gpt4 book ai didi

c# - 如何加载自定义字体以在 Windows Azure 上绘制图像?

转载 作者:行者123 更新时间:2023-11-30 13:51:04 25 4
gpt4 key购买 nike

我需要使用自定义字体在我自己的应用程序上绘图。

是否可以通过部署脚本安装?

最佳答案

How to manage custom fonts in web application (system.drawing)

It should be possible to store your font files on disk or in database, and then use the PrivateFontCollection class to use the fonts at runtime.

Here is how you would use it:

    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);
}

干杯。

关于c# - 如何加载自定义字体以在 Windows Azure 上绘制图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5114658/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com