2017-08-01 25 views

回答

-1

Freetype提供了两个功能来完成此任务。第一个是FT_Get_First_Char(FT_Face face, FT_UInt * agindex)

该函数将返回字体支持的第一个字符的代码。它还会将由agindex指向的变量设置为字形在字体中的索引。请注意,如果它设置为0,这意味着字体中没有其他字符。

您需要的下一个功能是 FT_Get_Next_Char(FT_Face face, FT_ULong char_code, FT_UInt * agindex)。这将让你通过返回它的值来获取字体中下一个可用的字符。请注意,就像FT_Get_First_Char一样,当它返回最终的字形时,它也会将agindex设置为零。

所以现在的工作示例:

// Load freetype library before hand. 
FT_Face face; 

// Load the face by whatever means you feel are best. 

FT_UInt index; 
FT_ULong c = FT_Get_First_Char(face, &index); 

while (index) { 
    std::cout << "Supported Code: " << c << std::endl; 

    // Load character glyph. 
    FT_Load_Char(face, c, FT_LOAD_RENDER); 

    // You can now access the glyph with: 
    // face->glyph; 

    // Now grab the next charecter. 
    c = FT_Get_Next_Char(face, c, &index); 
} 

// Make sure to clean up your mess. 
+0

在我的代码我使用FT_Load_Glyph(ftFace,glyphIndex,FT_LOAD_DEFAULT)和FT_Render_Glyph(ftFace->字形,FT_RENDER_MODE_NORMAL),似乎从你输入什么不同,它确实工作,所以它让我想知道。 – Zebrafish

+0

我在想什么,所有的downvotes。 – Zebrafish

相关问题