自定义字体样式与图形自定义、样式、图形、字体

2023-09-07 09:31:58 作者:如山中清风

予有字体的清单如下:

I have the following list of fonts:

我有使用它们没有任何问题,通过

I have no issues with using them via

new Font("XXXX Sans", 21, FontStyle.Bold, GraphicsUnit.Pixel)

不过,我该怎么办时,我需要使用一个非标准的字体样式般的光芒?所有提供的是一个枚举,这是不适合的。

However, what do i do when i need to use a non-standard font style like light? All that is provided is an enumeration and that is not suitable.

推荐答案

你能不只是使用的字体名称出现在控制面板?大多数字体是不正规,粗体或斜体居然有正规反正一个亚家族类型。如果你下载字体属性扩展微软你可以看到这个名称选项卡上。即净知道它们的方式,控制面板中列出他们和方式有时是不同的,因此它是一个好主意,列出所有的字体从.net的观点:

Can you not just use the font name as it appears in the control panel? Most fonts that aren't regular, bold or italic actually have a subfamily type of "regular" anyways. If you download the font properties extensions from Microsoft you can see this on the Names tab. The way the the control panels lists them and the way that .Net knows about them is sometimes different so its a good idea to list out all of the fonts from .Net's perspective:

        var installed_fonts = new InstalledFontCollection();
        var families = installed_fonts.Families;
        var allFonts = new List<string>();
        foreach(FontFamily ff in families){
            allFonts.Add(ff.Name);
        }
        allFonts.Sort();
        foreach(String s in allFonts){
            Console.WriteLine(s);
        }

下面是使用富兰克林哥特式黛咪电导率(这是列在CP作为富兰克林哥特式电导率黛咪)

And here's a sample that use Franklin Gothic Demi Cond (which is listed in the CP as "Franklin Gothic Cond Demi")

e.Graphics.DrawString("Test", new Font("Franklin Gothic Demi Cond", 12), new SolidBrush(Color.Red), 25, 25);