Skip to content

Commit

Permalink
Add support for FontStyle.italics
Browse files Browse the repository at this point in the history
  • Loading branch information
abarth committed Aug 3, 2015
1 parent e7d1dc7 commit c8f99a6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions sky/packages/sky/lib/painting/text_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ enum FontWeight { w100, w200, w300, w400, w500, w600, w700, w800, w900 }
const normal = FontWeight.w400;
const bold = FontWeight.w700;

enum FontStyle { normal, italic, oblique }

enum TextAlign { left, right, center }

enum TextBaseline { alphabetic, ideographic }
Expand All @@ -25,6 +27,7 @@ class TextStyle {
this.fontFamily,
this.fontSize,
this.fontWeight,
this.fontStyle,
this.textAlign,
this.textBaseline,
this.height,
Expand All @@ -37,6 +40,7 @@ class TextStyle {
final String fontFamily;
final double fontSize; // in pixels
final FontWeight fontWeight;
final FontStyle fontStyle;
final TextAlign textAlign;
final TextBaseline textBaseline;
final double height; // multiple of fontSize
Expand All @@ -49,6 +53,7 @@ class TextStyle {
String fontFamily,
double fontSize,
FontWeight fontWeight,
FontStyle fontStyle,
TextAlign textAlign,
TextBaseline textBaseline,
double height,
Expand All @@ -61,6 +66,7 @@ class TextStyle {
fontFamily: fontFamily != null ? fontFamily : this.fontFamily,
fontSize: fontSize != null ? fontSize : this.fontSize,
fontWeight: fontWeight != null ? fontWeight : this.fontWeight,
fontStyle: fontStyle != null ? fontStyle : this.fontStyle,
textAlign: textAlign != null ? textAlign : this.textAlign,
textBaseline: textBaseline != null ? textBaseline : this.textBaseline,
height: height != null ? height : this.height,
Expand All @@ -76,6 +82,7 @@ class TextStyle {
fontFamily: other.fontFamily,
fontSize: other.fontSize,
fontWeight: other.fontWeight,
fontStyle: other.fontStyle,
textAlign: other.textAlign,
textBaseline: other.textBaseline,
height: other.height,
Expand Down Expand Up @@ -140,6 +147,13 @@ class TextStyle {
FontWeight.w900: '900'
}[fontWeight];
}
if (fontStyle != null) {
cssStyle['font-style'] = const {
FontStyle.normal: 'normal',
FontStyle.italic: 'italic',
FontStyle.oblique: 'oblique',
}[fontStyle];
}
if (decoration != null) {
cssStyle['text-decoration'] = _decorationToCSSString(decoration);
if (decorationColor != null)
Expand Down Expand Up @@ -170,6 +184,7 @@ class TextStyle {
fontFamily == other.fontFamily &&
fontSize == other.fontSize &&
fontWeight == other.fontWeight &&
fontStyle == other.fontStyle &&
textAlign == other.textAlign &&
textBaseline == other.textBaseline &&
decoration == other.decoration &&
Expand All @@ -184,6 +199,7 @@ class TextStyle {
value = 37 * value + fontFamily.hashCode;
value = 37 * value + fontSize.hashCode;
value = 37 * value + fontWeight.hashCode;
value = 37 * value + fontStyle.hashCode;
value = 37 * value + textAlign.hashCode;
value = 37 * value + textBaseline.hashCode;
value = 37 * value + decoration.hashCode;
Expand All @@ -203,6 +219,8 @@ class TextStyle {
result.add('${prefix}fontSize: $fontSize');
if (fontWeight != null)
result.add('${prefix}fontWeight: $fontWeight');
if (fontStyle != null)
result.add('${prefix}fontStyle: $fontStyle');
if (textAlign != null)
result.add('${prefix}textAlign: $textAlign');
if (textBaseline != null)
Expand Down

0 comments on commit c8f99a6

Please sign in to comment.