如何加载自定义字体以在Windows Azure上绘制图像? [英] How can I load custom fonts to draw over image on Windows Azure?

查看:175
本文介绍了如何加载自定义字体以在Windows Azure上绘制图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用自定义字体来绘制我自己的应用程序。



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

解决方案

如何在Web应用程序中管理自定义字体(system.drawing)
$ b


应该可以将
字体文件存储在磁盘或数据库中,
然后使用
PrivateFontCollection class
在运行时使用字体。

以下是您将如何使用它: b

  PrivateFontCollection collection = new PrivateFontCollection(); 
//添加自定义字体系列。
//(如果内存中有字体,则使用AddMemoryFont,从数据库中检索)。
collection.AddFontFile(@E:\Downloads\actest.ttf);
使用(var g = Graphics.FromImage(bm))
{
//根据PrivateFontCollection中的字体系列之一创建一个字体实例
Font f = new Font (collection.Families.First(),16);
g.DrawString(Hello fonts,f,Brushes.White,50,50);

干杯。


I need to use custom fonts for drawing on my own application.

Is it possible to install by deployment scripts?

解决方案

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

Cheers.

这篇关于如何加载自定义字体以在Windows Azure上绘制图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆