Stop supporting broken font fallback

The supporting broken font is over engineering and it works the same as
default font fallback in most cases.
Removing fallback logic and return default fallback.

Test: bit CtsTextTestCases:*
Test: bit CtsGraphicsTestCases:*
Test: ./gradlew appcompat-v7:connectedDebugAndroidTest
Test: ./gradlew support-compat:connectedDebugAndroidTest
Bug: 65024629
Change-Id: Ib3fc0d638c6aee904cdf865082f8d5ae7d31ba48
This commit is contained in:
Seigo Nonaka
2018-01-30 19:09:28 -08:00
parent fad69a64d9
commit fcd2af9ca8
3 changed files with 11 additions and 47 deletions

View File

@@ -160,25 +160,6 @@ public class FontFamily {
isItalic);
}
/**
* Allow creating unsupported FontFamily.
*
* For compatibility reasons, we still need to create a FontFamily object even if Minikin failed
* to find any usable 'cmap' table for some reasons, e.g. broken 'cmap' table, no 'cmap' table
* encoded with Unicode code points, etc. Without calling this method, the freeze() method will
* return null if Minikin fails to find any usable 'cmap' table. By calling this method, the
* freeze() won't fail and will create an empty FontFamily. This empty FontFamily is placed at
* the top of the fallback chain but is never used. if we don't create this empty FontFamily
* and put it at top, bad things (performance regressions, unexpected glyph selection) will
* happen.
*/
public void allowUnsupportedFont() {
if (mBuilderPtr == 0) {
throw new IllegalStateException("Unable to allow unsupported font.");
}
nAllowUnsupportedFont(mBuilderPtr);
}
// TODO: Remove once internal user stop using private API.
private static boolean nAddFont(long builderPtr, ByteBuffer font, int ttcIndex) {
return nAddFont(builderPtr, font, ttcIndex, -1, -1);
@@ -189,9 +170,6 @@ public class FontFamily {
@CriticalNative
private static native long nCreateFamily(long mBuilderPtr);
@CriticalNative
private static native void nAllowUnsupportedFont(long builderPtr);
@CriticalNative
private static native void nAbort(long mBuilderPtr);

View File

@@ -818,12 +818,9 @@ public class Typeface {
if (fontFamily.addFontFromAssetManager(mgr, path, 0, true /* isAsset */,
0 /* ttc index */, RESOLVE_BY_FONT_TABLE, RESOLVE_BY_FONT_TABLE,
null /* axes */)) {
// 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 Typeface.DEFAULT;
}
final FontFamily[] families = { fontFamily };
typeface = createFromFamiliesWithDefault(families, DEFAULT_FAMILY,
RESOLVE_BY_FONT_TABLE, RESOLVE_BY_FONT_TABLE);
@@ -870,12 +867,9 @@ public class Typeface {
final FontFamily fontFamily = new FontFamily();
if (fontFamily.addFont(path, 0 /* ttcIndex */, null /* axes */,
RESOLVE_BY_FONT_TABLE, RESOLVE_BY_FONT_TABLE)) {
// 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 Typeface.DEFAULT;
}
FontFamily[] families = { fontFamily };
return createFromFamiliesWithDefault(families, DEFAULT_FAMILY,
RESOLVE_BY_FONT_TABLE, RESOLVE_BY_FONT_TABLE);