2011-02-25 19 views

回答

7

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

干杯。