diff --git a/examples/rendering/baseline.dart b/examples/rendering/baseline.dart index b0b4718490..2e5163e1ac 100644 --- a/examples/rendering/baseline.dart +++ b/examples/rendering/baseline.dart @@ -17,17 +17,30 @@ class _BaselinePainter extends CustomPainter { double baseline = paragraph.getDistanceToBaseline(TextBaseline.alphabetic); double w = paragraph.getMaxIntrinsicWidth(new BoxConstraints.loose(size)); double h = paragraph.getMaxIntrinsicHeight(new BoxConstraints.loose(size)); - Path path = new Path(); + + Path path; + Paint paint; + + // top and bottom + path = new Path(); path.moveTo(0.0, 0.0); path.lineTo(w, 0.0); - path.moveTo(0.0, baseline); - path.lineTo(w, baseline); path.moveTo(0.0, h); path.lineTo(w, h); - Paint paint = new Paint() + paint = new Paint() ..color = const Color(0xFFFF9000) ..style = ui.PaintingStyle.stroke - ..strokeWidth = 3.0; + ..strokeWidth = 1.5; + canvas.drawPath(path, paint); + + // baseline + path = new Path(); + path.moveTo(0.0, baseline); + path.lineTo(w, baseline); + paint = new Paint() + ..color = const Color(0xFF00FF90) + ..style = ui.PaintingStyle.stroke + ..strokeWidth = 1.5; canvas.drawPath(path, paint); } @@ -81,8 +94,8 @@ void main() { new RenderConstrainedBox( additionalConstraints: new BoxConstraints.tightFor(height: 50.0) ), - getBox(1.0), getBox(null), + getBox(1.2), ], direction: FlexDirection.vertical, alignItems: FlexAlignItems.stretch diff --git a/packages/flutter/lib/src/painting/text_style.dart b/packages/flutter/lib/src/painting/text_style.dart index b1b8521e1a..17a9a69e0e 100644 --- a/packages/flutter/lib/src/painting/text_style.dart +++ b/packages/flutter/lib/src/painting/text_style.dart @@ -16,6 +16,7 @@ class TextStyle { this.fontWeight, this.fontStyle, this.letterSpacing, + this.wordSpacing, this.textAlign, this.textBaseline, this.height, @@ -45,6 +46,9 @@ class TextStyle { /// The amount of space to add between each letter. final double letterSpacing; + /// The amount of space to add at each sequence of white-space (i.e. between each word). + final double wordSpacing; + /// How the text should be aligned (applies only to the outermost /// StyledTextSpan, which establishes the container for the text). final TextAlign textAlign; @@ -73,6 +77,7 @@ class TextStyle { FontWeight fontWeight, FontStyle fontStyle, double letterSpacing, + double wordSpacing, TextAlign textAlign, TextBaseline textBaseline, double height, @@ -88,6 +93,7 @@ class TextStyle { fontWeight: fontWeight != null ? fontWeight : this.fontWeight, fontStyle: fontStyle != null ? fontStyle : this.fontStyle, letterSpacing: letterSpacing != null ? letterSpacing : this.letterSpacing, + wordSpacing: wordSpacing != null ? wordSpacing : this.wordSpacing, textAlign: textAlign != null ? textAlign : this.textAlign, textBaseline: textBaseline != null ? textBaseline : this.textBaseline, height: height != null ? height : this.height, @@ -111,6 +117,7 @@ class TextStyle { fontWeight: other.fontWeight, fontStyle: other.fontStyle, letterSpacing: other.letterSpacing, + wordSpacing: other.wordSpacing, textAlign: other.textAlign, textBaseline: other.textBaseline, height: other.height, @@ -130,7 +137,9 @@ class TextStyle { fontStyle: fontStyle, fontFamily: fontFamily, fontSize: fontSize, - letterSpacing: letterSpacing + letterSpacing: letterSpacing, + wordSpacing: wordSpacing, + lineHeight: height ); } @@ -155,8 +164,10 @@ class TextStyle { fontWeight == typedOther.fontWeight && fontStyle == typedOther.fontStyle && letterSpacing == typedOther.letterSpacing && + wordSpacing == typedOther.wordSpacing && textAlign == typedOther.textAlign && textBaseline == typedOther.textBaseline && + height == typedOther.height && decoration == typedOther.decoration && decorationColor == typedOther.decorationColor && decorationStyle == typedOther.decorationStyle; @@ -164,15 +175,17 @@ class TextStyle { int get hashCode { return hashValues( - super.hashCode, + inherit, color, fontFamily, fontSize, fontWeight, fontStyle, letterSpacing, + wordSpacing, textAlign, textBaseline, + height, decoration, decorationColor, decorationStyle @@ -181,7 +194,7 @@ class TextStyle { String toString([String prefix = '']) { List result = []; - result.add('${prefix}inhert: $inherit'); + result.add('${prefix}inherit: $inherit'); if (color != null) result.add('${prefix}color: $color'); if (fontFamily != null) @@ -230,7 +243,9 @@ class TextStyle { } } if (letterSpacing != null) - result.add('${prefix}letterSpacing: $letterSpacing'); + result.add('${prefix}letterSpacing: ${letterSpacing}x'); + if (wordSpacing != null) + result.add('${prefix}wordSpacing: ${wordSpacing}x'); if (textAlign != null) { switch (textAlign) { case TextAlign.left: @@ -254,6 +269,8 @@ class TextStyle { break; } } + if (height != null) + result.add('${prefix}height: ${height}x'); if (decoration != null || decorationColor != null || decorationStyle != null) { String decorationDescription = '${prefix}decoration: '; bool haveDecorationDescription = false;