生成Word/ATU报表提示 font family not found

1、先从你本机 C:\Windows\Fonts 拷贝或者网络上下载你想要安装的字体文件(*.ttf文件)到 /usr/share/fonts/chinese/TrueType 目录下(如果系统中没有此目录,则自行mkdir创建,亦可重命名为自己喜欢的文件夹名)

2、修改字体文件的权限,使root用户以外的用户也可以使用

cd /usr/share/fonts/chinese/TrueType

chmod 755 *.ttf

3、建立字体缓存

mkfontscale (如果提示 mkfontscale: command not found,需自行安装 # yum install mkfontscale )

mkfontdir

fc-cache -fv (如果提示 fc-cache: command not found,则需要安装# yum install fontconfig )

4、重启计算机

reboot

2、安装完毕后,我们在代码中指定要使用的字体

context.Response.ContentType = “image/gif”;
            Bitmap basemap = new Bitmap(200, 60);
            Graphics garph1 = Graphics.FromImage(basemap);
 
            garph1.FillRectangle(new SolidBrush(Color.White), 0, 0, 200, 60);
            Font font = new Font(“consola.ttf”, 48, FontStyle.Bold, GraphicsUnit.Pixel);
 
            Random r = new Random();
            string letters = “ABCDEFGHIJKLMNPQRSTUVWXYZ”;
            string letter;
            StringBuilder s = new StringBuilder();
            for (int i = 0; i < 5; i++)
            {
                letter = letters.Substring(r.Next(0, letters.Length – 1), 1);
                s.Append(letter);
                garph1.DrawString(letter, font, new SolidBrush(Color.Black), i * 38, r.Next(0, 15));
 
            }
 
            Pen linePen = new Pen(new SolidBrush(Color.Black), 2);
            for (int x = 0; x < 6; x++)
            {
                garph1.DrawLine(linePen, new Point(r.Next(0, 199), r.Next(0, 59)), new Point(r.Next(0, 199), r.Next(0, 59)));
            }
 
            basemap.Save(context.Response.OutputStream, ImageFormat.Gif);
            context.Session[“CheckCode”] = s.ToString();    //存入Session,用于对比验证
            context.Response.End();

再次访问清晰可见啊

转自:http://www.uol123.com/2017/06/15/linux%E4%B8%8Agdi%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8%E5%AD%97%E4%BD%93-font-family-not-found.html

转载于:https://www.cnblogs.com/music378/p/7218756.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值