我怎样才能找到什么字体实际上用于我的CreateFont调用? [英] How can I find what font was actually used for my CreateFont call?

查看:147
本文介绍了我怎样才能找到什么字体实际上用于我的CreateFont调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows中, <$ c $如果请求的字体没有被请求,c> CreateFontIndirect() 调用可以静静地替换兼容的字体。 GetObject() 调用不会反映这个替换;它会返回相同的 LOGFONT 传入。我怎样才能找到 创建的字体?另外,如何强制Windows只返回所需的确切字体?

解决方案


在Windows中,如果所请求的字体没有被请求,CreateFontIndirect()调用可以默默地替换兼容的字体。 GetObject()调用不会反映这个替换;它返回相同的LOGFONT传入。


不是CreateFontIndirect正在做替换。字体被选入DC时发生替换。 CreateFontIndirect只是给你一个LOGFONT的内部拷贝的句柄。这就是为什么GetObject为你提供相同的LOGFONT的原因。


我怎样才能找到 / p>

如果您在目标DC中选择了HFONT,则可以向DC请求关于实际选择的字体的信息最好与LOGFONT匹配。





基本上告诉你实际创建了什么字体。



另外:



当做类似于pr int预览,你可以从一个LOGFONT开始,选择它到打印机DC(或IC),抓取实际字体的细节(打印机常常替代字体),然后创建一个更能代表实际字体的LOGFONT。选择到屏幕DC,并 - 适当的大小转换 - 做一个相当不错的用户将实际得到匹配。


In Windows, the CreateFontIndirect() call can silently substitute compatible fonts if the requested font is not requested. The GetObject() call does not reflect this substitution; it returns the same LOGFONT passed in. How can I find what font was actually created? Alternately, how can I force Windows to only return the exact font requested?

解决方案

In Windows, the CreateFontIndirect() call can silently substitute compatible fonts if the requested font is not requested. The GetObject() call does not reflect this substitution; it returns the same LOGFONT passed in.

It's not CreateFontIndirect that's doing the substitution. The substitution happens when the font is selected into the DC. CreateFontIndirect just gives you a handle to an internal copy of the LOGFONT. That's why GetObject gives you the same LOGFONT back.

How can I find what font was actually created?

If you select the HFONT into the target DC, you can then ask the DC for the information about the font that was actually chosen as the best match to the LOGFONT.

That essentially tells you what font was actually created.

Aside:

When doing something like print preview, you can start with a LOGFONT, select it into the printer DC (or IC), grab the details of the actual font (printers often substitute fonts), and then create a new LOGFONT that's more representative of the actual font. Select that into the screen DC, and--with appropriate size conversions--do a pretty good match of what the user will actually get.

这篇关于我怎样才能找到什么字体实际上用于我的CreateFont调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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