简体   繁体   中英

How to import a font from a .ttf file

I'm using Graphics.DrawString and I don't want to use Arial for my font but I don't know how to use/import one from file. This is my code.

using (Font myFont = new Font("Arial", 14))
{
    Graphics.DrawString("Hello", myFont, Brushes.Black, new Point(2, 2));
}

I'm using a .ttf file.

MSDN文档“ 如何:创建专用字体集合”包含一个代码示例,该代码示例显示如何使用PrivateFontCollection类加载和使用自定义字体。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM