[英]How to check installed fonts styles?
I need a list of all installed fonts in the client machine (Always Windows) that contain the styles bold , italic and bold italic . 我需要客户端计算机(始终为Windows)中所有已安装字体的列表,这些字体包含样式bold , italic和bold italic 。 Is there a function for that? 有功能吗?
I'm already able to list all installed fonts with EnumFontFamiliesEx
and i suppose that is possible to filter that list, but i'm looking for a "better way" :) 我已经能够使用EnumFontFamiliesEx
列出所有已安装的字体,并且我想可以过滤该列表,但是我正在寻找“更好的方式” :)
Thanks! 谢谢!
PS: I'm using C++ with MFC. PS:我在MFC中使用C ++。
EDIT: 编辑:
For fonts that doesn't have these styles Windows can "fake" that behavior (force a font look bold or italic), but i need to know which fonts really have these styles. 对于不具有这些样式的字体,Windows可以“伪造”该行为(强制字体显示为粗体或斜体),但是我需要知道哪种字体确实具有这些样式。
As you are using "EnumFontFamiliesEx",the call back function recieves the structure LOGFONT.... 当您使用“ EnumFontFamiliesEx”时,回调函数将接收到LOGFONT结构。
LOGFONT
has two variables lfWeight
and lfItalic
. LOGFONT
具有两个变量lfWeight
和lfItalic
。
Use those two variables to check if the enumerated font has style or not. 使用这两个变量来检查枚举字体是否具有样式。
if lfWeight
value is 0 ( FW_DONTCARE
) and lfItalic
is false, you can consider this do not have any style. 如果lfWeight
值为0( FW_DONTCARE
)并且lfItalic
为false,则可以认为它没有任何样式。
Or if you want to be very specific, for example, you want to consider fonts with only Bold and Regular, then you can validate, if lfWeight
has value from {400 (REGULAR), 600 (BOLD), 700 (BOLD), 800 (BOLD)} 或者,如果您想非常具体,例如,您只考虑粗体和常规字体,则可以验证lfWeight
值是否从{400(REGULAR),600(BOLD),700(BOLD),800 (胆大)}
Below link has all the details. 以下链接包含所有详细信息。
https://msdn.microsoft.com/en-us/library/windows/desktop/dd145037(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/dd145037(v=vs.85).aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.