mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
replaced the use of fontDescriptorWithSymbolicTraits due to problems in iOS8+ and some fonts
This commit is contained in:
committed by
Nedyalko Nikolov
parent
64d4ebb074
commit
d0f4f36018
BIN
apps/tests/fonts/Roboto-Bold.ttf
Normal file
BIN
apps/tests/fonts/Roboto-Bold.ttf
Normal file
Binary file not shown.
BIN
apps/tests/fonts/Roboto-BoldItalic.ttf
Normal file
BIN
apps/tests/fonts/Roboto-BoldItalic.ttf
Normal file
Binary file not shown.
BIN
apps/tests/fonts/Roboto-Italic.ttf
Normal file
BIN
apps/tests/fonts/Roboto-Italic.ttf
Normal file
Binary file not shown.
BIN
apps/tests/fonts/Roboto-Regular.ttf
Normal file
BIN
apps/tests/fonts/Roboto-Regular.ttf
Normal file
Binary file not shown.
@@ -5,6 +5,8 @@ import stackModule = require("ui/layouts/stack-layout");
|
||||
import page = require("ui/page");
|
||||
import color = require("color");
|
||||
import observable = require("data/observable");
|
||||
import enums = require("ui/enums");
|
||||
import fontModule = require("ui/styling/font");
|
||||
|
||||
var testBtn: buttonModule.Button;
|
||||
var testPage: page.Page;
|
||||
@@ -317,3 +319,47 @@ function test_font_shorthand_property(short: string, family: string, size: numbe
|
||||
TKUnit.assertEqual(testView.style.fontWeight, weight, "style.fontWeight");
|
||||
TKUnit.assertEqual(testView.style.fontSize, size, "style.fontSize");
|
||||
}
|
||||
|
||||
export function test_setting_font_properties_sets_native_font() {
|
||||
|
||||
if (fontModule.ios) {
|
||||
var basePath = "fonts";
|
||||
fontModule.ios.registerFont(basePath + "/Roboto-Regular.ttf");
|
||||
fontModule.ios.registerFont(basePath + "/Roboto-Bold.ttf");
|
||||
fontModule.ios.registerFont(basePath + "/Roboto-BoldItalic.ttf");
|
||||
fontModule.ios.registerFont(basePath + "/Roboto-Italic.ttf");
|
||||
}
|
||||
|
||||
test_native_font(enums.FontStyle.normal, enums.FontWeight.normal);
|
||||
test_native_font(enums.FontStyle.italic, enums.FontWeight.normal);
|
||||
test_native_font(enums.FontStyle.normal, enums.FontWeight.bold);
|
||||
test_native_font(enums.FontStyle.italic, enums.FontWeight.bold);
|
||||
}
|
||||
|
||||
function test_native_font(style: string, weight: string) {
|
||||
var testView = new buttonModule.Button();
|
||||
var fontName = "Roboto";
|
||||
var fontNameSuffix = "";
|
||||
|
||||
testView.style.fontFamily = fontName;
|
||||
testView.style.fontWeight = weight;
|
||||
testView.style.fontStyle = style;
|
||||
|
||||
if (style === enums.FontStyle.normal && weight === enums.FontWeight.normal)
|
||||
{
|
||||
fontNameSuffix += "Regular";
|
||||
}
|
||||
if (weight === enums.FontWeight.bold)
|
||||
{
|
||||
fontNameSuffix += "Bold";
|
||||
}
|
||||
if (style === enums.FontStyle.italic)
|
||||
{
|
||||
fontNameSuffix += "Italic";
|
||||
}
|
||||
|
||||
if (testView.ios) {
|
||||
TKUnit.assertEqual((<UIButton>testView.ios).titleLabel.font.fontName.toLowerCase(), (fontName + "-" + fontNameSuffix).toLowerCase(), "native font " + weight + " " + style);
|
||||
}
|
||||
//TODO: If needed add tests for other platforms
|
||||
}
|
||||
Reference in New Issue
Block a user