我试图在iPad上使用OpenGL绘制一些文本。所以我使用Freetype 2库来加载字体文件。如下所示:
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"
我从这里使用适用于iOS的Freetype 2库:
https://github.com/cdave1/freetype2-ios
我已经读过Feetype 2支持TrueType字体,但我不知道它无法打开.ttf / .ttc文件的原因。
由于
答案 0 :(得分: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。