From 1db0d3cd048ecf6cc2c2af9e05c158b0ccdc74b2 Mon Sep 17 00:00:00 2001 From: Jerome Gaillard Date: Fri, 17 Feb 2017 15:46:05 +0000 Subject: [PATCH] Update FontFamily_Delegate following Change I1d6e1c4c Test: layoutlib tests Change-Id: I3fda9b0eaf36d74c8a64f2a5c7aeb063b4df8d1a --- .../src/android/graphics/FontFamily_Delegate.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/layoutlib/bridge/src/android/graphics/FontFamily_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/FontFamily_Delegate.java index fb24c01086d74..ff5a5e9541df2 100644 --- a/tools/layoutlib/bridge/src/android/graphics/FontFamily_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/FontFamily_Delegate.java @@ -314,7 +314,7 @@ public class FontFamily_Delegate { @LayoutlibDelegate /*package*/ static boolean nAddFontFromAssetManager(long builderPtr, AssetManager mgr, String path, - int cookie, boolean isAsset) { + int cookie, boolean isAsset, int weight, boolean isItalic) { FontFamily_Delegate ffd = sManager.getDelegate(builderPtr); if (ffd == null) { return false; @@ -355,8 +355,12 @@ public class FontFamily_Delegate { Font font = Font.createFont(Font.TRUETYPE_FONT, fontStream); fontInfo = new FontInfo(); fontInfo.mFont = font; - fontInfo.mWeight = font.isBold() ? BOLD_FONT_WEIGHT : DEFAULT_FONT_WEIGHT; - fontInfo.mIsItalic = font.isItalic(); + if (weight == 0) { + fontInfo.mWeight = font.isBold() ? BOLD_FONT_WEIGHT : DEFAULT_FONT_WEIGHT; + } else { + fontInfo.mWeight = weight; + } + fontInfo.mIsItalic = weight == 0 ? font.isItalic() : isItalic; ffd.addFont(fontInfo); return true; } catch (IOException e) {