本文介绍了什么是Windows系统字体规格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试根据当前字体重新调整应用程序的字体大小,以便我使用 结构 code> HFONT 使用以下代码:

  LOGFONT lf = {0}; 
:: GetObject(hFont,sizeof(lf),& lf);

有了这些,您就可以获得所需的所有信息,并且可以只更改所需的部分。要得到 HFONT ,你可以使用来检索,它们已经具有 LOGFONT 结构,您可以复制,修改和使用 CreateFontIndirect

至于你的第二个问题,字体设置是每个用户设置的,所以它可以是不同的与两个不同用户登录相同的安装。


I'm currently trying to re-size the font of an application based on it's current font, in order to do that I was going to use WM_GETFONT to get the font and re-size it with an equation using the width and height of the font for input, the problem is it's return value is the system font and I don't know the specifications for that font.

Can anyone tell me how to get the specifications for the system font? Does the system font differ between OS's?

解决方案

You can retrieve a LOGFONTstructure for an HFONT using the following code:

LOGFONT lf = { 0 };
::GetObject( hFont, sizeof( lf ), &lf );

With that you have all the information you need and can change just the parts you want to. To get an HFONT back you would use CreateFontIndirect:

HFONT hFontCustom = ::CreateFontIndirect( &lf );

Instead of using WM_GETFONT you could also consider using SystemParametersInfo to retrieve a NONCLIENTMETRICS structure that already has LOGFONT structures you can copy, modify, and use with CreateFontIndirect as illustrated above.

As for your second question, the font setting is a per user setting so it can be different even on the same installation with two different users logged on.

这篇关于什么是Windows系统字体规格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 07:19