在开发板上实现矢量字体显示

对于开发板实现显示矢量字体,同样PC机一样,我需要字体文件,这里选择simsun.ttc(新宋体)。

1)初始化库

   FT_Init_FreeType( &library ); /* initialize library */

2)create face object

   FT_New_Face( library, argv[1], 0, &face );

3)设置字体大小

  FT_Set_Pixel_Sizes(face, 24, 0);

4)设置坐标

  pen.x = 0 * 64;

  pen.y = (var.yres - 24) * 64;

5)逐个显示

  for (i = 0; i < wcslen(wstr1); i++)

  {
    /* set transformation */
    FT_Set_Transform( face, 0, &pen);

    /* load glyph image into the slot (erase previous one) */
     FT_Load_Char( face, wstr1[i], FT_LOAD_RENDER );

    draw_bitmap( &slot->bitmap,slot->bitmap_left,var.yres - slot->bitmap_top);

    /* increment pen position */
    pen.x += slot->advance.x;

  }

根据以上架构,即可实现在开发板上显示单行文字的功能。

————————————————————————————————————————————————————————————————————————————— 无他,唯手熟尔。。。
原文地址:https://www.cnblogs.com/ZXNblog/p/4014769.html