From 669792b303b99a003bbcbf8d962f5be1debf9b63 Mon Sep 17 00:00:00 2001 From: Deepanshu Gupta Date: Wed, 19 Feb 2014 10:53:27 -0800 Subject: Fix sans-serif-thin and sans-serif-light fonts in layoutlib. [DO NOT MERGE] For these font families, text was always rendered as italic. This changeset fixes the issue. Bug: http://b.android.com/57221 Change-Id: Ic8a299bd1e555f5bb914cd3d2fe72917ec7f471a (cherry-picked from 5be65fda15c6f66067da3cc623811427e9d541e4) --- .../bridge/src/com/android/layoutlib/bridge/impl/FontLoader.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/FontLoader.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/FontLoader.java index 081ce67..2244aa2 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/FontLoader.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/FontLoader.java @@ -55,7 +55,9 @@ public final class FontLoader { private static final String FONT_SUFFIX_NONE = ".ttf"; private static final String FONT_SUFFIX_REGULAR = "-Regular.ttf"; private static final String FONT_SUFFIX_BOLD = "-Bold.ttf"; - private static final String FONT_SUFFIX_ITALIC = "-Italic.ttf"; + // FONT_SUFFIX_ITALIC will always match FONT_SUFFIX_BOLDITALIC and hence it must be checked + // separately. + private static final String FONT_SUFFIX_ITALIC = "Italic.ttf"; private static final String FONT_SUFFIX_BOLDITALIC = "-BoldItalic.ttf"; // This must match the values of Typeface styles so that we can use them for indices in this @@ -267,10 +269,10 @@ public final class FontLoader { mFontInfo.font[Typeface.NORMAL] = font; } else if (fileName.endsWith(FONT_SUFFIX_BOLD)) { mFontInfo.font[Typeface.BOLD] = font; - } else if (fileName.endsWith(FONT_SUFFIX_ITALIC)) { - mFontInfo.font[Typeface.ITALIC] = font; } else if (fileName.endsWith(FONT_SUFFIX_BOLDITALIC)) { mFontInfo.font[Typeface.BOLD_ITALIC] = font; + } else if (fileName.endsWith(FONT_SUFFIX_ITALIC)) { + mFontInfo.font[Typeface.ITALIC] = font; } else if (fileName.endsWith(FONT_SUFFIX_NONE)) { mFontInfo.font[Typeface.NORMAL] = font; } -- cgit v1.1