.NET的System.Drawing.Font - 获取可用的大小和样式 [英] .NET System.Drawing.Font - Get Available Sizes and Styles

查看:394
本文介绍了.NET的System.Drawing.Font - 获取可用的大小和样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个组合,允许用户选择一个字体名称。



第二个应该显示可用的字体大小。第三必须显示可用的样式。

问题:如何检索System.Drawing.Font支持的大小和样式?

解决方案

您可以使用 InstalledFontCollection 类检索可用的字体,然后枚举它们,如图所示在这篇MSDN文章中。

  InstalledFontCollection installedFontCollection = new InstalledFontCollection(); 

//获取FontFamily对象的数组。
fontFamilies = installedFontCollection.Families;

//下面的循环创建一个大字符串,它是以逗号分隔的
//所有字体系列名称的列表。

int count = fontFamilies.Length;
for(int j = 0; j {
familyName = fontFamilies [j] .Name;
familyList = familyList + familyName;
familyList = familyList +,;
}


I have one combo that allows user to select a font name.

The 2nd is supposed to show available sizes of the font. The 3rd has to show available styles.

Question: how can I retrieve the sizes and styles selected System.Drawing.Font supports?

解决方案

You could use the InstalledFontCollection class to retrieve the available fonts and then enumerate them as shown in this MSDN article.

InstalledFontCollection installedFontCollection = new InstalledFontCollection();

// Get the array of FontFamily objects.
fontFamilies = installedFontCollection.Families;

// The loop below creates a large string that is a comma-separated
// list of all font family names.

int count = fontFamilies.Length;
for (int j = 0; j < count; ++j)
{
    familyName = fontFamilies[j].Name;
    familyList = familyList + familyName;
    familyList = familyList + ",  ";
}

这篇关于.NET的System.Drawing.Font - 获取可用的大小和样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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