Merge pull request #3682 from NativeScript/android-button-bold

Android buttons didn't apply bold or italic
This commit is contained in:
Panayot Cankov
2017-02-22 13:34:14 +02:00
committed by GitHub

View File

@ -99,11 +99,7 @@ function createTypeface(font: Font, fontStyle: number): android.graphics.Typefac
//http://stackoverflow.com/questions/19691530/valid-values-for-androidfontfamily-and-what-they-map-to //http://stackoverflow.com/questions/19691530/valid-values-for-androidfontfamily-and-what-they-map-to
const fonts = parseFontFamily(font.fontFamily); const fonts = parseFontFamily(font.fontFamily);
let result = null; let result = null;
if (fonts.length === 0) { for (let i = 0; i < fonts.length && !result; i++) {
return null;
}
for (let i = 0; i < fonts.length; i++) {
switch (fonts[i].toLowerCase()) { switch (fonts[i].toLowerCase()) {
case genericFontFamilies.serif: case genericFontFamilies.serif:
result = android.graphics.Typeface.create("serif" + getFontWeightSuffix(font.fontWeight), fontStyle); result = android.graphics.Typeface.create("serif" + getFontWeightSuffix(font.fontWeight), fontStyle);
@ -120,15 +116,18 @@ function createTypeface(font: Font, fontStyle: number): android.graphics.Typefac
default: default:
result = loadFontFromFile(fonts[i]); result = loadFontFromFile(fonts[i]);
if (fontStyle) {
result = android.graphics.Typeface.create(result, fontStyle);
}
break; break;
} }
if (result) {
return result;
}
} }
return null; if (fontStyle && !result) {
result = android.graphics.Typeface.create(result, fontStyle);
}
return result;
} }
function getFontWeightSuffix(fontWeight: FontWeight): string { function getFontWeightSuffix(fontWeight: FontWeight): string {