diff --git a/CrossPlatformModules.csproj b/CrossPlatformModules.csproj
index ab4c7e502..6e711aca5 100644
--- a/CrossPlatformModules.csproj
+++ b/CrossPlatformModules.csproj
@@ -440,7 +440,19 @@
wrap-layout.d.ts
-
+
+ css-selector.d.ts
+
+
+ font.d.ts
+
+
+ font.d.ts
+
+
+
+ font.d.ts
+
@@ -604,6 +616,7 @@
+
Designer
@@ -611,6 +624,7 @@
Designer
+
@@ -1594,7 +1608,7 @@
False
-
+
\ No newline at end of file
diff --git a/apps/tests/pages/fonts-test.ts b/apps/tests/pages/fonts-test.ts
new file mode 100644
index 000000000..94eaf662d
--- /dev/null
+++ b/apps/tests/pages/fonts-test.ts
@@ -0,0 +1,15 @@
+import stack = require("ui/layouts/stack-layout");
+import style = require("ui/styling/style");
+
+export function buttonTap(args) {
+ var stackLayout = args.object.parent;
+
+ for (var i = 0; i < stackLayout.getChildrenCount(); i++){
+ var v = stackLayout.getChildAt(i);
+ v.style._resetValue(style.fontFamilyProperty);
+ v.style._resetValue(style.fontSizeProperty);
+ v.style._resetValue(style.fontStyleProperty);
+ v.style._resetValue(style.fontWeightProperty);
+ v.style._resetValue(style.fontProperty);
+ }
+}
diff --git a/apps/tests/pages/fonts-test.xml b/apps/tests/pages/fonts-test.xml
new file mode 100644
index 000000000..d9fd65d20
--- /dev/null
+++ b/apps/tests/pages/fonts-test.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ui/enums/enums.d.ts b/ui/enums/enums.d.ts
index 0c8fd3387..f5bc4f01a 100644
--- a/ui/enums/enums.d.ts
+++ b/ui/enums/enums.d.ts
@@ -370,4 +370,36 @@
*/
export var popup: string;
}
+
+ /**
+ * Specifies different font styles.
+ */
+ export module FontStyle {
+ /**
+ * Normal font style.
+ */
+ export var normal: string;
+
+ /**
+ * Italic font style.
+ */
+ export var italic: string;
+ }
+
+
+ /**
+ * Specifies different font weights.
+ */
+ export module FontWeight {
+ /**
+ * Normal font weight.
+ */
+ export var normal: string;
+
+ /**
+ * Bold font weight.
+ */
+ export var bold: string;
+ }
+
}
\ No newline at end of file
diff --git a/ui/enums/enums.ts b/ui/enums/enums.ts
index 7c0d3d539..273ef9858 100644
--- a/ui/enums/enums.ts
+++ b/ui/enums/enums.ts
@@ -102,4 +102,14 @@ export module MenuItemPosition {
export module ImageFormat {
export var png: string = "png";
export var jpeg: string = "jpeg";
-}
\ No newline at end of file
+}
+
+export module FontStyle {
+ export var normal: string = "normal";
+ export var italic: string = "italic";
+}
+
+export module FontWeight {
+ export var normal: string = "normal";
+ export var bold: string = "bold";
+}
diff --git a/ui/styling/font-common.ts b/ui/styling/font-common.ts
new file mode 100644
index 000000000..87d5bf867
--- /dev/null
+++ b/ui/styling/font-common.ts
@@ -0,0 +1,71 @@
+import enums = require("ui/enums");
+import definitios = require("ui/styling/font");
+
+export class Font implements definitios.Font {
+ public static default = new Font(undefined, enums.FontStyle.normal, enums.FontWeight.normal);
+
+ private _fontFamily: string;
+ private _fontStyle: string;
+ private _fontWeight: string;
+
+ get fontFamily(): string {
+ return this._fontFamily;
+ }
+ set fontFamily(value: string) {
+ throw new Error("fontFamily is read-only");
+ }
+
+ get fontStyle(): string {
+ return this._fontStyle;
+ }
+ set fontStyle(value: string) {
+ throw new Error("fontStyle is read-only");
+ }
+
+ get fontWeight(): string {
+ return this._fontWeight;
+ }
+ set fontWeight(value: string) {
+ throw new Error("fontWeight is read-only");
+ }
+
+ get isBold(): boolean {
+ return this._fontWeight.toLowerCase() === enums.FontWeight.bold;;
+ }
+ set isBold(value: boolean) {
+ throw new Error("isBold is read-only");
+ }
+
+ get isItalic(): boolean {
+ return this._fontStyle.toLowerCase() === enums.FontStyle.italic;;
+ }
+ set isItalic(value: boolean) {
+ throw new Error("isItalic is read-only");
+ }
+
+ get ios(): UIFontDescriptor {
+ return undefined;
+ }
+
+ get android(): android.graphics.Typeface {
+ return undefined;
+ }
+
+ constructor(family: string, style: string, weight: string) {
+ this._fontFamily = family;
+ this._fontStyle = style;
+ this._fontWeight = weight;
+ }
+
+ public withFontFamily(family: string): Font {
+ throw new Error("This should be called on the derived class");
+ }
+
+ public withFontStyle(style: string): Font {
+ throw new Error("This should be called on the derived class");
+ }
+
+ public withFontWeight(weight: string): Font {
+ throw new Error("This should be called on the derived class");
+ }
+}
diff --git a/ui/styling/font.android.ts b/ui/styling/font.android.ts
new file mode 100644
index 000000000..4ed2a2db0
--- /dev/null
+++ b/ui/styling/font.android.ts
@@ -0,0 +1,50 @@
+import enums = require("ui/enums");
+import common = require("ui/styling/font-common");
+
+//declare var exports;
+//require("utils/module-merge").merge(common, exports);
+
+export class Font extends common.Font {
+ public static default = new Font(undefined, enums.FontStyle.normal, enums.FontWeight.normal);
+
+ private _android: android.graphics.Typeface;
+ get android(): android.graphics.Typeface {
+ if (!this._android) {
+ var style: number;
+ if (this.isBold) {
+ if (this.isItalic) {
+ style = android.graphics.Typeface.BOLD_ITALIC;
+ }
+ else {
+ style = android.graphics.Typeface.BOLD;
+ }
+ }
+ else if (this.isItalic) {
+ style = android.graphics.Typeface.ITALIC;
+ }
+ else {
+ style = android.graphics.Typeface.NORMAL;
+ }
+
+ this._android = android.graphics.Typeface.create(this.fontFamily, style);
+ }
+ return this._android;
+ }
+
+ constructor(family: string, style: string, weight: string) {
+ super(family, style, weight);
+ }
+
+ public withFontFamily(family: string): Font {
+ return new Font(family, this.fontStyle, this.fontWeight);
+ }
+
+ public withFontStyle(style: string): Font {
+ return new Font(this.fontFamily, style, this.fontWeight);
+ }
+
+ public withFontWeight(weight: string): Font {
+ return new Font(this.fontFamily, this.fontStyle, weight);
+ }
+}
+
diff --git a/ui/styling/font.d.ts b/ui/styling/font.d.ts
new file mode 100644
index 000000000..12544cbfd
--- /dev/null
+++ b/ui/styling/font.d.ts
@@ -0,0 +1,21 @@
+declare module "ui/styling/font" {
+ export class Font {
+ public static default: Font;
+
+ public fontFamily: string;
+ public fontStyle: string;
+ public fontWeight: string;
+
+ public isBold: boolean;
+ public isItalic: boolean;
+
+ public ios: UIFontDescriptor;
+ public android: android.graphics.Typeface;
+
+ constructor(family: string, style: string, weight: string);
+
+ public withFontFamily(family: string): Font;
+ public withFontStyle(style: string): Font;
+ public withFontWeight(weight: string): Font;
+ }
+}
\ No newline at end of file
diff --git a/ui/styling/font.ios.ts b/ui/styling/font.ios.ts
new file mode 100644
index 000000000..562deaf34
--- /dev/null
+++ b/ui/styling/font.ios.ts
@@ -0,0 +1,49 @@
+import enums = require("ui/enums");
+import common = require("ui/styling/font-common");
+
+//declare var exports;
+//require("utils/module-merge").merge(common, exports);
+
+export class Font extends common.Font {
+ public static default = new Font(undefined, enums.FontStyle.normal, enums.FontWeight.normal);
+
+ private _ios: UIFontDescriptor;
+ get ios(): UIFontDescriptor {
+ if (!this._ios) {
+ this._ios = UIFontDescriptor.fontDescriptorWithNameSize(this.fontFamily, 0);
+ if (this.isBold) {
+ if (this.isItalic) {
+ this._ios = this._ios.fontDescriptorWithSymbolicTraits(
+ UIFontDescriptorSymbolicTraits.UIFontDescriptorTraitItalic |
+ UIFontDescriptorSymbolicTraits.UIFontDescriptorTraitBold);
+ }
+ else {
+ this._ios = this._ios.fontDescriptorWithSymbolicTraits(
+ UIFontDescriptorSymbolicTraits.UIFontDescriptorTraitBold);
+ }
+ }
+ else if (this.isItalic) {
+ this._ios = this._ios.fontDescriptorWithSymbolicTraits(
+ UIFontDescriptorSymbolicTraits.UIFontDescriptorTraitItalic);
+ }
+ }
+ return this._ios;
+ }
+
+ constructor(family: string, style: string, weight: string) {
+ super(family, style, weight);
+ }
+
+ public withFontFamily(family: string): Font {
+ return new Font(family, this.fontStyle, this.fontWeight);
+ }
+
+ public withFontStyle(style: string): Font {
+ return new Font(this.fontFamily, style, this.fontWeight);
+ }
+
+ public withFontWeight(weight: string): Font {
+ return new Font(this.fontFamily, this.fontStyle, weight);
+ }
+}
+
diff --git a/ui/styling/style.ts b/ui/styling/style.ts
index d705cac25..fcb8c3504 100644
--- a/ui/styling/style.ts
+++ b/ui/styling/style.ts
@@ -11,6 +11,7 @@ import converters = require("ui/styling/converters");
import enums = require("ui/enums");
import imageSource = require("image-source");
import utils = require("utils/utils");
+import font = require("ui/styling/font");
// key is the property id and value is Dictionary;
var _registeredHandlers = Array