FontDialog中缺少字体

FontDialog中缺少字体

本文介绍了WinForms.FontDialog中缺少字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我显示一个WinForms.FontDialog(C#,.NET 2.0)的实例时,我错过了一些我期望在那里的字体(例如Courier,Fixedsys,MS Sans Serif)。另外,一位客户抱怨说,他安装的Adobe字体也没有显示在列表中。



我怎样才能让这些字体显示在这个对话框中? FontDialog被设计为只显示TrueType字体以保持与GDI +的兼容性。获取它显示设备字体需要一点反思黑客:

  using System.Reflection; 

...

  FontDialog fontDialog1 = new FontDialog(); 

MethodInfo mi = typeof(FontDialog).GetMethod(SetOption,
BindingFlags.NonPublic | BindingFlags.Instance);
mi.Invoke(fontDialog1,new object [] {0x40000,false});
fontDialog1.ShowDialog();

我不知道这是否也启用Adobe的OpenType字体,我没有。让我们知道。


When I display an instance of WinForms.FontDialog (C#, .NET 2.0), I am missing some fonts that I expect to be there (e.g. Courier, Fixedsys, MS Sans Serif). Also, a customer is complaining that Adobe fonts he has installed are also not showing up in the list.

How can I get these fonts to display in this dialog?

解决方案

FontDialog was designed to only show TrueType fonts to stay compatible with GDI+. Getting it to show the device fonts takes a bit of Reflection hacking:

using System.Reflection;

...

FontDialog fontDialog1 = new FontDialog();

MethodInfo mi = typeof(FontDialog).GetMethod("SetOption",
    BindingFlags.NonPublic | BindingFlags.Instance);
        mi.Invoke(fontDialog1, new object[] { 0x40000, false });
fontDialog1.ShowDialog();

I don't know whether this also enables Adobe's OpenType fonts, I don't have any. Let us know.

这篇关于WinForms.FontDialog中缺少字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 08:18