FreeType.如何知道FT_Face中的符号数及其索引

FreeType. How to know number of symbols in FT_Face and its indices?

本文关键字:符号 索引 何知道 FT Face FreeType      更新时间:2023-10-16

我想知道FT_Face中包含的所有符号,以将其渲染为纹理。FT_FaceRec有"FT_Long num_glyphs",但它只告诉我它的编号,而没有它的索引。

我能做点什么对于(wchat_t c=0;c<max_value;c++)//在此处加载字符c

但这样一来,如果字体没有字符,我就会有很多"矩形"。这是开销,因为它的矩形在纹理上会被去掉。

如何知道该字体真正包含的字符的glyph_index或wchar_t?

可以通过函数遍历字体中的所有字符:FT_Get_First_Char和FT_Get_Next_Char

示例:

FT_UInt index;
FT_ULong character = FT_Get_First_Char(face, &index);
while (true) {
  // to do something
  character = FT_Get_Next_Char(face, character, &index);
  if (!index) break; // if FT_Get_Next_Char write 0 to index then
                     // have no more characters in font face
}

自由型包装

基于Ogre字体类,但使用多个纹理来存储字形,每个纹理都有固定的大小。