Commit ad4c4272 authored by Adam Barth's avatar Adam Barth

Add support for FontStyle.italics

parent 4270d897
...@@ -8,6 +8,8 @@ enum FontWeight { w100, w200, w300, w400, w500, w600, w700, w800, w900 } ...@@ -8,6 +8,8 @@ enum FontWeight { w100, w200, w300, w400, w500, w600, w700, w800, w900 }
const normal = FontWeight.w400; const normal = FontWeight.w400;
const bold = FontWeight.w700; const bold = FontWeight.w700;
enum FontStyle { normal, italic, oblique }
enum TextAlign { left, right, center } enum TextAlign { left, right, center }
enum TextBaseline { alphabetic, ideographic } enum TextBaseline { alphabetic, ideographic }
...@@ -25,6 +27,7 @@ class TextStyle { ...@@ -25,6 +27,7 @@ class TextStyle {
this.fontFamily, this.fontFamily,
this.fontSize, this.fontSize,
this.fontWeight, this.fontWeight,
this.fontStyle,
this.textAlign, this.textAlign,
this.textBaseline, this.textBaseline,
this.height, this.height,
...@@ -37,6 +40,7 @@ class TextStyle { ...@@ -37,6 +40,7 @@ class TextStyle {
final String fontFamily; final String fontFamily;
final double fontSize; // in pixels final double fontSize; // in pixels
final FontWeight fontWeight; final FontWeight fontWeight;
final FontStyle fontStyle;
final TextAlign textAlign; final TextAlign textAlign;
final TextBaseline textBaseline; final TextBaseline textBaseline;
final double height; // multiple of fontSize final double height; // multiple of fontSize
...@@ -49,6 +53,7 @@ class TextStyle { ...@@ -49,6 +53,7 @@ class TextStyle {
String fontFamily, String fontFamily,
double fontSize, double fontSize,
FontWeight fontWeight, FontWeight fontWeight,
FontStyle fontStyle,
TextAlign textAlign, TextAlign textAlign,
TextBaseline textBaseline, TextBaseline textBaseline,
double height, double height,
...@@ -61,6 +66,7 @@ class TextStyle { ...@@ -61,6 +66,7 @@ class TextStyle {
fontFamily: fontFamily != null ? fontFamily : this.fontFamily, fontFamily: fontFamily != null ? fontFamily : this.fontFamily,
fontSize: fontSize != null ? fontSize : this.fontSize, fontSize: fontSize != null ? fontSize : this.fontSize,
fontWeight: fontWeight != null ? fontWeight : this.fontWeight, fontWeight: fontWeight != null ? fontWeight : this.fontWeight,
fontStyle: fontStyle != null ? fontStyle : this.fontStyle,
textAlign: textAlign != null ? textAlign : this.textAlign, textAlign: textAlign != null ? textAlign : this.textAlign,
textBaseline: textBaseline != null ? textBaseline : this.textBaseline, textBaseline: textBaseline != null ? textBaseline : this.textBaseline,
height: height != null ? height : this.height, height: height != null ? height : this.height,
...@@ -76,6 +82,7 @@ class TextStyle { ...@@ -76,6 +82,7 @@ class TextStyle {
fontFamily: other.fontFamily, fontFamily: other.fontFamily,
fontSize: other.fontSize, fontSize: other.fontSize,
fontWeight: other.fontWeight, fontWeight: other.fontWeight,
fontStyle: other.fontStyle,
textAlign: other.textAlign, textAlign: other.textAlign,
textBaseline: other.textBaseline, textBaseline: other.textBaseline,
height: other.height, height: other.height,
...@@ -140,6 +147,13 @@ class TextStyle { ...@@ -140,6 +147,13 @@ class TextStyle {
FontWeight.w900: '900' FontWeight.w900: '900'
}[fontWeight]; }[fontWeight];
} }
if (fontStyle != null) {
cssStyle['font-style'] = const {
FontStyle.normal: 'normal',
FontStyle.italic: 'italic',
FontStyle.oblique: 'oblique',
}[fontStyle];
}
if (decoration != null) { if (decoration != null) {
cssStyle['text-decoration'] = _decorationToCSSString(decoration); cssStyle['text-decoration'] = _decorationToCSSString(decoration);
if (decorationColor != null) if (decorationColor != null)
...@@ -170,6 +184,7 @@ class TextStyle { ...@@ -170,6 +184,7 @@ class TextStyle {
fontFamily == other.fontFamily && fontFamily == other.fontFamily &&
fontSize == other.fontSize && fontSize == other.fontSize &&
fontWeight == other.fontWeight && fontWeight == other.fontWeight &&
fontStyle == other.fontStyle &&
textAlign == other.textAlign && textAlign == other.textAlign &&
textBaseline == other.textBaseline && textBaseline == other.textBaseline &&
decoration == other.decoration && decoration == other.decoration &&
...@@ -184,6 +199,7 @@ class TextStyle { ...@@ -184,6 +199,7 @@ class TextStyle {
value = 37 * value + fontFamily.hashCode; value = 37 * value + fontFamily.hashCode;
value = 37 * value + fontSize.hashCode; value = 37 * value + fontSize.hashCode;
value = 37 * value + fontWeight.hashCode; value = 37 * value + fontWeight.hashCode;
value = 37 * value + fontStyle.hashCode;
value = 37 * value + textAlign.hashCode; value = 37 * value + textAlign.hashCode;
value = 37 * value + textBaseline.hashCode; value = 37 * value + textBaseline.hashCode;
value = 37 * value + decoration.hashCode; value = 37 * value + decoration.hashCode;
...@@ -203,6 +219,8 @@ class TextStyle { ...@@ -203,6 +219,8 @@ class TextStyle {
result.add('${prefix}fontSize: $fontSize'); result.add('${prefix}fontSize: $fontSize');
if (fontWeight != null) if (fontWeight != null)
result.add('${prefix}fontWeight: $fontWeight'); result.add('${prefix}fontWeight: $fontWeight');
if (fontStyle != null)
result.add('${prefix}fontStyle: $fontStyle');
if (textAlign != null) if (textAlign != null)
result.add('${prefix}textAlign: $textAlign'); result.add('${prefix}textAlign: $textAlign');
if (textBaseline != null) if (textBaseline != null)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment