Loading core/java/android/content/res/FontResourcesParser.java +12 −10 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import com.android.internal.R; import android.annotation.NonNull; import android.annotation.Nullable; import android.util.AttributeSet; import android.util.Log; import android.util.Xml; import org.xmlpull.v1.XmlPullParser; Loading @@ -34,6 +35,7 @@ import java.util.List; * @hide */ public class FontResourcesParser { private static final String TAG = "FontResourcesParser"; private static final int NORMAL_WEIGHT = 400; private static final int ITALIC = 1; Loading Loading @@ -79,12 +81,10 @@ public class FontResourcesParser { private boolean mItalic; private int mResourceId; public FontFileResourceEntry(@NonNull String fileName, int weight, boolean italic, int resourceId) { public FontFileResourceEntry(@NonNull String fileName, int weight, boolean italic) { mFileName = fileName; mWeight = weight; mItalic = italic; mResourceId = resourceId; } public @NonNull String getFileName() { Loading @@ -98,10 +98,6 @@ public class FontResourcesParser { public boolean isItalic() { return mItalic; } public int getResourceId() { return mResourceId; } } // A class represents file based font-family element in xml file. Loading Loading @@ -140,6 +136,7 @@ public class FontResourcesParser { return readFamily(parser, resources); } else { skip(parser); Log.e(TAG, "Failed to find font-family tag"); return null; } } Loading Loading @@ -184,7 +181,10 @@ public class FontResourcesParser { if (parser.getEventType() != XmlPullParser.START_TAG) continue; String tag = parser.getName(); if (tag.equals("font")) { fonts.add(readFont(parser, resources)); final FontFileResourceEntry entry = readFont(parser, resources); if (entry != null) { fonts.add(entry); } } else { skip(parser); } Loading @@ -203,12 +203,14 @@ public class FontResourcesParser { int weight = array.getInt(R.styleable.FontFamilyFont_fontWeight, NORMAL_WEIGHT); boolean isItalic = ITALIC == array.getInt(R.styleable.FontFamilyFont_fontStyle, 0); String filename = array.getString(R.styleable.FontFamilyFont_font); int resourceId = array.getResourceId(R.styleable.FontFamilyFont_font, 0); array.recycle(); while (parser.next() != XmlPullParser.END_TAG) { skip(parser); } return new FontFileResourceEntry(filename, weight, isItalic, resourceId); if (filename == null) { return null; } return new FontFileResourceEntry(filename, weight, isItalic); } private static void skip(XmlPullParser parser) throws XmlPullParserException, IOException { Loading core/java/android/content/res/ResourcesImpl.java +0 −1 Original line number Diff line number Diff line Loading @@ -789,7 +789,6 @@ public class ResourcesImpl { final FontResourcesParser.FamilyResourceEntry familyEntry = FontResourcesParser.parse(rp, wrapper); if (familyEntry == null) { Log.e(TAG, "Failed to find font-family tag"); return null; } return Typeface.createFromResources(familyEntry, mAssets, file); Loading graphics/java/android/graphics/Typeface.java +4 −5 Original line number Diff line number Diff line Loading @@ -230,6 +230,7 @@ public class Typeface { FontFamily fontFamily = new FontFamily(); for (final FontFileResourceEntry fontFile : filesEntry.getEntries()) { // TODO: Add ttc and variation font support. (b/37853920) if (!fontFamily.addFontFromAssetManager(mgr, fontFile.getFileName(), 0 /* resourceCookie */, false /* isAsset */, 0 /* ttcIndex */, fontFile.getWeight(), fontFile.isItalic() ? STYLE_ITALIC : STYLE_NORMAL, Loading @@ -237,11 +238,9 @@ public class Typeface { return null; } } // Due to backward compatibility, even if the font is not supported by our font stack, // we need to place the empty font at the first place. The typeface with empty font // behaves different from default typeface especially in fallback font selection. fontFamily.allowUnsupportedFont(); fontFamily.freeze(); if (!fontFamily.freeze()) { return null; } FontFamily[] familyChain = { fontFamily }; typeface = createFromFamiliesWithDefault(familyChain, RESOLVE_BY_FONT_TABLE, RESOLVE_BY_FONT_TABLE); Loading Loading
core/java/android/content/res/FontResourcesParser.java +12 −10 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import com.android.internal.R; import android.annotation.NonNull; import android.annotation.Nullable; import android.util.AttributeSet; import android.util.Log; import android.util.Xml; import org.xmlpull.v1.XmlPullParser; Loading @@ -34,6 +35,7 @@ import java.util.List; * @hide */ public class FontResourcesParser { private static final String TAG = "FontResourcesParser"; private static final int NORMAL_WEIGHT = 400; private static final int ITALIC = 1; Loading Loading @@ -79,12 +81,10 @@ public class FontResourcesParser { private boolean mItalic; private int mResourceId; public FontFileResourceEntry(@NonNull String fileName, int weight, boolean italic, int resourceId) { public FontFileResourceEntry(@NonNull String fileName, int weight, boolean italic) { mFileName = fileName; mWeight = weight; mItalic = italic; mResourceId = resourceId; } public @NonNull String getFileName() { Loading @@ -98,10 +98,6 @@ public class FontResourcesParser { public boolean isItalic() { return mItalic; } public int getResourceId() { return mResourceId; } } // A class represents file based font-family element in xml file. Loading Loading @@ -140,6 +136,7 @@ public class FontResourcesParser { return readFamily(parser, resources); } else { skip(parser); Log.e(TAG, "Failed to find font-family tag"); return null; } } Loading Loading @@ -184,7 +181,10 @@ public class FontResourcesParser { if (parser.getEventType() != XmlPullParser.START_TAG) continue; String tag = parser.getName(); if (tag.equals("font")) { fonts.add(readFont(parser, resources)); final FontFileResourceEntry entry = readFont(parser, resources); if (entry != null) { fonts.add(entry); } } else { skip(parser); } Loading @@ -203,12 +203,14 @@ public class FontResourcesParser { int weight = array.getInt(R.styleable.FontFamilyFont_fontWeight, NORMAL_WEIGHT); boolean isItalic = ITALIC == array.getInt(R.styleable.FontFamilyFont_fontStyle, 0); String filename = array.getString(R.styleable.FontFamilyFont_font); int resourceId = array.getResourceId(R.styleable.FontFamilyFont_font, 0); array.recycle(); while (parser.next() != XmlPullParser.END_TAG) { skip(parser); } return new FontFileResourceEntry(filename, weight, isItalic, resourceId); if (filename == null) { return null; } return new FontFileResourceEntry(filename, weight, isItalic); } private static void skip(XmlPullParser parser) throws XmlPullParserException, IOException { Loading
core/java/android/content/res/ResourcesImpl.java +0 −1 Original line number Diff line number Diff line Loading @@ -789,7 +789,6 @@ public class ResourcesImpl { final FontResourcesParser.FamilyResourceEntry familyEntry = FontResourcesParser.parse(rp, wrapper); if (familyEntry == null) { Log.e(TAG, "Failed to find font-family tag"); return null; } return Typeface.createFromResources(familyEntry, mAssets, file); Loading
graphics/java/android/graphics/Typeface.java +4 −5 Original line number Diff line number Diff line Loading @@ -230,6 +230,7 @@ public class Typeface { FontFamily fontFamily = new FontFamily(); for (final FontFileResourceEntry fontFile : filesEntry.getEntries()) { // TODO: Add ttc and variation font support. (b/37853920) if (!fontFamily.addFontFromAssetManager(mgr, fontFile.getFileName(), 0 /* resourceCookie */, false /* isAsset */, 0 /* ttcIndex */, fontFile.getWeight(), fontFile.isItalic() ? STYLE_ITALIC : STYLE_NORMAL, Loading @@ -237,11 +238,9 @@ public class Typeface { return null; } } // Due to backward compatibility, even if the font is not supported by our font stack, // we need to place the empty font at the first place. The typeface with empty font // behaves different from default typeface especially in fallback font selection. fontFamily.allowUnsupportedFont(); fontFamily.freeze(); if (!fontFamily.freeze()) { return null; } FontFamily[] familyChain = { fontFamily }; typeface = createFromFamiliesWithDefault(familyChain, RESOLVE_BY_FONT_TABLE, RESOLVE_BY_FONT_TABLE); Loading