mirror of https://github.com/axmolengine/axmol.git
[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:
parent
e02bc8ad30
commit
5959c24b80
|
@ -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 ) {
|
||||
|
|
Loading…
Reference in New Issue