Commit c8ac09a5 authored by Ian Hickson's avatar Ian Hickson

Merge pull request #1042 from Hixie/wordSpacing

Hook up wordSpacing and inline height.
parents dcd34f47 4588524c
...@@ -17,17 +17,30 @@ class _BaselinePainter extends CustomPainter { ...@@ -17,17 +17,30 @@ class _BaselinePainter extends CustomPainter {
double baseline = paragraph.getDistanceToBaseline(TextBaseline.alphabetic); double baseline = paragraph.getDistanceToBaseline(TextBaseline.alphabetic);
double w = paragraph.getMaxIntrinsicWidth(new BoxConstraints.loose(size)); double w = paragraph.getMaxIntrinsicWidth(new BoxConstraints.loose(size));
double h = paragraph.getMaxIntrinsicHeight(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.moveTo(0.0, 0.0);
path.lineTo(w, 0.0); path.lineTo(w, 0.0);
path.moveTo(0.0, baseline);
path.lineTo(w, baseline);
path.moveTo(0.0, h); path.moveTo(0.0, h);
path.lineTo(w, h); path.lineTo(w, h);
Paint paint = new Paint() paint = new Paint()
..color = const Color(0xFFFF9000) ..color = const Color(0xFFFF9000)
..style = ui.PaintingStyle.stroke ..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); canvas.drawPath(path, paint);
} }
...@@ -81,8 +94,8 @@ void main() { ...@@ -81,8 +94,8 @@ void main() {
new RenderConstrainedBox( new RenderConstrainedBox(
additionalConstraints: new BoxConstraints.tightFor(height: 50.0) additionalConstraints: new BoxConstraints.tightFor(height: 50.0)
), ),
getBox(1.0),
getBox(null), getBox(null),
getBox(1.2),
], ],
direction: FlexDirection.vertical, direction: FlexDirection.vertical,
alignItems: FlexAlignItems.stretch alignItems: FlexAlignItems.stretch
......
...@@ -16,6 +16,7 @@ class TextStyle { ...@@ -16,6 +16,7 @@ class TextStyle {
this.fontWeight, this.fontWeight,
this.fontStyle, this.fontStyle,
this.letterSpacing, this.letterSpacing,
this.wordSpacing,
this.textAlign, this.textAlign,
this.textBaseline, this.textBaseline,
this.height, this.height,
...@@ -45,6 +46,9 @@ class TextStyle { ...@@ -45,6 +46,9 @@ class TextStyle {
/// The amount of space to add between each letter. /// The amount of space to add between each letter.
final double letterSpacing; 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 /// 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;
...@@ -73,6 +77,7 @@ class TextStyle { ...@@ -73,6 +77,7 @@ class TextStyle {
FontWeight fontWeight, FontWeight fontWeight,
FontStyle fontStyle, FontStyle fontStyle,
double letterSpacing, double letterSpacing,
double wordSpacing,
TextAlign textAlign, TextAlign textAlign,
TextBaseline textBaseline, TextBaseline textBaseline,
double height, double height,
...@@ -88,6 +93,7 @@ class TextStyle { ...@@ -88,6 +93,7 @@ class TextStyle {
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, letterSpacing: letterSpacing != null ? letterSpacing : this.letterSpacing,
wordSpacing: wordSpacing != null ? wordSpacing : this.wordSpacing,
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,
...@@ -111,6 +117,7 @@ class TextStyle { ...@@ -111,6 +117,7 @@ class TextStyle {
fontWeight: other.fontWeight, fontWeight: other.fontWeight,
fontStyle: other.fontStyle, fontStyle: other.fontStyle,
letterSpacing: other.letterSpacing, letterSpacing: other.letterSpacing,
wordSpacing: other.wordSpacing,
textAlign: other.textAlign, textAlign: other.textAlign,
textBaseline: other.textBaseline, textBaseline: other.textBaseline,
height: other.height, height: other.height,
...@@ -130,7 +137,9 @@ class TextStyle { ...@@ -130,7 +137,9 @@ class TextStyle {
fontStyle: fontStyle, fontStyle: fontStyle,
fontFamily: fontFamily, fontFamily: fontFamily,
fontSize: fontSize, fontSize: fontSize,
letterSpacing: letterSpacing letterSpacing: letterSpacing,
wordSpacing: wordSpacing,
lineHeight: height
); );
} }
...@@ -155,8 +164,10 @@ class TextStyle { ...@@ -155,8 +164,10 @@ class TextStyle {
fontWeight == typedOther.fontWeight && fontWeight == typedOther.fontWeight &&
fontStyle == typedOther.fontStyle && fontStyle == typedOther.fontStyle &&
letterSpacing == typedOther.letterSpacing && letterSpacing == typedOther.letterSpacing &&
wordSpacing == typedOther.wordSpacing &&
textAlign == typedOther.textAlign && textAlign == typedOther.textAlign &&
textBaseline == typedOther.textBaseline && textBaseline == typedOther.textBaseline &&
height == typedOther.height &&
decoration == typedOther.decoration && decoration == typedOther.decoration &&
decorationColor == typedOther.decorationColor && decorationColor == typedOther.decorationColor &&
decorationStyle == typedOther.decorationStyle; decorationStyle == typedOther.decorationStyle;
...@@ -164,15 +175,17 @@ class TextStyle { ...@@ -164,15 +175,17 @@ class TextStyle {
int get hashCode { int get hashCode {
return hashValues( return hashValues(
super.hashCode, inherit,
color, color,
fontFamily, fontFamily,
fontSize, fontSize,
fontWeight, fontWeight,
fontStyle, fontStyle,
letterSpacing, letterSpacing,
wordSpacing,
textAlign, textAlign,
textBaseline, textBaseline,
height,
decoration, decoration,
decorationColor, decorationColor,
decorationStyle decorationStyle
...@@ -181,7 +194,7 @@ class TextStyle { ...@@ -181,7 +194,7 @@ class TextStyle {
String toString([String prefix = '']) { String toString([String prefix = '']) {
List<String> result = <String>[]; List<String> result = <String>[];
result.add('${prefix}inhert: $inherit'); result.add('${prefix}inherit: $inherit');
if (color != null) if (color != null)
result.add('${prefix}color: $color'); result.add('${prefix}color: $color');
if (fontFamily != null) if (fontFamily != null)
...@@ -230,7 +243,9 @@ class TextStyle { ...@@ -230,7 +243,9 @@ class TextStyle {
} }
} }
if (letterSpacing != null) 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) { if (textAlign != null) {
switch (textAlign) { switch (textAlign) {
case TextAlign.left: case TextAlign.left:
...@@ -254,6 +269,8 @@ class TextStyle { ...@@ -254,6 +269,8 @@ class TextStyle {
break; break;
} }
} }
if (height != null)
result.add('${prefix}height: ${height}x');
if (decoration != null || decorationColor != null || decorationStyle != null) { if (decoration != null || decorationColor != null || decorationStyle != null) {
String decorationDescription = '${prefix}decoration: '; String decorationDescription = '${prefix}decoration: ';
bool haveDecorationDescription = false; bool haveDecorationDescription = false;
......
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