2017-08-01 105 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

相關問題