[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.
This commit is contained in:
Andre Rudlaff 2013-01-30 01:43:21 +01:00
parent e02bc8ad30
commit 5959c24b80
1 changed files with 5 additions and 2 deletions

View File

@ -1,5 +1,6 @@
#include <string.h>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
@ -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 ) {