//------------------------------------------------------------------------- // 函数集 //------------------------------------------------------------------------- void FKCW_font_default_initialize() { FKCW_font_default_fontpath = get_systemfont_path(); FKCW_font_default_ppi = get_system_default_ppi(); FKCW_font_default_fontfile = get_system_default_fontfile(); FKCW_font_default_size = get_prefered_default_fontsize(); CCAssert(FKCW_font_default_fontpath, ""); CCAssert(FKCW_font_default_fontfile, ""); CCFileUtils::sharedFileUtils()->addSearchPath(FKCW_font_default_fontpath); // 添加默认字体 FKCW_Font_Catalog* font_catalog = FKCW_Font_Factory::GetInstance()->CreateFont( FKCW_Font_Default_FontAlias, FKCW_font_default_fontfile, FKCW_font_default_color, FKCW_font_default_size, e_plain); // 回滚 if ( !font_catalog ) { FKCW_font_default_fontfile = get_system_fallback_fontfile(); font_catalog = FKCW_Font_Factory::GetInstance()->CreateFont( FKCW_Font_Default_FontAlias, FKCW_font_default_fontfile, FKCW_font_default_color, FKCW_font_default_size, e_plain); } else { if ( get_system_default_hacklatin_fontfile() ) { std::string fullpath = CCFileUtils::sharedFileUtils() ->fullPathForFilename(get_system_default_hacklatin_fontfile()); /*FontInfo* hackfont =*/ font_catalog->AddHackFont( fullpath.c_str(), latin_charset(), get_system_default_hacklatin_fontshifty()); } } }
// // dfont system default initializer // bool dfont_default_initialize() { std::string temStr=""; temStr=temStr+get_systemfont_path()+"/"+get_system_default_fontfile(); systemPaths.push_back(temStr); #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) addSystemFontPath("/System/Library/Fonts/STHeiti Medium.ttc"); addSystemFontPath("/System/Library/Fonts/Core/STHeiti-Medium.ttc"); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #endif for(auto&i:systemPaths) { if (CCFileUtils::sharedFileUtils()->isFileExist(i)) { dfont_default_fontfilepath=i.c_str(); break; } } dfont_default_fontpath = get_systemfont_path(); dfont_default_ppi = get_system_default_ppi(); dfont_default_fontfile = get_system_default_fontfile(); dfont_default_size = get_prefered_default_fontsize(); if (dfont_default_fontfilepath==NULL || dfont_default_fontfilepath=="") { return false; } //CCFileUtils::sharedFileUtils()->addSearchPath(dfont_default_fontpath); // add default font FontCatalog* font_catalog = FontFactory::instance()->create_font( DFONT_DEFAULT_FONTALIAS, dfont_default_fontfilepath, dfont_default_color, dfont_default_size, e_plain); // fallback if ( !font_catalog ) { dfont_default_fontfile = get_system_fallback_fontfile(); font_catalog = FontFactory::instance()->create_font( DFONT_DEFAULT_FONTALIAS, dfont_default_fontfile, dfont_default_color, dfont_default_size, e_plain); } else { // hack latin charset? if ( get_system_default_hacklatin_fontfile() ) { std::string fullpath = CCFileUtils::sharedFileUtils() ->fullPathForFilename(get_system_default_hacklatin_fontfile()); /*FontInfo* hackfont =*/ font_catalog->add_hackfont( fullpath.c_str(), latin_charset(), get_system_default_hacklatin_fontshifty()); } } return true; }