mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
Merge pull request #3682 from NativeScript/android-button-bold
Android buttons didn't apply bold or italic
This commit is contained in:
@ -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 {
|
||||||
|
Reference in New Issue
Block a user