字体对话框仅显示TrueType字体 [英] Font Dialog show only truetype fonts

查看:166
本文介绍了字体对话框仅显示TrueType字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个通用的FontDialog,它会自动列出字体.问题是,如果有人选择了非TrueType字体,它将在预览及所有内容中显示出来,但是当他们单击确定"/应用"时,它将返回一个异常,即仅支持TrueType字体.这不是TrueType字体."

解决方案

AllowScriptChange属性设置为false. /blockquote>

您可以尝试自己使用google而不是对已提交的唯一(几乎已使用了一年的)答案进行1票表决.我做了(想出第一个答案),然后我再次想出了这个:

调用ChooseFont()时包括CF_TTONLY标志.这可能涉及使用PInvoke使用Windows api,但是我认为您是程序员,所以这没什么大不了的.


I made a generic FontDialog and it auto lists fonts. The problem is if someone picks a non-truetype font, it displays it in the preview and everything, but when they hit ok/apply it comes back with an exception "Only TrueType fonts are supported. This is not a TrueType font."
How do I get the dialog so that non-true type fonts aren''t listed in the Font Dialog?

解决方案

Set the AllowScriptChange property to false.


Instead of 1-voting the only (almost year-old) answer that was submitted, you could try using google yourself. I did (to come up with the first answer), and I did again to come up with this one:

Include the CF_TTONLY flag when you call ChooseFont(). This may involve using PInvoke to use the windows api, but I assume you''re a programmer, so this shouldn''t be a big deal.


这篇关于字体对话框仅显示TrueType字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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