replaced the use of fontDescriptorWithSymbolicTraits due to problems in iOS8+ and some fonts

This commit is contained in:
Peter Staev
2015-08-28 10:32:04 +03:00
committed by Nedyalko Nikolov
parent 64d4ebb074
commit d0f4f36018
7 changed files with 73 additions and 5 deletions

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

@@ -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
}