2011-12-15 36 views
0

我想畫上使用OpenGL的iPad.So我使用FreeType 2的庫加載字體files.Like一些文字如下:FreeType 2的無法打開的.ttf/.ttc字體文件

 FT_New_Face(ft, "/System/Library/Fonts/Geneva.dfont", 0, &face) 

編譯器不拋出任何錯誤打開文件,但是當我嘗試這樣做:

 FT_New_Face(ft, "/System/Library/Fonts/HelveticaLight.ttf", 0, &face) 

我得到的錯誤是:

 "FT_Stream_Open: could not open `/System/Library/Fonts/HelveticaLight.ttf' 
     Could not open font" 

我現在用的是FreeType 2的庫爲iOS從這裏:

https://github.com/cdave1/freetype2-ios

我已閱讀,Feetype 2支持TrueType字體,但我不知道爲什麼它是無法打開的.ttf/.ttc文件。

感謝

+0

這可能聽起來很愚蠢,但你確定你打開的是在那裏嗎?這聽起來有點像I/O錯誤。另外,你確定編譯器報告錯誤嗎?它不應該在運行時出錯嗎? – 2012-01-20 10:05:58

回答

0

試圖尋找在CGFontCache.plist路徑字體:

NSDictionary *fontsDict = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/Fonts/CGFontCache.plist"]; 
NSDictionary* traitsDict = [fontsDict valueForKey:@"TraitMappings"]; 
NSDictionary *arialMappingDict = [traitsDict valueForKey:@"Arial"]; 
NSDictionary *namesDict = [fontsDict valueForKey:@"Names"]; 
NSString* arialPathSting = [namesDict valueForKey:[arialMappingDict valueForKey:@"Plain"]]; 
FT_Error error = FT_New_Face(ft, [arialPathSting UTF8String], 0, &face) 

工作正常的iOS設備,但對模擬器的問題。其實,我沒有在模擬器上找到CGFontCache.plist。