什么是Windows系统字体规格 [英] What are the windows system font specifications

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

问题描述

我目前正在尝试根据当前字体重新调整应用程序的字体大小,以便我使用 WM_GETFONT 来获取字体和重新大小与一个方程使用字体的宽度和高度输入,问题是它的返回值是系统字体,我不知道该字体的规格。

任何人都可以告诉我如何获得系统字体的规格?操作系统的系统字体是否有所不同?

解决方案

您可以检索结构,在 结构 code> HFONT 使用以下代码:

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

有了这些,您就可以获得所需的所有信息,并且可以只更改所需的部分。要得到 HFONT ,你可以使用

 code> HFONT hFontCustom = :: CreateFontIndirect(& lf); 

您也可以考虑使用 WM_GETFONT 使用 SystemParametersInfo 来检索 NONCLIENTMETRICS 结构,它们已经具有 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系统字体规格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆