我有一个应用程序将文本写入图像 using System.Drawing
(C#).
我正在使用特定的字体来做到这一点。
由于我不能依赖共享托管服务器来获取我可能需要的所有自定义字体(并且字体列表可能会增长),因此如何管理用于我的应用程序的字体?
我可以包括吗.ttf
我的项目中的文件并以某种方式引用它们?
包含字体的 SQL 数据库怎么样?
应该可以将字体文件存储在磁盘或数据库中,然后使用私人字体集合类在运行时使用字体。
以下是您将如何使用它:
PrivateFontCollection collection = new PrivateFontCollection();
// Add the custom font families.
// (Alternatively use AddMemoryFont if you have the font in memory, retrieved from a database).
collection.AddFontFile(@"E:\Downloads\actest.ttf");
using (var g = Graphics.FromImage(bm))
{
// Create a font instance based on one of the font families in the PrivateFontCollection
Font f = new Font(collection.Families.First(), 16);
g.DrawString("Hello fonts", f, Brushes.White, 50, 50);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)