Commit 20a49edd authored by Adam Barth's avatar Adam Barth

Add support for letterSpacing to TextStyle

parent 5ad32f29
...@@ -30,6 +30,7 @@ class TextStyle { ...@@ -30,6 +30,7 @@ class TextStyle {
this.fontSize, this.fontSize,
this.fontWeight, this.fontWeight,
this.fontStyle, this.fontStyle,
this.letterSpacing,
this.textAlign, this.textAlign,
this.textBaseline, this.textBaseline,
this.height, this.height,
...@@ -41,48 +42,52 @@ class TextStyle { ...@@ -41,48 +42,52 @@ class TextStyle {
/// Whether null values are replaced with their value in an ancestor text style. /// Whether null values are replaced with their value in an ancestor text style.
final bool inherit; final bool inherit;
/// The color to use when painting the text /// The color to use when painting the text.
final Color color; final Color color;
/// The name of the font to use when painting the text /// The name of the font to use when painting the text.
final String fontFamily; final String fontFamily;
/// The size of gyphs (in logical pixels) to use when painting the text /// The size of gyphs (in logical pixels) to use when painting the text.
final double fontSize; final double fontSize;
/// The font weight to use when painting the text /// The font weight to use when painting the text.
final FontWeight fontWeight; final FontWeight fontWeight;
/// The font style to use when painting the text /// The font style to use when painting the text.
final FontStyle fontStyle; final FontStyle fontStyle;
/// The amount of space to add between each letter.
final double letterSpacing;
/// How the text should be aligned (applies only to the outermost /// How the text should be aligned (applies only to the outermost
/// StyledTextSpan, which establishes the container for the text) /// StyledTextSpan, which establishes the container for the text).
final TextAlign textAlign; final TextAlign textAlign;
/// The baseline to use for aligning the text /// The baseline to use for aligning the text.
final TextBaseline textBaseline; final TextBaseline textBaseline;
/// The distance between the text baselines, as a multiple of the font size /// The distance between the text baselines, as a multiple of the font size.
final double height; final double height;
/// A list of decorations to paint near the text /// A list of decorations to paint near the text.
final List<TextDecoration> decoration; // TODO(ianh): Switch this to a Set<> once Dart supports constant Sets final List<TextDecoration> decoration; // TODO(ianh): Switch this to a Set<> once Dart supports constant Sets
/// The color in which to paint the text decorations /// The color in which to paint the text decorations.
final Color decorationColor; final Color decorationColor;
/// The style in which to paint the text decorations /// The style in which to paint the text decorations.
final TextDecorationStyle decorationStyle; final TextDecorationStyle decorationStyle;
/// Returns a new text style that matches this text style but with the given /// Returns a new text style that matches this text style but with the given
/// values replaced /// values replaced.
TextStyle copyWith({ TextStyle copyWith({
Color color, Color color,
String fontFamily, String fontFamily,
double fontSize, double fontSize,
FontWeight fontWeight, FontWeight fontWeight,
FontStyle fontStyle, FontStyle fontStyle,
double letterSpacing,
TextAlign textAlign, TextAlign textAlign,
TextBaseline textBaseline, TextBaseline textBaseline,
double height, double height,
...@@ -97,6 +102,7 @@ class TextStyle { ...@@ -97,6 +102,7 @@ class TextStyle {
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, fontStyle: fontStyle != null ? fontStyle : this.fontStyle,
letterSpacing: letterSpacing != null ? letterSpacing : this.letterSpacing,
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,
...@@ -119,6 +125,7 @@ class TextStyle { ...@@ -119,6 +125,7 @@ class TextStyle {
fontSize: other.fontSize, fontSize: other.fontSize,
fontWeight: other.fontWeight, fontWeight: other.fontWeight,
fontStyle: other.fontStyle, fontStyle: other.fontStyle,
letterSpacing: other.letterSpacing,
textAlign: other.textAlign, textAlign: other.textAlign,
textBaseline: other.textBaseline, textBaseline: other.textBaseline,
height: other.height, height: other.height,
...@@ -137,7 +144,8 @@ class TextStyle { ...@@ -137,7 +144,8 @@ class TextStyle {
fontWeight: fontWeight, fontWeight: fontWeight,
fontStyle: fontStyle, fontStyle: fontStyle,
fontFamily: fontFamily, fontFamily: fontFamily,
fontSize: fontSize fontSize: fontSize,
letterSpacing: letterSpacing
); );
} }
...@@ -161,6 +169,7 @@ class TextStyle { ...@@ -161,6 +169,7 @@ class TextStyle {
fontSize == typedOther.fontSize && fontSize == typedOther.fontSize &&
fontWeight == typedOther.fontWeight && fontWeight == typedOther.fontWeight &&
fontStyle == typedOther.fontStyle && fontStyle == typedOther.fontStyle &&
letterSpacing == typedOther.letterSpacing &&
textAlign == typedOther.textAlign && textAlign == typedOther.textAlign &&
textBaseline == typedOther.textBaseline && textBaseline == typedOther.textBaseline &&
decoration == typedOther.decoration && decoration == typedOther.decoration &&
...@@ -177,6 +186,7 @@ class TextStyle { ...@@ -177,6 +186,7 @@ class TextStyle {
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 + fontStyle.hashCode;
value = 37 * value + letterSpacing.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;
...@@ -235,6 +245,8 @@ class TextStyle { ...@@ -235,6 +245,8 @@ class TextStyle {
break; break;
} }
} }
if (letterSpacing != null)
result.add('${prefix}letterSpacing: $letterSpacing');
if (textAlign != null) { if (textAlign != null) {
switch (textAlign) { switch (textAlign) {
case TextAlign.left: case TextAlign.left:
......
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