diff --git a/cocos/platform/linux/CCDevice-linux.cpp b/cocos/platform/linux/CCDevice-linux.cpp index 806f45ed23..639f6539b5 100644 --- a/cocos/platform/linux/CCDevice-linux.cpp +++ b/cocos/platform/linux/CCDevice-linux.cpp @@ -345,11 +345,10 @@ public: std::string lowerCasePath = fontPath; std::transform(lowerCasePath.begin(), lowerCasePath.end(), lowerCasePath.begin(), ::tolower); if ( lowerCasePath.find(".ttf") != std::string::npos ) { - fontPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(fontPath.c_str()); - - FILE *f = fopen(fontPath.c_str(), "r"); - if ( f ) { - fclose(f); + fontPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(fontPath); + auto* fileStream = cocos2d::FileUtils::getInstance()->openFileStream(fontPath, FileStream::Mode::READ); + if ( fileStream ) { + delete fileStream; fontCache.insert(std::pair(family_name, fontPath)); return fontPath; }