mirror of https://github.com/axmolengine/axmol.git
fixed #2151: Custom font can't be loaded correctly if using full path of filename.
This commit is contained in:
parent
4e3ff65707
commit
8fa593a8fe
|
@ -72,7 +72,7 @@ public:
|
|||
|
||||
// If the path name returned includes the 'assets' dir then that needs to be removed, because the android.content.Context
|
||||
// requires this portion of the path to be omitted for assets inside the app package.
|
||||
if (fullPathOrFontName.find_first_of("assets/") == 0)
|
||||
if (fullPathOrFontName.find("assets/") == 0)
|
||||
{
|
||||
fullPathOrFontName = fullPathOrFontName.substr(strlen("assets/")); // Chop out the 'assets/' portion of the path.
|
||||
}
|
||||
|
|
|
@ -57,7 +57,15 @@ public class Cocos2dxTypefaces {
|
|||
|
||||
public static synchronized Typeface get(final Context pContext, final String pAssetName) {
|
||||
if (!Cocos2dxTypefaces.sTypefaceCache.containsKey(pAssetName)) {
|
||||
final Typeface typeface = Typeface.createFromAsset(pContext.getAssets(), pAssetName);
|
||||
Typeface typeface = null;
|
||||
if (pAssetName.startsWith("/"))
|
||||
{
|
||||
typeface = Typeface.createFromFile(pAssetName);
|
||||
}
|
||||
else
|
||||
{
|
||||
typeface = Typeface.createFromAsset(pContext.getAssets(), pAssetName);
|
||||
}
|
||||
Cocos2dxTypefaces.sTypefaceCache.put(pAssetName, typeface);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue