2017-07-02 9 views
0

graphics.DrawStringを使用して画像にテキストを描画するアプリケーションを.netに開発しています。このメソッドはパラメータとしてフォントを受け入れますが、ローカルにはフォントをインストールして使用できますが、ホストにフォントをインストールするにはどうすればいいですか?(フォントをインストールするオペレーティングシステムにアクセスできない場合、私の場合はAzureweb appとしてホストしています。ウェブアプリケーションでグラフィックスで使用するフォントをインストールするには

私の質問は、Webサーバにフォントをインストールするか、あるいは単にその機能でそれを使用するだけです。

 using (Graphics graphics = Graphics.FromImage(bitmap)) 
     { 
      // some codes 
      graphics.DrawString(text, font, brush, location, drawFormat); 
     } 

答えて

1

私は同じ問題を持つ場合、他の人に解決策を見つけた:

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); 
    } 
関連する問題