Iphone development custom FONT
[ 2009-11-26 15:47:59 | 作者: ccloveaa ]
iphone上面应用自定义的truetype字体
#import <dlfcn.h>
....
typedef bool (*A_FUNC_TYPE)(const char*);
NSUInteger LOAD_FONT(){
NSUInteger newFontCount = 0;
NSBundle *frameworkBundle = [NSBundle bundleWithIdentifier:@"com.apple.GraphicsServices"];
const char *frameworkPath = [[frameworkBundle executablePath] UTF8String];
if (frameworkPath) {
void *graphicsServices = dlopen(frameworkPath, RTLD_NOLOAD | RTLD_LAZY);
if (graphicsServices) {
A_FUNC_TYPE GSFontAddFromFile = (A_FUNC_TYPE)dlsym(graphicsServices, "GSFontAddFromFile");
if (GSFontAddFromFile)
for (NSString *fontFile in [[NSBundle mainBundle] pathsForResourcesOfType:@"ttf" inDirectory:nil])
newFontCount += GSFontAddFromFile([fontFile UTF8String]);
}
}
printf("NEW FONT COUNT = %d\n",newFontCount);
return newFontCount;
};
评论Feed: http://www.ccloveaa.com/blog/feed.asp?q=comment&id=475
#import <dlfcn.h>
....
typedef bool (*A_FUNC_TYPE)(const char*);
NSUInteger LOAD_FONT(){
NSUInteger newFontCount = 0;
NSBundle *frameworkBundle = [NSBundle bundleWithIdentifier:@"com.apple.GraphicsServices"];
const char *frameworkPath = [[frameworkBundle executablePath] UTF8String];
if (frameworkPath) {
void *graphicsServices = dlopen(frameworkPath, RTLD_NOLOAD | RTLD_LAZY);
if (graphicsServices) {
A_FUNC_TYPE GSFontAddFromFile = (A_FUNC_TYPE)dlsym(graphicsServices, "GSFontAddFromFile");
if (GSFontAddFromFile)
for (NSString *fontFile in [[NSBundle mainBundle] pathsForResourcesOfType:@"ttf" inDirectory:nil])
newFontCount += GSFontAddFromFile([fontFile UTF8String]);
}
}
printf("NEW FONT COUNT = %d\n",newFontCount);
return newFontCount;
};
评论Feed: http://www.ccloveaa.com/blog/feed.asp?q=comment&id=475
Gunner!Lingo,Flash action script,max plug-in.
Contact Way:QQ:58920142 MSN:ccloveaa@sina.com
李连杰->壹基金->民间后援团!
Contact Way:QQ:58920142 MSN:ccloveaa@sina.com
李连杰->壹基金->民间后援团!
这篇日志没有评论.






