diff options
| author | Seigo Nonaka <nona@google.com> | 2017-06-29 17:50:33 -0700 |
|---|---|---|
| committer | Seigo Nonaka <nona@google.com> | 2017-07-13 10:47:48 -0700 |
| commit | 0d253e46aa0b4cb2ea56e220812aeab92de64ae1 (patch) | |
| tree | 790b3171f79c25b3be1878d0e2070be84a84fb4e /core/java/android/text/FontConfig.java | |
| parent | ab78a4707b276a58c758e5a7122a21d75403497b (diff) | |
Implement family fallback.
Introduce new attribute "fallbackFor" to font element.
By specifying name of the family to this attribute, that font is used
when the developer specifies the font family.
For example, if fonts.xml has the following family entry,
<family lang="ja">
<font fallbackFor="serif">NotoSerifJP-Regular.ttf</font>
<font>NotoSansJP-Regular.ttf</font>
</family>
the Japanese text is rendered by NotoSansJP-Regular.ttf by default.
Then, if developer specifies fontFamily="serif" in TextView, the Japanese
text is rendered by NotoSerifJP-Regular.ttf.
Bug: 37328609
Bug: 31491668
Test: bit FrameworksCoreTests:android.graphics.TypefaceSystemFallbackTest
Change-Id: I2744db7384c8056795e841c88b387545434131f4
Diffstat (limited to 'core/java/android/text/FontConfig.java')
| -rw-r--r-- | core/java/android/text/FontConfig.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/core/java/android/text/FontConfig.java b/core/java/android/text/FontConfig.java index ed583907123b..029f66e1d670 100644 --- a/core/java/android/text/FontConfig.java +++ b/core/java/android/text/FontConfig.java @@ -64,17 +64,19 @@ public final class FontConfig { private final int mWeight; private final boolean mIsItalic; private Uri mUri; + private final String mFallbackFor; /** * @hide */ public Font(@NonNull String fontName, int ttcIndex, @NonNull FontVariationAxis[] axes, - int weight, boolean isItalic) { + int weight, boolean isItalic, String fallbackFor) { mFontName = fontName; mTtcIndex = ttcIndex; mAxes = axes; mWeight = weight; mIsItalic = isItalic; + mFallbackFor = fallbackFor; } /** @@ -125,6 +127,10 @@ public final class FontConfig { public void setUri(@NonNull Uri uri) { mUri = uri; } + + public String getFallbackFor() { + return mFallbackFor; + } } /** |
