在使用freetype过程中发现,从window下拷贝来的simsun.ttc, simkai.ttf两个字体,

在调用

FT_Set_Pixel_Sizes(face, 12, 0);

将字体大小设置为12×12pixels,或者16×16pixels等时,中文无法正常画出,英文可以正常画出。

而设置为10×10pixepixels, 17×17pixels时,却能正常画出中文。

其实解决方法是比较简单的,不过还是贴出来供新手有个参考。

分析:

后来经过跟踪发现在设置为12×12pixels时,

FT_Load_Glyph(face, FT_Get_Char_Index(face, szText), FT_LOAD_DEFAULT);

函数在load时,从字体文件中load的时bitmapped image,而不是outline,而可能是字体中的bitmapped image有问题,从而造成无法正常画出中文。

联想到freetype帮助文档中有如下的描述

Loading a glyph image into the slot is performed by calling FT_Load_Glyph as in

error = FT_Load_Glyph( face, /* handle to face object */ glyph_index, /* glyph index */ load_flags ); /* load flags, see below */

The load_flags value is a set of bit flags used to indicate some special operations. The default valueFT_LOAD_DEFAULT is 0.

This function will try to load the corresponding glyph image from the face:

  • If a bitmap is found for the corresponding glyph and pixel size, it will be loaded into the slot. Embedded bitmaps are always favored over native image formats, because we assume that they are higher-quality versions of the same glyph. This can be changed by using the FT_LOAD_NO_BITMAP flag.

  • Otherwise, a native image for the glyph will be loaded. It will also be scaled to the current pixel size, as well as hinted for certain formats like TrueType and Type 1.

解决办法:

error = FT_Load_Glyph(face, FT_Get_Char_Index(face, szText), FT_LOAD_DEFAULT|FT_LOAD_NO_BITMAP);

这样强制在load时,loadoutline,然后再根据outline得到bitmapped image。

通过这样修改后,上面提到的问题得到解决。

(转载)

宋体freetype16和12号字无法正常显示的更多相关文章

  1. chrome浏览器设置小于12号的字体不起作用?

    在某些chrome浏览器下,css里设置的10号字体竟然不起作用!仍显示12号大小,对比firefox.ie6.7.8.9,他们的显示都是好的. 要是你也碰到这问题,可以这样解决: -webkit-t ...

  2. chrome显示小于12号字体的方法

    我现在做一个支持英文的网站,但是字体要设置小于12号字体,我百度方法是-webkit-text-size-adjust:none;  但是谷歌为什么不支持啊,  有没有解决办法 让谷歌浏览器 支持小于 ...

  3. CSS3手机端字体不能小于12号的方法

    CSS3手机端字体不能小于12号的方法 <pre> .xiaoyu12fontsize{ -webkit-transform-origin: 0% 0%; -webkit-transfor ...

  4. 量子化学Gaussian技术实战课 2021年4月9号--12号 远程在线教学

    材料模拟分子动力学课程 3月19号--22号 远程在线课 lammps分子动力学课程 3月12号--15号 远程在线课 第一性原理VASP实战课 3月25号-28号 远程在线课 量子化学Gaussia ...

  5. Easyui Datagrid rownumbers行号四位、五位显示不完全的解决办法

    Easyui Datagrid rownumbers行号四位.五位显示不完全的解决办法(引) 方法一: 相信很多人在使用easyui的时候都遇到过这个问题,当我们设置成显示Rownumber的时候,你 ...

  6. 10月12号 晚八点 Speed-BI 云平台-基于Excel数据源的管理驾驶舱构建全过程,腾讯课堂开课啦

    认真地做了一大摞一大摞的报表,老板没时间看?努力把能反馈的内容都融汇进图表里,老板嫌复杂?做了几个简单的报表,老板一眼就觉得信息不全面?每个报表都用了各种各样的图表,老板却毫无兴趣?明明很努力了,为什 ...

  7. 4.12号HTML、CSS

    HTML 表单元素: 多行文本域<textarea> 标签定义多行的文本输入控件.文本区中可容纳无限数量的文本,其中的文本的默认字体是等宽字体(通常是 Courier).可以通过 cols ...

  8. 7月12号day4总结

    今天学习过程和总结 封装JDBC在src/main/java下com.neuedu下utils建立JDBCUilt.java 进行封装,基于框架的开发要么继承父类要么实现接口 一个方法里只能有一个动态 ...

  9. 6.12号整理(h5新特性-图片、文件上传)

    <input type="file" id='myFile' multiple> <ul> <li> <img src="&qu ...

随机推荐

  1. linux系统安装java环境

    参考资料:实测可用 https://www.cnblogs.com/xuliangxing/p/7066913.html

  2. Turn the Rectangles 1008B

    output standard output There are nn rectangles in a row. You can either turn each rectangle by 9090  ...

  3. Delphi XE8 中TIdTCPClient的WriteLn编码变化!

    //XE2中正常的代码: IdTCPClient1.IOHandler.WriteLn(sendData,TEncoding.ANSI); //XE8中不行了,解决方法: //,引入“IdGlobal ...

  4. 一个未完成的2.6.32-220内核踩内存crash分析记录

    遇到一个crash,log如下: BUG: unable to handle kernel NULL pointer dereference at (null) IP: [<ffffffff81 ...

  5. centos7启动iptables时报Job for iptables.service failed because the control process exited with error cod

    centos7启动iptables时报Job for iptables.service failed because the control process exited with error cod ...

  6. Python正则表达式与re模块介绍

    Python中通过re模块实现了正则表达式的功能.re模块提供了一些根据正则表达式进行查找.替换.分隔字符串的函数.本文主要介绍正则表达式先关内容以及re模块中常用的函数和函数常用场景. 正则表达式基 ...

  7. 迷你MVVM框架 avalonjs1.5.2 发布

    经过2个小版本的试水, avalon1.5这个全新的架构也终于成熟了. 首先是组件的配置项,名字改了不少,让大家都满意. ms-duplex, ms-include, ms-if等指令的BUG修复. ...

  8. OpenWrt上搭建纯L2TP服务器[ZT]

    转自:http://www.openwrt.pro/post-389.html 纯L2TP(l2tp + ppp,无IPSec) 首先安装xl2tpd软件包 opkg update opkg inst ...

  9. Ajax与select标签的组合运用

    ---------------------------------------------------------------------------------------------------- ...

  10. 收藏点webservice接口

    商业和贸易: 1.股票行情数据 WEB 服务(支持香港.深圳.上海基金.债券和股票:支持多股票同时查询) Endpoint: http://webservice.webxml.com.cn/WebSe ...