免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 7894 | 回复: 3
打印 上一主题 下一主题

[桌面系统] Linux下使用freetype显示中文的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-02-28 15:51 |只看该作者 |倒序浏览
在嵌入式环境中显示字体,如果采用点阵的方式,要先取得汉字的点阵表示形式,然后根据点阵中每一位是否为1来决定是否对屏幕上相应的像素赋值;如果采用矢量字体的话,例如使用freetype库来显示TrueType类型的字体时,其大致的过程如下:

1.初始化库

FT_Library  library;
FT_Face     face;

FT_Error error = FT_Init_FreeType( &library );

2. 加载相应的字体文件

error = FT_New_Face( library, "/usr/share/fonts/truetype/arial.ttf", 0, &face );

3. 设置字体的大小

error = FT_Set_Char_Size(face,    /* handle to face object */
                                             0,       /* char_width in 1/64th of points  */
                                         16*64,   /* char_height in 1/64th of points */
                                           300,     /* horizontal device resolution    */
                                          300 );   /* vertical device resolution      */

  error = FT_Set_Pixel_Sizes(face,   /* handle to face object */
                                               0,      /* pixel_width           */
                                             16 );   /* pixel_height          */


4.  加载字符的glyph

glyph_index = FT_Get_Char_Index( face, charcode );

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

error = FT_Render_Glyph( face->glyph,   /* glyph slot  */
                                        render_mode ); /* render mode */

5.  字体变换(旋转和缩放)

error = FT_Set_Transform( face,       /* target face object    */
                                         &matrix,    /* pointer to 2x2 matrix */
                                         &delta );   /* pointer to 2d vector  */

6. 把字符显示出来
draw_bitmap( &slot->bitmap,  pen_x + slot->bitmap_left,  pen_y - slot->bitmap_top );


我的问题在上述第六步中得到FT_Bitmap的指针(&slot->bitmap)后,如何吧FT_Bitmap中的内容在frame buffer中显示出来了?


谢谢大家先!

论坛徽章:
0
2 [报告]
发表于 2008-04-03 17:20 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
3 [报告]
发表于 2008-07-31 18:21 |只看该作者
我编译了(对fon字体支持的库文件),头文件也包含近来了,为什么下句总是执行不成功?
error = FT_New_Face( library, "/usr/share/fonts/truetype/roman.fon", 0, &face );

我的QQ:645488292

论坛徽章:
0
4 [报告]
发表于 2008-08-01 22:44 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP