From 5959c24b80d22057f32fc46a0ca3661d329ddfee Mon Sep 17 00:00:00 2001 From: Andre Rudlaff Date: Wed, 30 Jan 2013 01:43:21 +0100 Subject: [PATCH] [Linux] fixed loading truetype fonts from resource directory We should use CCFileUtils to get the full path to font resources. Additionally the input font is converted to lowercase for checking if it is a ttf file. So we can also load .TTF or .tTf files. --- cocos2dx/platform/linux/CCImage.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cocos2dx/platform/linux/CCImage.cpp b/cocos2dx/platform/linux/CCImage.cpp index 3c43180b6e..183b3fe3d2 100644 --- a/cocos2dx/platform/linux/CCImage.cpp +++ b/cocos2dx/platform/linux/CCImage.cpp @@ -1,5 +1,6 @@ #include +#include #include #include #include @@ -231,8 +232,10 @@ public: std::string fontPath = family_name; // check if the parameter is a font file shipped with the application - if ( fontPath.find(".ttf") != std::string::npos ) { - fontPath = cocos2d::CCApplication::sharedApplication()->getResourceRootPath() + std::string("/") + fontPath; + std::string lowerCasePath = fontPath; + std::transform(lowerCasePath.begin(), lowerCasePath.end(), lowerCasePath.begin(), ::tolower); + if ( lowerCasePath.find(".ttf") != std::string::npos ) { + fontPath = cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(fontPath.c_str()); FILE *f = fopen(fontPath.c_str(), "r"); if ( f ) {