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

时间:2011-02-25 07:23:04

标签: c# azure fonts

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

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

1 个答案:

答案 0 :(得分:8)

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

  

应该可以存储你的   磁盘或数据库中的字体文件   然后使用   PrivateFontCollection上课   在运行时使用字体。

     

以下是您将如何使用它:

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

干杯。