简体   繁体   English

如何检查已安装的字体样式?

[英]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)中所有已安装字体的列表,这些字体包含样式bolditalicbold 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具有两个变量lfWeightlfItalic

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.

相关问题 如何检查是否安装了libc ++? - How to check if libc++ is installed? 如何检查程序是否在C ++中与Qt一起安装 - How to check if program is installed with Qt in C++ 如何检查是否安装了 USB CDC 驱动程序 - How to check if USB CDC driver is installed 如何使用C或C ++在Linux上获取已安装的True Type字体列表? - How to get a list of installed True Type Fonts on Linux using C or C++? 如何使用非托管C ++获取Windows上已安装字体的列表? - How can I get a list of installed fonts on Windows, using unmanaged C++? 如何获取 Windows 上已安装 fonts 的列表,包括使用 c++ 的字体样式 - How can I get a list of installed fonts on Windows including font style using c++ SetCurrentConsoleFontEx() 不适用于自定义安装的 fonts - SetCurrentConsoleFontEx() doesn't work with custom installed fonts 如何从代码中检查Tesseract API中是否安装了某种语言? - How check from code if some language is installed in Tesseract API? 如何使用C ++检查计算机中安装的ShellIconOverLayIdentifers总数 - How to check total number ShellIconOverLayIdentifers installed in a computer using C++ 如何检查(在C / C ++代码中)我的计算机上是否安装了Openssl? - How to check (in C/C++ code) if Openssl is installed on my computer?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM