免费注册 查看新帖 |

Chinaunix

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

Linux下如何使用freetype显示字体的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-02-28 15:44 |只看该作者 |倒序浏览
在嵌入式环境中显示字体,如果采用点阵的方式,要先取得汉字的点阵表示形式,然后根据点阵中每一位是否为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-03-08 16:16 |只看该作者
没有人回答,自己顶一下吧,再问可以利用Freetype来生成点阵字体的文件么?可以的话,怎么生成了?

论坛徽章:
95
程序设计版块每日发帖之星
日期:2015-09-05 06:20:00程序设计版块每日发帖之星
日期:2015-09-17 06:20:00程序设计版块每日发帖之星
日期:2015-09-18 06:20:002015亚冠之阿尔艾因
日期:2015-09-18 10:35:08月度论坛发贴之星
日期:2015-09-30 22:25:002015亚冠之阿尔沙巴布
日期:2015-10-03 08:57:39程序设计版块每日发帖之星
日期:2015-10-05 06:20:00每日论坛发贴之星
日期:2015-10-05 06:20:002015年亚冠纪念徽章
日期:2015-10-06 10:06:482015亚冠之塔什干棉农
日期:2015-10-19 19:43:35程序设计版块每日发帖之星
日期:2015-10-21 06:20:00每日论坛发贴之星
日期:2015-09-14 06:20:00
3 [报告]
发表于 2008-03-10 21:06 |只看该作者
原帖由 wwsheng 于 2008-3-8 16:16 发表
没有人回答,自己顶一下吧,再问可以利用Freetype来生成点阵字体的文件么?可以的话,怎么生成了?

这个问题在嵌入式版里面问可能效果更好些。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP