Use new ParagraphStyle attributes
Test: ./gradlew compileDebugKotlin
Test: ./gradlew ui-text:test
Test: ./gradlew ui-text:connectedAndroidTest
Test: Manual on demo app
Bug: 135546322
Change-Id: Ic19094590ec80a6a173b4313a2e87635213bcc4d
diff --git a/ui/text/api/1.0.0-alpha01.txt b/ui/text/api/1.0.0-alpha01.txt
index b063425..672173f 100644
--- a/ui/text/api/1.0.0-alpha01.txt
+++ b/ui/text/api/1.0.0-alpha01.txt
@@ -98,20 +98,21 @@
}
public final class ParagraphStyle {
- ctor public ParagraphStyle(androidx.ui.engine.text.TextAlign? textAlign, androidx.ui.engine.text.TextDirection? textDirection, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, Integer? maxLines, androidx.ui.engine.text.font.FontFamily? fontFamily, Float? fontSize, Float? lineHeight, Boolean? ellipsis, androidx.ui.engine.window.Locale? locale, androidx.ui.engine.text.FontSynthesis? fontSynthesis);
+ ctor public ParagraphStyle(androidx.ui.engine.text.TextAlign? textAlign, androidx.ui.engine.text.TextDirection? textDirection, androidx.ui.engine.text.TextIndent? textIndent, Float? lineHeight, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, Integer? maxLines, androidx.ui.engine.text.font.FontFamily? fontFamily, Float? fontSize, androidx.ui.engine.text.FontSynthesis? fontSynthesis, Boolean? ellipsis, androidx.ui.engine.window.Locale? locale);
ctor public ParagraphStyle();
method public androidx.ui.engine.text.TextAlign? component1();
- method public androidx.ui.engine.window.Locale? component10();
- method public androidx.ui.engine.text.FontSynthesis? component11();
+ method public androidx.ui.engine.text.FontSynthesis? component10();
+ method public Boolean? component11();
+ method public androidx.ui.engine.window.Locale? component12();
method public androidx.ui.engine.text.TextDirection? component2();
- method public androidx.ui.engine.text.FontWeight? component3();
- method public androidx.ui.engine.text.FontStyle? component4();
- method public Integer? component5();
- method public androidx.ui.engine.text.font.FontFamily? component6();
- method public Float? component7();
- method public Float? component8();
- method public Boolean? component9();
- method public androidx.ui.engine.text.ParagraphStyle copy(androidx.ui.engine.text.TextAlign? textAlign, androidx.ui.engine.text.TextDirection? textDirection, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, Integer? maxLines, androidx.ui.engine.text.font.FontFamily? fontFamily, Float? fontSize, Float? lineHeight, Boolean? ellipsis, androidx.ui.engine.window.Locale? locale, androidx.ui.engine.text.FontSynthesis? fontSynthesis);
+ method public androidx.ui.engine.text.TextIndent? component3();
+ method public Float? component4();
+ method public androidx.ui.engine.text.FontWeight? component5();
+ method public androidx.ui.engine.text.FontStyle? component6();
+ method public Integer? component7();
+ method public androidx.ui.engine.text.font.FontFamily? component8();
+ method public Float? component9();
+ method public androidx.ui.engine.text.ParagraphStyle copy(androidx.ui.engine.text.TextAlign? textAlign, androidx.ui.engine.text.TextDirection? textDirection, androidx.ui.engine.text.TextIndent? textIndent, Float? lineHeight, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, Integer? maxLines, androidx.ui.engine.text.font.FontFamily? fontFamily, Float? fontSize, androidx.ui.engine.text.FontSynthesis? fontSynthesis, Boolean? ellipsis, androidx.ui.engine.window.Locale? locale);
method public Boolean? getEllipsis();
method public androidx.ui.engine.text.font.FontFamily? getFontFamily();
method public Float? getFontSize();
@@ -123,7 +124,7 @@
method public Integer? getMaxLines();
method public androidx.ui.engine.text.TextAlign? getTextAlign();
method public androidx.ui.engine.text.TextDirection? getTextDirection();
- method public androidx.ui.engine.text.TextStyle getTextStyle();
+ method public androidx.ui.engine.text.TextIndent? getTextIndent();
}
public final class ParagraphStyleKt {
@@ -221,19 +222,16 @@
}
public final class TextStyle {
- ctor public TextStyle(androidx.ui.graphics.Color? color, androidx.ui.engine.text.TextDecoration? decoration, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, androidx.ui.engine.text.font.FontFamily? fontFamily, Float? fontSize, Float? fontSizeScale, String? fontFeatureSettings, Float? letterSpacing, Float? wordSpacing, androidx.ui.engine.text.BaselineShift? baselineShift, androidx.ui.engine.text.TextGeometricTransform? textGeometricTransform, Float? lineHeight, androidx.ui.engine.window.Locale? locale, androidx.ui.graphics.Color? background, androidx.ui.engine.text.FontSynthesis? fontSynthesis, androidx.ui.engine.text.TextIndent? textIndent, androidx.ui.engine.text.TextAlign? textAlign, androidx.ui.painting.Shadow? shadow);
+ ctor public TextStyle(androidx.ui.graphics.Color? color, androidx.ui.engine.text.TextDecoration? decoration, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, androidx.ui.engine.text.font.FontFamily? fontFamily, Float? fontSize, Float? fontSizeScale, String? fontFeatureSettings, Float? letterSpacing, Float? wordSpacing, androidx.ui.engine.text.BaselineShift? baselineShift, androidx.ui.engine.text.TextGeometricTransform? textGeometricTransform, androidx.ui.engine.window.Locale? locale, androidx.ui.graphics.Color? background, androidx.ui.engine.text.FontSynthesis? fontSynthesis, androidx.ui.painting.Shadow? shadow);
ctor public TextStyle();
method public androidx.ui.graphics.Color? component1();
method public Float? component10();
method public androidx.ui.engine.text.BaselineShift? component11();
method public androidx.ui.engine.text.TextGeometricTransform? component12();
- method public Float? component13();
- method public androidx.ui.engine.window.Locale? component14();
- method public androidx.ui.graphics.Color? component15();
- method public androidx.ui.engine.text.FontSynthesis? component16();
- method public androidx.ui.engine.text.TextIndent? component17();
- method public androidx.ui.engine.text.TextAlign? component18();
- method public androidx.ui.painting.Shadow? component19();
+ method public androidx.ui.engine.window.Locale? component13();
+ method public androidx.ui.graphics.Color? component14();
+ method public androidx.ui.engine.text.FontSynthesis? component15();
+ method public androidx.ui.painting.Shadow? component16();
method public androidx.ui.engine.text.TextDecoration? component2();
method public androidx.ui.engine.text.FontWeight? component3();
method public androidx.ui.engine.text.FontStyle? component4();
@@ -242,7 +240,7 @@
method public Float? component7();
method public String? component8();
method public Float? component9();
- method public androidx.ui.engine.text.TextStyle copy(androidx.ui.graphics.Color? color, androidx.ui.engine.text.TextDecoration? decoration, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, androidx.ui.engine.text.font.FontFamily? fontFamily, Float? fontSize, Float? fontSizeScale, String? fontFeatureSettings, Float? letterSpacing, Float? wordSpacing, androidx.ui.engine.text.BaselineShift? baselineShift, androidx.ui.engine.text.TextGeometricTransform? textGeometricTransform, Float? lineHeight, androidx.ui.engine.window.Locale? locale, androidx.ui.graphics.Color? background, androidx.ui.engine.text.FontSynthesis? fontSynthesis, androidx.ui.engine.text.TextIndent? textIndent, androidx.ui.engine.text.TextAlign? textAlign, androidx.ui.painting.Shadow? shadow);
+ method public androidx.ui.engine.text.TextStyle copy(androidx.ui.graphics.Color? color, androidx.ui.engine.text.TextDecoration? decoration, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, androidx.ui.engine.text.font.FontFamily? fontFamily, Float? fontSize, Float? fontSizeScale, String? fontFeatureSettings, Float? letterSpacing, Float? wordSpacing, androidx.ui.engine.text.BaselineShift? baselineShift, androidx.ui.engine.text.TextGeometricTransform? textGeometricTransform, androidx.ui.engine.window.Locale? locale, androidx.ui.graphics.Color? background, androidx.ui.engine.text.FontSynthesis? fontSynthesis, androidx.ui.painting.Shadow? shadow);
method public androidx.ui.graphics.Color? getBackground();
method public androidx.ui.engine.text.BaselineShift? getBaselineShift();
method public androidx.ui.graphics.Color? getColor();
@@ -255,12 +253,9 @@
method public androidx.ui.engine.text.FontSynthesis? getFontSynthesis();
method public androidx.ui.engine.text.FontWeight? getFontWeight();
method public Float? getLetterSpacing();
- method public Float? getLineHeight();
method public androidx.ui.engine.window.Locale? getLocale();
method public androidx.ui.painting.Shadow? getShadow();
- method public androidx.ui.engine.text.TextAlign? getTextAlign();
method public androidx.ui.engine.text.TextGeometricTransform? getTextGeometricTransform();
- method public androidx.ui.engine.text.TextIndent? getTextIndent();
method public Float? getWordSpacing();
}
@@ -490,22 +485,19 @@
}
public final class TextStyle {
- ctor public TextStyle(androidx.ui.graphics.Color? color, Float? fontSize, Float? fontSizeScale, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, androidx.ui.engine.text.FontSynthesis? fontSynthesis, String? fontFeatureSettings, Float? letterSpacing, Float? wordSpacing, androidx.ui.engine.text.BaselineShift? baselineShift, androidx.ui.engine.text.TextGeometricTransform? textGeometricTransform, Float? lineHeight, androidx.ui.engine.window.Locale? locale, androidx.ui.graphics.Color? background, androidx.ui.engine.text.TextDecoration? decoration, androidx.ui.engine.text.font.FontFamily? fontFamily, androidx.ui.engine.text.TextIndent? textIndent, androidx.ui.engine.text.TextAlign? textAlign, androidx.ui.painting.Shadow? shadow, String? debugLabel);
+ ctor public TextStyle(androidx.ui.graphics.Color? color, Float? fontSize, Float? fontSizeScale, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, androidx.ui.engine.text.FontSynthesis? fontSynthesis, String? fontFeatureSettings, Float? letterSpacing, Float? wordSpacing, androidx.ui.engine.text.BaselineShift? baselineShift, androidx.ui.engine.text.TextGeometricTransform? textGeometricTransform, androidx.ui.engine.window.Locale? locale, androidx.ui.graphics.Color? background, androidx.ui.engine.text.TextDecoration? decoration, androidx.ui.engine.text.font.FontFamily? fontFamily, androidx.ui.painting.Shadow? shadow, String? debugLabel);
ctor public TextStyle();
method public androidx.ui.painting.basictypes.RenderComparison compareTo(androidx.ui.painting.TextStyle other);
method public androidx.ui.graphics.Color? component1();
method public androidx.ui.engine.text.BaselineShift? component10();
method public androidx.ui.engine.text.TextGeometricTransform? component11();
- method public Float? component12();
- method public androidx.ui.engine.window.Locale? component13();
- method public androidx.ui.graphics.Color? component14();
- method public androidx.ui.engine.text.TextDecoration? component15();
- method public androidx.ui.engine.text.font.FontFamily? component16();
- method public androidx.ui.engine.text.TextIndent? component17();
- method public androidx.ui.engine.text.TextAlign? component18();
- method public androidx.ui.painting.Shadow? component19();
+ method public androidx.ui.engine.window.Locale? component12();
+ method public androidx.ui.graphics.Color? component13();
+ method public androidx.ui.engine.text.TextDecoration? component14();
+ method public androidx.ui.engine.text.font.FontFamily? component15();
+ method public androidx.ui.painting.Shadow? component16();
+ method public String? component17();
method public Float? component2();
- method public String? component20();
method public Float? component3();
method public androidx.ui.engine.text.FontWeight? component4();
method public androidx.ui.engine.text.FontStyle? component5();
@@ -513,7 +505,7 @@
method public String? component7();
method public Float? component8();
method public Float? component9();
- method public androidx.ui.painting.TextStyle copy(androidx.ui.graphics.Color? color, Float? fontSize, Float? fontSizeScale, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, androidx.ui.engine.text.FontSynthesis? fontSynthesis, String? fontFeatureSettings, Float? letterSpacing, Float? wordSpacing, androidx.ui.engine.text.BaselineShift? baselineShift, androidx.ui.engine.text.TextGeometricTransform? textGeometricTransform, Float? lineHeight, androidx.ui.engine.window.Locale? locale, androidx.ui.graphics.Color? background, androidx.ui.engine.text.TextDecoration? decoration, androidx.ui.engine.text.font.FontFamily? fontFamily, androidx.ui.engine.text.TextIndent? textIndent, androidx.ui.engine.text.TextAlign? textAlign, androidx.ui.painting.Shadow? shadow, String? debugLabel);
+ method public androidx.ui.painting.TextStyle copy(androidx.ui.graphics.Color? color, Float? fontSize, Float? fontSizeScale, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, androidx.ui.engine.text.FontSynthesis? fontSynthesis, String? fontFeatureSettings, Float? letterSpacing, Float? wordSpacing, androidx.ui.engine.text.BaselineShift? baselineShift, androidx.ui.engine.text.TextGeometricTransform? textGeometricTransform, androidx.ui.engine.window.Locale? locale, androidx.ui.graphics.Color? background, androidx.ui.engine.text.TextDecoration? decoration, androidx.ui.engine.text.font.FontFamily? fontFamily, androidx.ui.painting.Shadow? shadow, String? debugLabel);
method public androidx.ui.graphics.Color? getBackground();
method public androidx.ui.engine.text.BaselineShift? getBaselineShift();
method public androidx.ui.graphics.Color? getColor();
@@ -527,13 +519,10 @@
method public androidx.ui.engine.text.FontSynthesis? getFontSynthesis();
method public androidx.ui.engine.text.FontWeight? getFontWeight();
method public Float? getLetterSpacing();
- method public Float? getLineHeight();
method public androidx.ui.engine.window.Locale? getLocale();
- method public androidx.ui.engine.text.ParagraphStyle getParagraphStyle(androidx.ui.engine.text.TextAlign? textAlign = null, androidx.ui.engine.text.TextDirection? textDirection = null, float textScaleFactor = 1.0f, Boolean? ellipsis = null, Integer? maxLines = null, androidx.ui.engine.window.Locale? locale = null);
+ method public androidx.ui.engine.text.ParagraphStyle getParagraphStyle(androidx.ui.engine.text.TextAlign? textAlign = null, androidx.ui.engine.text.TextDirection? textDirection = null, androidx.ui.engine.text.TextIndent? textIndent = null, Float? lineHeight = null, float textScaleFactor = 1.0f, Boolean? ellipsis = null, Integer? maxLines = null, androidx.ui.engine.window.Locale? locale = null);
method public androidx.ui.painting.Shadow? getShadow();
- method public androidx.ui.engine.text.TextAlign? getTextAlign();
method public androidx.ui.engine.text.TextGeometricTransform? getTextGeometricTransform();
- method public androidx.ui.engine.text.TextIndent? getTextIndent();
method public androidx.ui.engine.text.TextStyle getTextStyle(float textScaleFactor = 1.0f);
method public Float? getWordSpacing();
method public androidx.ui.painting.TextStyle merge(androidx.ui.painting.TextStyle? other = null);
diff --git a/ui/text/api/current.txt b/ui/text/api/current.txt
index b063425..672173f 100644
--- a/ui/text/api/current.txt
+++ b/ui/text/api/current.txt
@@ -98,20 +98,21 @@
}
public final class ParagraphStyle {
- ctor public ParagraphStyle(androidx.ui.engine.text.TextAlign? textAlign, androidx.ui.engine.text.TextDirection? textDirection, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, Integer? maxLines, androidx.ui.engine.text.font.FontFamily? fontFamily, Float? fontSize, Float? lineHeight, Boolean? ellipsis, androidx.ui.engine.window.Locale? locale, androidx.ui.engine.text.FontSynthesis? fontSynthesis);
+ ctor public ParagraphStyle(androidx.ui.engine.text.TextAlign? textAlign, androidx.ui.engine.text.TextDirection? textDirection, androidx.ui.engine.text.TextIndent? textIndent, Float? lineHeight, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, Integer? maxLines, androidx.ui.engine.text.font.FontFamily? fontFamily, Float? fontSize, androidx.ui.engine.text.FontSynthesis? fontSynthesis, Boolean? ellipsis, androidx.ui.engine.window.Locale? locale);
ctor public ParagraphStyle();
method public androidx.ui.engine.text.TextAlign? component1();
- method public androidx.ui.engine.window.Locale? component10();
- method public androidx.ui.engine.text.FontSynthesis? component11();
+ method public androidx.ui.engine.text.FontSynthesis? component10();
+ method public Boolean? component11();
+ method public androidx.ui.engine.window.Locale? component12();
method public androidx.ui.engine.text.TextDirection? component2();
- method public androidx.ui.engine.text.FontWeight? component3();
- method public androidx.ui.engine.text.FontStyle? component4();
- method public Integer? component5();
- method public androidx.ui.engine.text.font.FontFamily? component6();
- method public Float? component7();
- method public Float? component8();
- method public Boolean? component9();
- method public androidx.ui.engine.text.ParagraphStyle copy(androidx.ui.engine.text.TextAlign? textAlign, androidx.ui.engine.text.TextDirection? textDirection, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, Integer? maxLines, androidx.ui.engine.text.font.FontFamily? fontFamily, Float? fontSize, Float? lineHeight, Boolean? ellipsis, androidx.ui.engine.window.Locale? locale, androidx.ui.engine.text.FontSynthesis? fontSynthesis);
+ method public androidx.ui.engine.text.TextIndent? component3();
+ method public Float? component4();
+ method public androidx.ui.engine.text.FontWeight? component5();
+ method public androidx.ui.engine.text.FontStyle? component6();
+ method public Integer? component7();
+ method public androidx.ui.engine.text.font.FontFamily? component8();
+ method public Float? component9();
+ method public androidx.ui.engine.text.ParagraphStyle copy(androidx.ui.engine.text.TextAlign? textAlign, androidx.ui.engine.text.TextDirection? textDirection, androidx.ui.engine.text.TextIndent? textIndent, Float? lineHeight, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, Integer? maxLines, androidx.ui.engine.text.font.FontFamily? fontFamily, Float? fontSize, androidx.ui.engine.text.FontSynthesis? fontSynthesis, Boolean? ellipsis, androidx.ui.engine.window.Locale? locale);
method public Boolean? getEllipsis();
method public androidx.ui.engine.text.font.FontFamily? getFontFamily();
method public Float? getFontSize();
@@ -123,7 +124,7 @@
method public Integer? getMaxLines();
method public androidx.ui.engine.text.TextAlign? getTextAlign();
method public androidx.ui.engine.text.TextDirection? getTextDirection();
- method public androidx.ui.engine.text.TextStyle getTextStyle();
+ method public androidx.ui.engine.text.TextIndent? getTextIndent();
}
public final class ParagraphStyleKt {
@@ -221,19 +222,16 @@
}
public final class TextStyle {
- ctor public TextStyle(androidx.ui.graphics.Color? color, androidx.ui.engine.text.TextDecoration? decoration, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, androidx.ui.engine.text.font.FontFamily? fontFamily, Float? fontSize, Float? fontSizeScale, String? fontFeatureSettings, Float? letterSpacing, Float? wordSpacing, androidx.ui.engine.text.BaselineShift? baselineShift, androidx.ui.engine.text.TextGeometricTransform? textGeometricTransform, Float? lineHeight, androidx.ui.engine.window.Locale? locale, androidx.ui.graphics.Color? background, androidx.ui.engine.text.FontSynthesis? fontSynthesis, androidx.ui.engine.text.TextIndent? textIndent, androidx.ui.engine.text.TextAlign? textAlign, androidx.ui.painting.Shadow? shadow);
+ ctor public TextStyle(androidx.ui.graphics.Color? color, androidx.ui.engine.text.TextDecoration? decoration, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, androidx.ui.engine.text.font.FontFamily? fontFamily, Float? fontSize, Float? fontSizeScale, String? fontFeatureSettings, Float? letterSpacing, Float? wordSpacing, androidx.ui.engine.text.BaselineShift? baselineShift, androidx.ui.engine.text.TextGeometricTransform? textGeometricTransform, androidx.ui.engine.window.Locale? locale, androidx.ui.graphics.Color? background, androidx.ui.engine.text.FontSynthesis? fontSynthesis, androidx.ui.painting.Shadow? shadow);
ctor public TextStyle();
method public androidx.ui.graphics.Color? component1();
method public Float? component10();
method public androidx.ui.engine.text.BaselineShift? component11();
method public androidx.ui.engine.text.TextGeometricTransform? component12();
- method public Float? component13();
- method public androidx.ui.engine.window.Locale? component14();
- method public androidx.ui.graphics.Color? component15();
- method public androidx.ui.engine.text.FontSynthesis? component16();
- method public androidx.ui.engine.text.TextIndent? component17();
- method public androidx.ui.engine.text.TextAlign? component18();
- method public androidx.ui.painting.Shadow? component19();
+ method public androidx.ui.engine.window.Locale? component13();
+ method public androidx.ui.graphics.Color? component14();
+ method public androidx.ui.engine.text.FontSynthesis? component15();
+ method public androidx.ui.painting.Shadow? component16();
method public androidx.ui.engine.text.TextDecoration? component2();
method public androidx.ui.engine.text.FontWeight? component3();
method public androidx.ui.engine.text.FontStyle? component4();
@@ -242,7 +240,7 @@
method public Float? component7();
method public String? component8();
method public Float? component9();
- method public androidx.ui.engine.text.TextStyle copy(androidx.ui.graphics.Color? color, androidx.ui.engine.text.TextDecoration? decoration, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, androidx.ui.engine.text.font.FontFamily? fontFamily, Float? fontSize, Float? fontSizeScale, String? fontFeatureSettings, Float? letterSpacing, Float? wordSpacing, androidx.ui.engine.text.BaselineShift? baselineShift, androidx.ui.engine.text.TextGeometricTransform? textGeometricTransform, Float? lineHeight, androidx.ui.engine.window.Locale? locale, androidx.ui.graphics.Color? background, androidx.ui.engine.text.FontSynthesis? fontSynthesis, androidx.ui.engine.text.TextIndent? textIndent, androidx.ui.engine.text.TextAlign? textAlign, androidx.ui.painting.Shadow? shadow);
+ method public androidx.ui.engine.text.TextStyle copy(androidx.ui.graphics.Color? color, androidx.ui.engine.text.TextDecoration? decoration, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, androidx.ui.engine.text.font.FontFamily? fontFamily, Float? fontSize, Float? fontSizeScale, String? fontFeatureSettings, Float? letterSpacing, Float? wordSpacing, androidx.ui.engine.text.BaselineShift? baselineShift, androidx.ui.engine.text.TextGeometricTransform? textGeometricTransform, androidx.ui.engine.window.Locale? locale, androidx.ui.graphics.Color? background, androidx.ui.engine.text.FontSynthesis? fontSynthesis, androidx.ui.painting.Shadow? shadow);
method public androidx.ui.graphics.Color? getBackground();
method public androidx.ui.engine.text.BaselineShift? getBaselineShift();
method public androidx.ui.graphics.Color? getColor();
@@ -255,12 +253,9 @@
method public androidx.ui.engine.text.FontSynthesis? getFontSynthesis();
method public androidx.ui.engine.text.FontWeight? getFontWeight();
method public Float? getLetterSpacing();
- method public Float? getLineHeight();
method public androidx.ui.engine.window.Locale? getLocale();
method public androidx.ui.painting.Shadow? getShadow();
- method public androidx.ui.engine.text.TextAlign? getTextAlign();
method public androidx.ui.engine.text.TextGeometricTransform? getTextGeometricTransform();
- method public androidx.ui.engine.text.TextIndent? getTextIndent();
method public Float? getWordSpacing();
}
@@ -490,22 +485,19 @@
}
public final class TextStyle {
- ctor public TextStyle(androidx.ui.graphics.Color? color, Float? fontSize, Float? fontSizeScale, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, androidx.ui.engine.text.FontSynthesis? fontSynthesis, String? fontFeatureSettings, Float? letterSpacing, Float? wordSpacing, androidx.ui.engine.text.BaselineShift? baselineShift, androidx.ui.engine.text.TextGeometricTransform? textGeometricTransform, Float? lineHeight, androidx.ui.engine.window.Locale? locale, androidx.ui.graphics.Color? background, androidx.ui.engine.text.TextDecoration? decoration, androidx.ui.engine.text.font.FontFamily? fontFamily, androidx.ui.engine.text.TextIndent? textIndent, androidx.ui.engine.text.TextAlign? textAlign, androidx.ui.painting.Shadow? shadow, String? debugLabel);
+ ctor public TextStyle(androidx.ui.graphics.Color? color, Float? fontSize, Float? fontSizeScale, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, androidx.ui.engine.text.FontSynthesis? fontSynthesis, String? fontFeatureSettings, Float? letterSpacing, Float? wordSpacing, androidx.ui.engine.text.BaselineShift? baselineShift, androidx.ui.engine.text.TextGeometricTransform? textGeometricTransform, androidx.ui.engine.window.Locale? locale, androidx.ui.graphics.Color? background, androidx.ui.engine.text.TextDecoration? decoration, androidx.ui.engine.text.font.FontFamily? fontFamily, androidx.ui.painting.Shadow? shadow, String? debugLabel);
ctor public TextStyle();
method public androidx.ui.painting.basictypes.RenderComparison compareTo(androidx.ui.painting.TextStyle other);
method public androidx.ui.graphics.Color? component1();
method public androidx.ui.engine.text.BaselineShift? component10();
method public androidx.ui.engine.text.TextGeometricTransform? component11();
- method public Float? component12();
- method public androidx.ui.engine.window.Locale? component13();
- method public androidx.ui.graphics.Color? component14();
- method public androidx.ui.engine.text.TextDecoration? component15();
- method public androidx.ui.engine.text.font.FontFamily? component16();
- method public androidx.ui.engine.text.TextIndent? component17();
- method public androidx.ui.engine.text.TextAlign? component18();
- method public androidx.ui.painting.Shadow? component19();
+ method public androidx.ui.engine.window.Locale? component12();
+ method public androidx.ui.graphics.Color? component13();
+ method public androidx.ui.engine.text.TextDecoration? component14();
+ method public androidx.ui.engine.text.font.FontFamily? component15();
+ method public androidx.ui.painting.Shadow? component16();
+ method public String? component17();
method public Float? component2();
- method public String? component20();
method public Float? component3();
method public androidx.ui.engine.text.FontWeight? component4();
method public androidx.ui.engine.text.FontStyle? component5();
@@ -513,7 +505,7 @@
method public String? component7();
method public Float? component8();
method public Float? component9();
- method public androidx.ui.painting.TextStyle copy(androidx.ui.graphics.Color? color, Float? fontSize, Float? fontSizeScale, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, androidx.ui.engine.text.FontSynthesis? fontSynthesis, String? fontFeatureSettings, Float? letterSpacing, Float? wordSpacing, androidx.ui.engine.text.BaselineShift? baselineShift, androidx.ui.engine.text.TextGeometricTransform? textGeometricTransform, Float? lineHeight, androidx.ui.engine.window.Locale? locale, androidx.ui.graphics.Color? background, androidx.ui.engine.text.TextDecoration? decoration, androidx.ui.engine.text.font.FontFamily? fontFamily, androidx.ui.engine.text.TextIndent? textIndent, androidx.ui.engine.text.TextAlign? textAlign, androidx.ui.painting.Shadow? shadow, String? debugLabel);
+ method public androidx.ui.painting.TextStyle copy(androidx.ui.graphics.Color? color, Float? fontSize, Float? fontSizeScale, androidx.ui.engine.text.FontWeight? fontWeight, androidx.ui.engine.text.FontStyle? fontStyle, androidx.ui.engine.text.FontSynthesis? fontSynthesis, String? fontFeatureSettings, Float? letterSpacing, Float? wordSpacing, androidx.ui.engine.text.BaselineShift? baselineShift, androidx.ui.engine.text.TextGeometricTransform? textGeometricTransform, androidx.ui.engine.window.Locale? locale, androidx.ui.graphics.Color? background, androidx.ui.engine.text.TextDecoration? decoration, androidx.ui.engine.text.font.FontFamily? fontFamily, androidx.ui.painting.Shadow? shadow, String? debugLabel);
method public androidx.ui.graphics.Color? getBackground();
method public androidx.ui.engine.text.BaselineShift? getBaselineShift();
method public androidx.ui.graphics.Color? getColor();
@@ -527,13 +519,10 @@
method public androidx.ui.engine.text.FontSynthesis? getFontSynthesis();
method public androidx.ui.engine.text.FontWeight? getFontWeight();
method public Float? getLetterSpacing();
- method public Float? getLineHeight();
method public androidx.ui.engine.window.Locale? getLocale();
- method public androidx.ui.engine.text.ParagraphStyle getParagraphStyle(androidx.ui.engine.text.TextAlign? textAlign = null, androidx.ui.engine.text.TextDirection? textDirection = null, float textScaleFactor = 1.0f, Boolean? ellipsis = null, Integer? maxLines = null, androidx.ui.engine.window.Locale? locale = null);
+ method public androidx.ui.engine.text.ParagraphStyle getParagraphStyle(androidx.ui.engine.text.TextAlign? textAlign = null, androidx.ui.engine.text.TextDirection? textDirection = null, androidx.ui.engine.text.TextIndent? textIndent = null, Float? lineHeight = null, float textScaleFactor = 1.0f, Boolean? ellipsis = null, Integer? maxLines = null, androidx.ui.engine.window.Locale? locale = null);
method public androidx.ui.painting.Shadow? getShadow();
- method public androidx.ui.engine.text.TextAlign? getTextAlign();
method public androidx.ui.engine.text.TextGeometricTransform? getTextGeometricTransform();
- method public androidx.ui.engine.text.TextIndent? getTextIndent();
method public androidx.ui.engine.text.TextStyle getTextStyle(float textScaleFactor = 1.0f);
method public Float? getWordSpacing();
method public androidx.ui.painting.TextStyle merge(androidx.ui.painting.TextStyle? other = null);
diff --git a/ui/text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/CraneText.kt b/ui/text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/CraneText.kt
index 04730de..627ff7a 100644
--- a/ui/text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/CraneText.kt
+++ b/ui/text/integration-tests/text-demos/src/main/java/androidx/ui/text/demos/CraneText.kt
@@ -320,12 +320,15 @@
style = TextStyle(fontSize = fontSize8)
)
}
- Text {
+ Text(
+ paragraphStyle = ParagraphStyle(
+ lineHeight = 2.0f
+ )
+ ) {
Span(
text = "$displayText\n$displayText ",
style = TextStyle(
- fontSize = fontSize8,
- lineHeight = 2.0f
+ fontSize = fontSize8
)
)
}
diff --git a/ui/text/src/androidTest/java/androidx/ui/engine/text/ParagraphIntegrationTest.kt b/ui/text/src/androidTest/java/androidx/ui/engine/text/ParagraphIntegrationTest.kt
index 192f57c..1cc4742 100644
--- a/ui/text/src/androidTest/java/androidx/ui/engine/text/ParagraphIntegrationTest.kt
+++ b/ui/text/src/androidTest/java/androidx/ui/engine/text/ParagraphIntegrationTest.kt
@@ -29,8 +29,8 @@
import androidx.ui.engine.text.font.FontFamily
import androidx.ui.engine.text.font.asFontFamily
import androidx.ui.engine.window.Locale
-import androidx.ui.matchers.equalToBitmap
import androidx.ui.graphics.Color
+import androidx.ui.matchers.equalToBitmap
import androidx.ui.painting.AnnotatedString
import androidx.ui.painting.Path
import androidx.ui.painting.PathOperation
@@ -1296,21 +1296,14 @@
}
@Test
- fun textStyle_textIndent_onSingleLine() {
+ fun textIndent_onSingleLine() {
val text = "abc"
val fontSize = 20.0f
val indent = 20.0f
- val textStyle = TextStyle(textIndent = TextIndent(firstLine = indent.px))
val paragraph = simpleParagraph(
text = text,
- textStyles = listOf(
- AnnotatedString.Item(
- style = textStyle,
- start = 0,
- end = text.length
- )
- ),
+ textIndent = TextIndent(firstLine = indent.px),
fontSize = fontSize,
fontFamily = fontFamilyMeasureFont
)
@@ -1325,22 +1318,15 @@
}
@Test
- fun textStyle_textIndent_onFirstLine() {
+ fun textIndent_onFirstLine() {
val text = "abcdef"
val fontSize = 20.0f
val indent = 20.0f
- val textStyle = TextStyle(textIndent = TextIndent(firstLine = indent.px))
val paragraphWidth = "abcd".length * fontSize
val paragraph = simpleParagraph(
text = text,
- textStyles = listOf(
- AnnotatedString.Item(
- style = textStyle,
- start = 0,
- end = text.length
- )
- ),
+ textIndent = TextIndent(firstLine = indent.px),
fontSize = fontSize,
fontFamily = fontFamilyMeasureFont
)
@@ -1356,27 +1342,15 @@
}
@Test
- fun textStyle_textIndent_onRestLine() {
+ fun textIndent_onRestLine() {
val text = "abcde"
val fontSize = 20.0f
val indent = 20.0f
- val textStyle = TextStyle(
- textIndent = TextIndent(
- firstLine = 0.px,
- restLine = indent.px
- )
- )
val paragraphWidth = "abc".length * fontSize
val paragraph = simpleParagraph(
text = text,
- textStyles = listOf(
- AnnotatedString.Item(
- style = textStyle,
- start = 0,
- end = text.length
- )
- ),
+ textIndent = TextIndent(firstLine = 0.px, restLine = indent.px),
fontSize = fontSize,
fontFamily = fontFamilyMeasureFont
)
@@ -1393,170 +1367,6 @@
}
@Test
- fun textStyle_textAlign_whenAlignLeft_returnsZeroForGetLineLeft() {
- val texts = listOf("aa", "\u05D0\u05D0")
- val fontSize = 20.0f
-
- texts.map { text ->
- val paragraph = simpleParagraph(
- text = text,
- textStyles = listOf(
- AnnotatedString.Item(
- style = TextStyle(textAlign = TextAlign.Left),
- start = 0,
- end = text.length
- )
- ),
- fontSize = fontSize
- )
- val layoutWidth = (text.length + 2) * fontSize
- paragraph.layout(ParagraphConstraints(width = layoutWidth))
- val paragraphImpl = paragraph.paragraphImpl
- assertThat(paragraphImpl.getLineLeft(0), equalTo(0.0f))
- }
- }
-
- @Test
- fun textStyle_textAlign_whenAlignRight_returnsLayoutWidthForGetLineRight() {
- val texts = listOf("aa", "\u05D0\u05D0")
- val fontSize = 20.0f
-
- texts.map { text ->
- val paragraph = simpleParagraph(
- text = text,
- textStyles = listOf(
- AnnotatedString.Item(
- style = TextStyle(textAlign = TextAlign.Right),
- start = 0,
- end = text.length
- )
- ),
- fontSize = fontSize
- )
- val layoutWidth = (text.length + 2) * fontSize
- paragraph.layout(ParagraphConstraints(width = layoutWidth))
- val paragraphImpl = paragraph.paragraphImpl
- assertThat(paragraphImpl.getLineRight(0), equalTo(layoutWidth))
- }
- }
-
- @Test
- fun textStyle_textAlign_whenAlignCenter_textIsCentered() {
- val texts = listOf("aa", "\u05D0\u05D0")
- val fontSize = 20.0f
-
- texts.map { text ->
- val paragraph = simpleParagraph(
- text = text,
- textStyles = listOf(
- AnnotatedString.Item(
- style = TextStyle(textAlign = TextAlign.Center),
- start = 0,
- end = text.length
- )
- ),
- fontSize = fontSize
- )
- val layoutWidth = (text.length + 2) * fontSize
- paragraph.layout(ParagraphConstraints(width = layoutWidth))
- val textWidth = text.length * fontSize
- val paragraphImpl = paragraph.paragraphImpl
- assertThat(paragraphImpl.getLineLeft(0),
- equalTo(layoutWidth / 2 - textWidth / 2))
- assertThat(paragraphImpl.getLineRight(0),
- equalTo(layoutWidth / 2 + textWidth / 2))
- }
- }
-
- @Test
- fun textStyle_textAlign_whenAlignStart_withLTR_returnsZeroForGetLineLeft() {
- val text = "aa"
- val fontSize = 20.0f
- val layoutWidth = (text.length + 2) * fontSize
-
- val paragraph = simpleParagraph(
- text = text,
- textStyles = listOf(
- AnnotatedString.Item(
- style = TextStyle(textAlign = TextAlign.Start),
- start = 0,
- end = text.length
- )
- ),
- fontSize = fontSize
- )
- paragraph.layout(ParagraphConstraints(width = layoutWidth))
- val paragraphImpl = paragraph.paragraphImpl
- assertThat(paragraphImpl.getLineLeft(0), equalTo(0.0f))
- }
-
- @Test
- fun textStyle_textAlign_whenAlignEnd_withLTR_returnsLayoutWidthForGetLineRight() {
- val text = "aa"
- val fontSize = 20.0f
- val layoutWidth = (text.length + 2) * fontSize
-
- val paragraph = simpleParagraph(
- text = text,
- textStyles = listOf(
- AnnotatedString.Item(
- style = TextStyle(textAlign = TextAlign.End),
- start = 0,
- end = text.length
- )
- ),
- fontSize = fontSize
- )
- paragraph.layout(ParagraphConstraints(width = layoutWidth))
- val paragraphImpl = paragraph.paragraphImpl
- assertThat(paragraphImpl.getLineRight(0), equalTo(layoutWidth))
- }
-
- @Test
- fun textStyle_textAlign_whenAlignStart_withRTL_returnsLayoutWidthForGetLineRight() {
- val text = "\u05D0\u05D0"
- val fontSize = 20.0f
- val layoutWidth = (text.length + 2) * fontSize
-
- val paragraph = simpleParagraph(
- text = text,
- textStyles = listOf(
- AnnotatedString.Item(
- style = TextStyle(textAlign = TextAlign.Start),
- start = 0,
- end = text.length
- )
- ),
- fontSize = fontSize
- )
- paragraph.layout(ParagraphConstraints(width = layoutWidth))
- val paragraphImpl = paragraph.paragraphImpl
- assertThat(paragraphImpl.getLineRight(0), equalTo(layoutWidth))
- }
-
- @Test
- fun textStyle_textAlign_whenAlignEnd_withRTL_returnsZeroForGetLineLeft() {
- val text = "\u05D0\u05D0"
- val fontSize = 20.0f
- val layoutWidth = (text.length + 2) * fontSize
-
- val paragraph = simpleParagraph(
- text = text,
- textStyles = listOf(
- AnnotatedString.Item(
- style = TextStyle(textAlign = TextAlign.End),
- start = 0,
- end = text.length
- )
- ),
- fontSize = fontSize
- )
- paragraph.layout(ParagraphConstraints(width = layoutWidth))
- val paragraphImpl = paragraph.paragraphImpl
- assertThat(paragraphImpl.getLineLeft(0), equalTo(0.0f))
- }
-
- @Test
fun textStyle_fontFamily_changesMeasurement() {
val text = "ad"
val fontSize = 20.0f
@@ -1956,6 +1766,7 @@
private fun simpleParagraph(
text: String = "",
+ textIndent: TextIndent? = null,
textAlign: TextAlign? = null,
textDirection: TextDirection? = null,
fontSize: Float? = null,
@@ -1968,6 +1779,7 @@
text = text,
textStyles = textStyles,
paragraphStyle = ParagraphStyle(
+ textIndent = textIndent,
textAlign = textAlign,
textDirection = textDirection,
maxLines = maxLines,
diff --git a/ui/text/src/androidTest/java/androidx/ui/engine/text/platform/ParagraphAndroidTest.kt b/ui/text/src/androidTest/java/androidx/ui/engine/text/platform/ParagraphAndroidTest.kt
index b88c119..2832fc7 100644
--- a/ui/text/src/androidTest/java/androidx/ui/engine/text/platform/ParagraphAndroidTest.kt
+++ b/ui/text/src/androidTest/java/androidx/ui/engine/text/platform/ParagraphAndroidTest.kt
@@ -40,7 +40,6 @@
import androidx.ui.matchers.equalToBitmap
import androidx.ui.matchers.hasSpan
import androidx.ui.matchers.hasSpanOnTop
-import androidx.ui.matchers.notHasSpan
import androidx.ui.graphics.Color
import androidx.ui.painting.Shadow
import androidx.ui.painting.AnnotatedString
@@ -714,164 +713,21 @@
}
@Test
- fun textStyle_setTextIndent_onWholeParagraph() {
+ fun textIndent_onWholeParagraph() {
val text = "abc\ndef"
val firstLine = 40
val restLine = 20
- val textStyle = TextStyle(textIndent = TextIndent(firstLine.px, restLine.px))
val paragraph = simpleParagraph(
text = text,
- textStyles = listOf(
- AnnotatedString.Item(textStyle, 0, "abc".length)
- )
+ textIndent = TextIndent(firstLine.px, restLine.px)
)
// width is not important
paragraph.layout(100.0f)
assertThat(
paragraph.underlyingText,
- hasSpan(LeadingMarginSpan.Standard::class, 0, "abc".length) {
- it.getLeadingMargin(true) == firstLine && it.getLeadingMargin(false) == restLine
- }
- )
- }
-
- @Test
- fun textStyle_setTextIndent_onPartParagraph() {
- val text = "abc\ndef"
- val firstLine = 40
- val restLine = 20
- val textStyle = TextStyle(textIndent = TextIndent(firstLine.px, restLine.px))
-
- val paragraph = simpleParagraph(
- text = text,
- textStyles = listOf(
- AnnotatedString.Item(textStyle, 0, 1)
- )
- )
- // width is not important
- paragraph.layout(100.0f)
-
- assertThat(
- paragraph.underlyingText,
- hasSpan(LeadingMarginSpan.Standard::class, 0, "abc".length) {
- it.getLeadingMargin(true) == firstLine && it.getLeadingMargin(false) == restLine
- }
- )
- }
-
- @Test
- fun textStyle_setTextIndent_lastCharIsLineFeed() {
- val text = "abc\ndef"
- val firstLine = 40
- val restLine = 20
- val textStyle = TextStyle(textIndent = TextIndent(firstLine.px, restLine.px))
-
- val paragraph = simpleParagraph(
- text = text,
- textStyles = listOf(
- AnnotatedString.Item(textStyle, 0, "abc\n".length)
- )
- )
- // width is not important
- paragraph.layout(100.0f)
-
- assertThat(
- paragraph.underlyingText,
- hasSpan(LeadingMarginSpan.Standard::class, 0, "abc".length) {
- it.getLeadingMargin(true) == firstLine && it.getLeadingMargin(false) == restLine
- }
- )
- }
-
- @Test
- fun textStyle_setTextIndent_firstCharIsLineFeed() {
- val text = "abc\ndef"
- val firstLine = 40
- val restLine = 20
- val textStyle = TextStyle(textIndent = TextIndent(firstLine.px, restLine.px))
-
- val paragraph = simpleParagraph(
- text = text,
- textStyles = listOf(
- AnnotatedString.Item(textStyle, "abc".length, "abc\nd".length)
- )
- )
- // width is not important
- paragraph.layout(100.0f)
-
- assertThat(
- paragraph.underlyingText,
- hasSpan(LeadingMarginSpan.Standard::class, "abc\n".length, "abc\ndef".length) {
- it.getLeadingMargin(true) == firstLine && it.getLeadingMargin(false) == restLine
- }
- )
- }
-
- @Test
- fun textStyle_setTextIndent_coverLineFeed() {
- val text = "abc\ndef"
- val firstLine = 40
- val restLine = 20
- val textStyle = TextStyle(textIndent = TextIndent(firstLine.px, restLine.px))
-
- val paragraph = simpleParagraph(
- text = text,
- textStyles = listOf(
- AnnotatedString.Item(textStyle, "abc".length, "abc\n".length)
- )
- )
- // width is not important
- paragraph.layout(100.0f)
-
- assertThat(
- paragraph.underlyingText,
- notHasSpan(LeadingMarginSpan.Standard::class, 0, text.length)
- )
- }
-
- @Test
- fun textStyle_setTextIndent_coverEmptyParagraph() {
- val text = "abc\n\ndef"
- val firstLine = 40
- val restLine = 20
- val textStyle = TextStyle(textIndent = TextIndent(firstLine.px, restLine.px))
-
- val paragraph = simpleParagraph(
- text = text,
- textStyles = listOf(
- AnnotatedString.Item(textStyle, "abc".length, "abc\n\n".length)
- )
- )
- // width is not important
- paragraph.layout(100.0f)
-
- assertThat(
- paragraph.underlyingText,
- hasSpan(LeadingMarginSpan.Standard::class, "abc\n".length, "abc\n\n".length)
- )
- }
-
- @Test
- fun textStyle_setTextIndent_coverMultiParagraph() {
- val text = "abc\ndef\nghi"
- val firstLine = 40
- val restLine = 20
- val textStyle = TextStyle(textIndent = TextIndent(firstLine.px, restLine.px))
-
- val paragraph = simpleParagraph(
- text = text,
- textStyles = listOf(
- AnnotatedString.Item(textStyle, "ab".length, "abc\nd".length)
- )
- )
- // width is not important
- paragraph.layout(100.0f)
-
- assertThat(
- paragraph.underlyingText,
- hasSpan(LeadingMarginSpan.Standard::class, 0, "abc\ndef".length) {
+ hasSpan(LeadingMarginSpan.Standard::class, 0, text.length) {
it.getLeadingMargin(true) == firstLine && it.getLeadingMargin(false) == restLine
}
)
@@ -1215,6 +1071,7 @@
private fun simpleParagraph(
text: String = "",
textStyles: List<AnnotatedString.Item<TextStyle>> = listOf(),
+ textIndent: TextIndent? = null,
textAlign: TextAlign? = null,
fontSize: Float? = null,
ellipsis: Boolean? = null,
@@ -1230,6 +1087,7 @@
typefaceAdapter = typefaceAdapter,
paragraphStyle = ParagraphStyle(
textAlign = textAlign,
+ textIndent = textIndent,
ellipsis = ellipsis,
maxLines = maxLines,
fontFamily = fontFamily,
@@ -1239,4 +1097,4 @@
)
)
}
-}
+}
\ No newline at end of file
diff --git a/ui/text/src/main/java/androidx/ui/engine/text/ParagraphStyle.kt b/ui/text/src/main/java/androidx/ui/engine/text/ParagraphStyle.kt
index 72eea36..e657fa0 100644
--- a/ui/text/src/main/java/androidx/ui/engine/text/ParagraphStyle.kt
+++ b/ui/text/src/main/java/androidx/ui/engine/text/ParagraphStyle.kt
@@ -34,6 +34,12 @@
* directionality of the paragraph, as well as the meaning of
* [TextAlign.Start] and [TextAlign.End] in the `textAlign` field.
*
+ * @param textIndent The amount of indentation applied to the affected paragraph. A paragraph is
+ * affected if any of its character is covered by the TextSpan.
+ *
+ * @param lineHeight The minimum height of the line boxes, as a multiple of the
+ * font size.
+ *
* @param fontWeight The typeface thickness to use when painting the text
* (e.g., bold).
*
@@ -50,8 +56,8 @@
* @param fontSize The size of glyphs (in logical pixels) to use when painting
* the text.
*
- * @param lineHeight The minimum height of the line boxes, as a multiple of the
- * font size.
+ * @param fontSynthesis Whether to synthesize font weight and/or style when the requested weight or
+ * style cannot be found in the provided custom font family.
*
* @param ellipsis Whether to ellipsize overflowing text. If `maxLines` is
* not null, ellipsis is applied to the last rendered line, if that line
@@ -60,52 +66,21 @@
*
* @param locale The locale used to select region-specific glyphs.
*
- * @param fontSynthesis Whether to synthesize font weight and/or style when the requested weight or
- * style cannot be found in the provided custom font family.
*/
data class ParagraphStyle constructor(
val textAlign: TextAlign? = null,
val textDirection: TextDirection? = null,
+ val textIndent: TextIndent? = null,
+ val lineHeight: Float? = null,
val fontWeight: FontWeight? = null,
val fontStyle: FontStyle? = null,
val maxLines: Int? = null,
val fontFamily: FontFamily? = null,
val fontSize: Float? = null,
- val lineHeight: Float? = null,
- // TODO(Migration/siyamed): pass to TextLayout
+ val fontSynthesis: FontSynthesis? = null,
val ellipsis: Boolean? = null,
- val locale: Locale? = null,
- val fontSynthesis: FontSynthesis? = null
-) {
-
- override fun toString(): String {
- return "ParagraphStyle(" +
- "textAlign: ${textAlign ?: "unspecified"}, " +
- "textDirection: ${textDirection ?: "unspecified"}, " +
- "fontWeight: ${fontWeight ?: "unspecified"}, " +
- "fontStyle: ${fontStyle ?: "unspecified"}, " +
- "maxLines: ${maxLines ?: "unspecified"}, " +
- "fontFamily: ${fontFamily ?: "unspecified"}, " +
- "fontSize: ${fontSize ?: "unspecified"}, " +
- "lineHeight: ${if (lineHeight != null) "${lineHeight}x" else "unspecified"}, " +
- "ellipsis: ${if (ellipsis != null) "\"$ellipsis\"" else "unspecified"}, " +
- "locale: ${locale ?: "unspecified"}, " +
- "fontSynthesis: ${fontSynthesis ?: "unspecified"}" +
- ")"
- }
-
- fun getTextStyle(): TextStyle {
- return TextStyle(
- fontWeight = fontWeight,
- fontStyle = fontStyle,
- fontFamily = fontFamily,
- fontSize = fontSize,
- locale = locale,
- lineHeight = lineHeight,
- fontSynthesis = fontSynthesis
- )
- }
-}
+ val locale: Locale? = null
+)
/**
* Returns true if this [ParagraphStyle] contains any font style attributes set.
diff --git a/ui/text/src/main/java/androidx/ui/engine/text/TextStyle.kt b/ui/text/src/main/java/androidx/ui/engine/text/TextStyle.kt
index 95bb40e..177f40c 100644
--- a/ui/text/src/main/java/androidx/ui/engine/text/TextStyle.kt
+++ b/ui/text/src/main/java/androidx/ui/engine/text/TextStyle.kt
@@ -43,15 +43,11 @@
* @param textBaseline The common baseline that should be aligned between this text span and its
* parent text span, or, for the root text spans, with the line box.
* @param baselineShift This parameter specifies how much the baseline is shifted from the current position.
- * @param lineHeight The line height for this text, as a multiple of the font size.
* @param textGeometricTransform The geometric transformation applied the text.
* @param locale The locale used to select region-specific glyphs.
* @param background The background color for the text.
* @param fontSynthesis Whether to synthesize font weight and/or style when the requested weight or
* style cannot be found in the provided custom font family.
- * @param textIndent The amount of indentation applied to the affected paragraph. A paragraph is affected
- * if any of its character is covered by the TextSpan.
- * @param textAlign Specify how a paragraph is aligned.
* @param shadow The shadow effect applied on the text.
*/
data class TextStyle constructor(
@@ -67,11 +63,8 @@
val wordSpacing: Float? = null,
val baselineShift: BaselineShift? = null,
val textGeometricTransform: TextGeometricTransform? = null,
- val lineHeight: Float? = null,
val locale: Locale? = null,
val background: Color? = null,
val fontSynthesis: FontSynthesis? = null,
- val textIndent: TextIndent? = null,
- val textAlign: TextAlign? = null,
val shadow: Shadow? = null
)
\ No newline at end of file
diff --git a/ui/text/src/main/java/androidx/ui/engine/text/platform/ParagraphAndroid.kt b/ui/text/src/main/java/androidx/ui/engine/text/platform/ParagraphAndroid.kt
index f3a755f..04ffa5c 100644
--- a/ui/text/src/main/java/androidx/ui/engine/text/platform/ParagraphAndroid.kt
+++ b/ui/text/src/main/java/androidx/ui/engine/text/platform/ParagraphAndroid.kt
@@ -21,7 +21,6 @@
import android.text.TextPaint
import android.text.TextUtils
import android.text.style.AbsoluteSizeSpan
-import android.text.style.AlignmentSpan
import android.text.style.BackgroundColorSpan
import android.text.style.ForegroundColorSpan
import android.text.style.LeadingMarginSpan
@@ -44,14 +43,13 @@
import androidx.text.LayoutCompat.JUSTIFICATION_MODE_INTER_WORD
import androidx.text.LayoutCompat.TEXT_DIRECTION_LTR
import androidx.text.LayoutCompat.TEXT_DIRECTION_RTL
-import androidx.text.TextAlignmentAdapter
import androidx.text.TextLayout
import androidx.text.selection.WordBoundary
import androidx.text.style.BaselineShiftSpan
import androidx.text.style.FontFeatureSpan
import androidx.text.style.LetterSpacingSpan
-import androidx.text.style.SkewXSpan
import androidx.text.style.ShadowSpan
+import androidx.text.style.SkewXSpan
import androidx.text.style.TypefaceSpan
import androidx.text.style.WordSpacingSpan
import androidx.ui.core.px
@@ -65,6 +63,7 @@
import androidx.ui.engine.text.TextAlign
import androidx.ui.engine.text.TextDecoration
import androidx.ui.engine.text.TextDirection
+import androidx.ui.engine.text.TextIndent
import androidx.ui.engine.text.TextPosition
import androidx.ui.engine.text.hasFontAttributes
import androidx.ui.painting.AnnotatedString
@@ -147,7 +146,7 @@
textPaint.textSize = it
}
- // TODO: This default values are problem here. If the user just gives a single font
+ // TODO(siyamed): This default values are problem here. If the user just gives a single font
// in the family, and does not provide any fontWeight, TypefaceAdapter will still get the
// call as FontWeight.normal (which is the default value)
if (paragraphStyle.hasFontAttributes()) {
@@ -156,7 +155,6 @@
fontWeight = paragraphStyle.fontWeight ?: FontWeight.normal,
fontStyle = paragraphStyle.fontStyle ?: FontStyle.Normal,
fontSynthesis = paragraphStyle.fontSynthesis ?: FontSynthesis.All
-
)
}
@@ -167,7 +165,8 @@
)
}
- val charSequence = applyTextStyle(text, textStyles)
+ val charSequence = applyTextStyle(text, paragraphStyle.textIndent, textStyles)
+
val alignment = toLayoutAlign(paragraphStyle.textAlign)
// TODO(Migration/haoyuchang): Layout has more settings that flutter,
// we may add them in future.
@@ -176,14 +175,14 @@
TextDirection.Rtl -> TEXT_DIRECTION_RTL
else -> DEFAULT_TEXT_DIRECTION
}
+
val maxLines = paragraphStyle.maxLines ?: DEFAULT_MAX_LINES
val justificationMode = when (paragraphStyle.textAlign) {
TextAlign.Justify -> JUSTIFICATION_MODE_INTER_WORD
else -> DEFAULT_JUSTIFICATION_MODE
}
- val lineSpacingMultiplier =
- paragraphStyle.lineHeight ?: DEFAULT_LINESPACING_MULTIPLIER
+ val lineSpacingMultiplier = paragraphStyle.lineHeight ?: DEFAULT_LINESPACING_MULTIPLIER
val ellipsize = if (paragraphStyle.ellipsis == true) {
TextUtils.TruncateAt.END
@@ -268,69 +267,27 @@
canvas.translate(-x, -y)
}
- /**
- * Adjust the paragraph span position to fit affected paragraphs correctly. As a paragraph span
- * will take effect on a paragraph when any character of the paragraph is covered, the range of
- * the span doesn't necessarily equals to the range it take effect. This functions is used to
- * convert the range where the span is attached to the range in which the span actually take
- * effect.
- * E.g. For input text "ab\ncd\ne" where a paragraph span is attached to "ab\nc", the span will
- * take effect on "ab\ncd". Thus this function will return Pair(0, 5).
- *
- * @param text the text where the span is applied on
- * @param start the inclusive start position of the paragraph span.
- * @param end the exclusive end position of the paragraph span.
- * @return a pair of indices which represent the adjusted position of the paragraph span.
- */
- private fun adjustSpanPositionForParagraph(
- text: String,
- start: Int,
- end: Int
- ): Pair<Int, Int> {
- if (text.isEmpty()) return Pair(0, 0)
- if (end <= start) return Pair(start, start)
-
- var spanStart = start.coerceIn(0, text.length - 1)
- var spanEnd = end.coerceIn(0, text.length)
-
- if (text[spanStart] == LINE_FEED) {
- // The span happens to start with a LINE_FEED; check if the previous char is LINE_FEED.
- // If not, the spanStart points to the end of a paragraph; skip the LINE_FEED.
- // Otherwise, the span covers an empty paragraph; won't change start position.
- if (spanStart > 0 && text[spanStart - 1] != LINE_FEED) {
- ++spanStart
- }
- } else {
- // The span starts with a non LINE_FEED character, reposition the start to the first
- // character following a previous LINE_FEED.
- while (spanStart > 0 && text[spanStart - 1] != LINE_FEED) {
- --spanStart
- }
- }
-
- if (spanEnd > 0 && text[spanEnd - 1] == LINE_FEED) {
- // The span ends with a LINE_FEED; check if the second last char is LINE_FEED.
- // If not, the spanEnd is pointing to the end of a paragraph; skip the LINE_FEED.
- // Otherwise, the span covers an empty paragraph; won't change the end position
- if (spanEnd > 1 && text[spanEnd - 2] != LINE_FEED) {
- --spanEnd
- }
- } else {
- // The span ends with a non LINE_FEED character, reposition the end to the first
- // character followed by a LINE_FEED.
- while (spanEnd < text.length && text[spanEnd] != LINE_FEED) {
- ++spanEnd
- }
- }
- return Pair(spanStart, spanEnd)
- }
-
private fun applyTextStyle(
text: String,
+ textIndent: TextIndent?,
textStyles: List<AnnotatedString.Item<TextStyle>>
): CharSequence {
- if (textStyles.isEmpty()) return text
+ if (textStyles.isEmpty() && textIndent == null) return text
val spannableString = SpannableString(text)
+
+ textIndent?.let { indent ->
+ if (indent.firstLine == 0.px && indent.restLine == 0.px) return@let
+ spannableString.setSpan(
+ LeadingMarginSpan.Standard(
+ indent.firstLine.value.toInt(),
+ indent.restLine.value.toInt()
+ ),
+ 0,
+ text.length,
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
+ )
+ }
+
for (textStyle in textStyles) {
val start = textStyle.start
val end = textStyle.end
@@ -338,36 +295,6 @@
if (start < 0 || start >= text.length || end <= start || end > text.length) continue
- style.textIndent?.let { indent ->
- if (indent.firstLine == 0.px && indent.restLine == 0.px) return@let
- val (spanStart, spanEnd) = adjustSpanPositionForParagraph(text, start, end)
- // Filter out invalid result.
- if (spanStart >= spanEnd) return@let
- spannableString.setSpan(
- LeadingMarginSpan.Standard(
- indent.firstLine.value.toInt(),
- indent.restLine.value.toInt()
- ),
- spanStart,
- spanEnd,
- Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
- )
- }
-
- style.textAlign?.let { align ->
- val (spanStart, spanEnd) = adjustSpanPositionForParagraph(text, start, end)
- // Filter out invalid result.
- if (spanStart >= spanEnd) return@let
-
- // TODO(haoyuchang): Support TextAlign.JUSTIFY
- spannableString.setSpan(
- AlignmentSpan.Standard(TextAlignmentAdapter.get(toLayoutAlign(align))),
- spanStart,
- spanEnd,
- Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
- )
- }
-
// Be aware that SuperscriptSpan needs to be applied before all other spans which
// affect FontMetrics
style.baselineShift?.let {
@@ -529,4 +456,61 @@
TextAlign.Start -> ALIGN_NORMAL
TextAlign.End -> ALIGN_OPPOSITE
else -> DEFAULT_ALIGNMENT
-}
\ No newline at end of file
+}
+
+// /**
+// * Adjust the paragraph span position to fit affected paragraphs correctly. As a paragraph span
+// * will take effect on a paragraph when any character of the paragraph is covered, the range of
+// * the span doesn't necessarily equals to the range it take effect. This functions is used to
+// * convert the range where the span is attached to the range in which the span actually take
+// * effect.
+// * E.g. For input text "ab\ncd\ne" where a paragraph span is attached to "ab\nc", the span will
+// * take effect on "ab\ncd". Thus this function will return Pair(0, 5).
+// *
+// * @param text the text where the span is applied on
+// * @param start the inclusive start position of the paragraph span.
+// * @param end the exclusive end position of the paragraph span.
+// * @return a pair of indices which represent the adjusted position of the paragraph span.
+// */
+// private fun adjustSpanPositionForParagraph(
+// text: StringBuilder,
+// start: Int,
+// end: Int
+// ): Pair<Int, Int> {
+// if (text.isEmpty()) return Pair(0, 0)
+// if (end <= start) return Pair(start, start)
+//
+// var spanStart = start.coerceIn(0, text.length - 1)
+// var spanEnd = end.coerceIn(0, text.length)
+//
+// if (text[spanStart] == LINE_FEED) {
+// // The span happens to start with a LINE_FEED; check if the previous char is LINE_FEED.
+// // If not, the spanStart points to the end of a paragraph; skip the LINE_FEED.
+// // Otherwise, the span covers an empty paragraph; won't change start position.
+// if (spanStart > 0 && text[spanStart - 1] != LINE_FEED) {
+// ++spanStart
+// }
+// } else {
+// // The span starts with a non LINE_FEED character, reposition the start to the first
+// // character following a previous LINE_FEED.
+// while (spanStart > 0 && text[spanStart - 1] != LINE_FEED) {
+// --spanStart
+// }
+// }
+//
+// if (spanEnd > 0 && text[spanEnd - 1] == LINE_FEED) {
+// // The span ends with a LINE_FEED; check if the second last char is LINE_FEED.
+// // If not, the spanEnd is pointing to the end of a paragraph; skip the LINE_FEED.
+// // Otherwise, the span covers an empty paragraph; won't change the end position
+// if (spanEnd > 1 && text[spanEnd - 2] != LINE_FEED) {
+// --spanEnd
+// }
+// } else {
+// // The span ends with a non LINE_FEED character, reposition the end to the first
+// // character followed by a LINE_FEED.
+// while (spanEnd < text.length && text[spanEnd] != LINE_FEED) {
+// ++spanEnd
+// }
+// }
+// return Pair(spanStart, spanEnd)
+// }
\ No newline at end of file
diff --git a/ui/text/src/main/java/androidx/ui/painting/ParagraphStyle.kt b/ui/text/src/main/java/androidx/ui/painting/ParagraphStyle.kt
index 04d3a0b..55a2fdc 100644
--- a/ui/text/src/main/java/androidx/ui/painting/ParagraphStyle.kt
+++ b/ui/text/src/main/java/androidx/ui/painting/ParagraphStyle.kt
@@ -36,7 +36,6 @@
data class ParagraphStyle constructor(
val textAlign: TextAlign? = null,
val textDirection: TextDirection? = null,
- // TODO(siyamed) these two are not being applied from ParagraphStyle for now.
val lineHeight: Float? = null,
val textIndent: TextIndent? = null
) {
diff --git a/ui/text/src/main/java/androidx/ui/painting/TextPainter.kt b/ui/text/src/main/java/androidx/ui/painting/TextPainter.kt
index 6d57b0e..953090d 100644
--- a/ui/text/src/main/java/androidx/ui/painting/TextPainter.kt
+++ b/ui/text/src/main/java/androidx/ui/painting/TextPainter.kt
@@ -216,6 +216,8 @@
textAlign = textAlign,
textDirection = textDirection,
textScaleFactor = textScaleFactor,
+ lineHeight = paragraphStyle?.lineHeight,
+ textIndent = paragraphStyle?.textIndent,
maxLines = maxLines,
ellipsis = overflow == TextOverflow.Ellipsis,
locale = locale
diff --git a/ui/text/src/main/java/androidx/ui/painting/TextStyle.kt b/ui/text/src/main/java/androidx/ui/painting/TextStyle.kt
index 65b2036e..f3ef0d7 100644
--- a/ui/text/src/main/java/androidx/ui/painting/TextStyle.kt
+++ b/ui/text/src/main/java/androidx/ui/painting/TextStyle.kt
@@ -38,7 +38,7 @@
private const val _kDefaultDebugLabel: String = "unknown"
/** The default font size if none is specified. */
-private const val _defaultFontSize: Float = 14.0f
+internal const val _defaultFontSize: Float = 14.0f
/**
* Configuration object to define the text style.
@@ -58,13 +58,10 @@
* @param wordSpacing The amount of space (in logical pixels) to add at each sequence of white-space (i.e. between each word). Only works on Android Q and above.
* @param baselineShift This parameter specifies how much the baseline is shifted from the current position.
* @param textGeometricTransform The geometric transformation applied the text.
- * @param lineHeight The line height for this text, as a multiple of the font size.
* @param locale The locale used to select region-specific glyphs.
* @param background The background color for the text.
* @param decoration The decorations to paint near the text (e.g., an underline).
* @param fontFamily The name of the font to use when painting the text (e.g., Roboto).
- * @param textIndent Specify how much a paragraph is indented.
- * @param textAlign Specify how a paragraph is aligned.
* @param shadow The shadow effect applied on the text.
* @param debugLabel A human-readable description of this text style.
*/
@@ -80,13 +77,10 @@
val wordSpacing: Float? = null,
val baselineShift: BaselineShift? = null,
val textGeometricTransform: TextGeometricTransform? = null,
- val lineHeight: Float? = null,
val locale: Locale? = null,
val background: Color? = null,
val decoration: TextDecoration? = null,
var fontFamily: FontFamily? = null,
- val textIndent: TextIndent? = null,
- val textAlign: TextAlign? = null,
val shadow: Shadow? = null,
val debugLabel: String? = null
) {
@@ -127,12 +121,9 @@
wordSpacing = other.wordSpacing ?: this.wordSpacing,
baselineShift = other.baselineShift ?: this.baselineShift,
textGeometricTransform = other.textGeometricTransform ?: this.textGeometricTransform,
- lineHeight = other.lineHeight ?: this.lineHeight,
locale = other.locale ?: this.locale,
background = other.background ?: this.background,
decoration = other.decoration ?: this.decoration,
- textIndent = other.textIndent ?: this.textIndent,
- textAlign = other.textAlign ?: this.textAlign,
shadow = other.shadow ?: this.shadow,
debugLabel = mergedDebugLabel
)
@@ -233,16 +224,9 @@
b.textGeometricTransform ?: TextGeometricTransform.None,
t
),
- lineHeight = lerpFloat(a.lineHeight, b.lineHeight, t),
locale = lerpDiscrete(a.locale, b.locale, t),
background = lerpDiscrete(a.background, b.background, t),
decoration = lerpDiscrete(a.decoration, b.decoration, t),
- textIndent = lerp(
- a.textIndent ?: TextIndent.NONE,
- b.textIndent ?: TextIndent.NONE,
- t
- ),
- textAlign = if (t < 0.5) a.textAlign else b.textAlign,
shadow = lerp(
a.shadow ?: Shadow(),
b.shadow ?: Shadow(),
@@ -269,9 +253,6 @@
wordSpacing = wordSpacing,
baselineShift = baselineShift,
textGeometricTransform = textGeometricTransform,
- textAlign = textAlign,
- lineHeight = lineHeight,
- textIndent = textIndent,
locale = locale,
background = background,
shadow = shadow
@@ -290,6 +271,8 @@
fun getParagraphStyle(
textAlign: TextAlign? = null,
textDirection: TextDirection? = null,
+ textIndent: TextIndent? = null,
+ lineHeight: Float? = null,
textScaleFactor: Float = 1.0f,
ellipsis: Boolean? = null,
maxLines: Int? = null,
@@ -299,12 +282,13 @@
return ParagraphStyle(
textAlign = textAlign,
textDirection = textDirection,
+ textIndent = textIndent,
+ lineHeight = lineHeight,
fontWeight = fontWeight,
fontStyle = fontStyle,
maxLines = maxLines,
fontFamily = fontFamily,
fontSize = (fontSize ?: _defaultFontSize) * textScaleFactor,
- lineHeight = lineHeight,
ellipsis = ellipsis,
locale = locale,
fontSynthesis = fontSynthesis
@@ -333,7 +317,6 @@
wordSpacing != other.wordSpacing ||
baselineShift != other.baselineShift ||
textGeometricTransform != other.textGeometricTransform ||
- lineHeight != other.lineHeight ||
locale != other.locale ||
background != other.background
) {
diff --git a/ui/text/src/test/java/androidx/ui/engine/text/ParagraphStyleTest.kt b/ui/text/src/test/java/androidx/ui/engine/text/ParagraphStyleTest.kt
index b64b6d6..b103e60 100644
--- a/ui/text/src/test/java/androidx/ui/engine/text/ParagraphStyleTest.kt
+++ b/ui/text/src/test/java/androidx/ui/engine/text/ParagraphStyleTest.kt
@@ -16,11 +16,7 @@
package androidx.ui.engine.text
import androidx.ui.engine.text.font.FontFamily
-import androidx.ui.engine.window.Locale
-import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.CoreMatchers.equalTo
-import org.hamcrest.CoreMatchers.not
-import org.hamcrest.CoreMatchers.nullValue
import org.junit.Assert.assertThat
import org.junit.Test
import org.junit.runner.RunWith
@@ -28,145 +24,27 @@
@RunWith(JUnit4::class)
class ParagraphStyleTest {
-
@Test
- fun `toString with null values`() {
+ fun `hasFontAttributes default`() {
val paragraphStyle = ParagraphStyle()
- assertThat(
- paragraphStyle.toString(), `is`(
- equalTo(
- "ParagraphStyle(" +
- "textAlign: unspecified, " +
- "textDirection: unspecified, " +
- "fontWeight: unspecified, " +
- "fontStyle: unspecified, " +
- "maxLines: unspecified, " +
- "fontFamily: unspecified, " +
- "fontSize: unspecified, " +
- "lineHeight: unspecified, " +
- "ellipsis: unspecified, " +
- "locale: unspecified, " +
- "fontSynthesis: unspecified" +
- ")"
- )
- )
- )
+ assertThat(paragraphStyle.hasFontAttributes(), equalTo(false))
}
@Test
- fun `getTextStyle with non-null values`() {
- val textAlign = TextAlign.End
- val textDirection = TextDirection.Rtl
- val fontWeight = FontWeight.bold
- val fontStyle = FontStyle.Italic
- val maxLines = 2
- val fontFamily = FontFamily("sans-serif")
- val fontSize = 1.0f
- val lineHeight = 2.0f
- val ellipsis = true
- val locale = Locale("en")
- val fontSynthesis = FontSynthesis.Style
-
- val paragraphStyle = ParagraphStyle(
- textAlign = textAlign,
- textDirection = textDirection,
- fontWeight = fontWeight,
- fontStyle = fontStyle,
- maxLines = maxLines,
- fontFamily = fontFamily,
- fontSize = fontSize,
- lineHeight = lineHeight,
- ellipsis = ellipsis,
- locale = locale,
- fontSynthesis = fontSynthesis
- )
-
- val textStyle = paragraphStyle.getTextStyle()
- assertThat(textStyle, not(nullValue()))
-
- assertThat(textStyle.fontWeight, equalTo(paragraphStyle.fontWeight))
- assertThat(textStyle.fontStyle, equalTo(paragraphStyle.fontStyle))
- assertThat(textStyle.fontFamily, equalTo(paragraphStyle.fontFamily))
- assertThat(textStyle.fontSize, equalTo(paragraphStyle.fontSize))
- assertThat(textStyle.locale, equalTo(paragraphStyle.locale))
- assertThat(textStyle.lineHeight, equalTo(paragraphStyle.lineHeight))
- assertThat(textStyle.fontSynthesis, equalTo(paragraphStyle.fontSynthesis))
+ fun `hasFontAttributes with fontFamily returns true`() {
+ val paragraphStyle = ParagraphStyle(fontFamily = FontFamily("sans"))
+ assertThat(paragraphStyle.hasFontAttributes(), equalTo(true))
}
@Test
- fun `getTextStyle with null values`() {
- val paragraphStyle = ParagraphStyle(
- textAlign = null,
- textDirection = null,
- fontWeight = null,
- fontStyle = null,
- maxLines = null,
- fontFamily = null,
- fontSize = null,
- lineHeight = null,
- ellipsis = null,
- locale = null,
- fontSynthesis = null
- )
-
- val textStyle = paragraphStyle.getTextStyle()
- assertThat(textStyle, not(nullValue()))
-
- assertThat(textStyle.fontWeight, `is`(nullValue()))
- assertThat(textStyle.fontStyle, `is`(nullValue()))
- assertThat(textStyle.fontFamily, `is`(nullValue()))
- assertThat(textStyle.fontSize, `is`(nullValue()))
- assertThat(textStyle.locale, `is`(nullValue()))
- assertThat(textStyle.lineHeight, `is`(nullValue()))
- assertThat(textStyle.fontSynthesis, `is`(nullValue()))
+ fun `hasFontAttributes with fontStyle returns true`() {
+ val paragraphStyle = ParagraphStyle(fontStyle = FontStyle.Italic)
+ assertThat(paragraphStyle.hasFontAttributes(), equalTo(true))
}
@Test
- fun `toString with values`() {
- val textAlign = TextAlign.End
- val textDirection = TextDirection.Rtl
- val fontWeight = FontWeight.bold
- val fontStyle = FontStyle.Italic
- val maxLines = 2
- val fontFamily = FontFamily("sans-serif")
- val fontSize = 1.0f
- val lineHeight = 2.0f
- val ellipsis = false
- val locale = Locale("en")
- val fontSynthesis = FontSynthesis.Style
-
- val paragraphStyle = ParagraphStyle(
- textAlign = textAlign,
- textDirection = textDirection,
- fontWeight = fontWeight,
- fontStyle = fontStyle,
- maxLines = maxLines,
- fontFamily = fontFamily,
- fontSize = fontSize,
- lineHeight = lineHeight,
- ellipsis = ellipsis,
- locale = locale,
- fontSynthesis = fontSynthesis
- )
-
- assertThat(
- paragraphStyle.toString(), `is`(
- equalTo(
- "ParagraphStyle(" +
- "textAlign: $textAlign, " +
- "textDirection: $textDirection, " +
- "fontWeight: $fontWeight, " +
- "fontStyle: $fontStyle, " +
- "maxLines: $maxLines, " +
- "fontFamily: $fontFamily, " +
- "fontSize: $fontSize, " +
- "lineHeight: ${lineHeight}x, " +
- "ellipsis: \"$ellipsis\", " +
- "locale: $locale, " +
- "fontSynthesis: $fontSynthesis" +
- ")"
- )
- )
- )
+ fun `hasFontAttributes with fontWeight returns true`() {
+ val paragraphStyle = ParagraphStyle(fontWeight = FontWeight.normal)
+ assertThat(paragraphStyle.hasFontAttributes(), equalTo(true))
}
}
\ No newline at end of file
diff --git a/ui/text/src/test/java/androidx/ui/painting/TextPainterTest.kt b/ui/text/src/test/java/androidx/ui/painting/TextPainterTest.kt
index b8d263e..39bffe5 100644
--- a/ui/text/src/test/java/androidx/ui/painting/TextPainterTest.kt
+++ b/ui/text/src/test/java/androidx/ui/painting/TextPainterTest.kt
@@ -208,7 +208,7 @@
val paragraphStyle = textPainter.createParagraphStyle()
- assertThat(paragraphStyle.getTextStyle().fontSize).isNull()
+ assertThat(paragraphStyle.fontSize).isNull()
assertThat(paragraphStyle.textAlign).isEqualTo(TextAlign.Center)
assertThat(paragraphStyle.textDirection).isEqualTo(TextDirection.Rtl)
assertThat(paragraphStyle.maxLines).isEqualTo(maxLines)
@@ -240,7 +240,7 @@
val paragraphStyle = textPainter.createParagraphStyle()
- assertThat(paragraphStyle.getTextStyle().fontSize).isEqualTo(fontSize * scaleFactor)
+ assertThat(paragraphStyle.fontSize).isEqualTo(fontSize * scaleFactor)
assertThat(paragraphStyle.textAlign).isEqualTo(TextAlign.Center)
assertThat(paragraphStyle.textDirection).isEqualTo(TextDirection.Rtl)
assertThat(paragraphStyle.maxLines).isEqualTo(maxLines)
diff --git a/ui/text/src/test/java/androidx/ui/painting/TextSpanTest.kt b/ui/text/src/test/java/androidx/ui/painting/TextSpanTest.kt
index b2c516c..c39e527 100644
--- a/ui/text/src/test/java/androidx/ui/painting/TextSpanTest.kt
+++ b/ui/text/src/test/java/androidx/ui/painting/TextSpanTest.kt
@@ -42,7 +42,7 @@
@Test
fun `constructor with customized style`() {
- val textStyle = TextStyle(fontSize = 10.0f, lineHeight = 123.0f)
+ val textStyle = TextStyle(fontSize = 10.0f, letterSpacing = 1.5f)
val textSpan = TextSpan(style = textStyle)
assertThat(textSpan.style).isEqualTo(textStyle)
@@ -261,7 +261,7 @@
@Test
fun `compareTo with one null style should return LAYOUT`() {
val textSpan1 = TextSpan()
- val textSpan2 = TextSpan(style = TextStyle(lineHeight = 123.0f))
+ val textSpan2 = TextSpan(style = TextStyle(letterSpacing = 1.5f))
assertThat(textSpan1.compareTo(textSpan2)).isEqualTo(RenderComparison.LAYOUT)
}
diff --git a/ui/text/src/test/java/androidx/ui/painting/TextStyleTest.kt b/ui/text/src/test/java/androidx/ui/painting/TextStyleTest.kt
index 5228c08..5e5d0bd 100644
--- a/ui/text/src/test/java/androidx/ui/painting/TextStyleTest.kt
+++ b/ui/text/src/test/java/androidx/ui/painting/TextStyleTest.kt
@@ -27,6 +27,7 @@
import androidx.ui.engine.text.TextDecoration
import androidx.ui.engine.text.TextDirection
import androidx.ui.engine.text.TextGeometricTransform
+import androidx.ui.engine.text.TextIndent
import androidx.ui.engine.text.font.FontFamily
import androidx.ui.engine.text.lerp
import androidx.ui.engine.window.Locale
@@ -50,7 +51,6 @@
assertThat(textStyle.fontStyle).isNull()
assertThat(textStyle.letterSpacing).isNull()
assertThat(textStyle.wordSpacing).isNull()
- assertThat(textStyle.lineHeight).isNull()
assertThat(textStyle.locale).isNull()
assertThat(textStyle.background).isNull()
assertThat(textStyle.decoration).isNull()
@@ -121,15 +121,6 @@
}
@Test
- fun `constructor with customized height`() {
- val height = 123.0f
-
- val textStyle = TextStyle(lineHeight = height)
-
- assertThat(textStyle.lineHeight).isEqualTo(height)
- }
-
- @Test
fun `constructor with customized locale`() {
val locale = Locale("en", "US")
@@ -415,29 +406,29 @@
assertThat(newTextStyle.baselineShift).isEqualTo(otherBaselineShift)
}
- @Test
- fun `merge with other's height is null should use this' height`() {
- val height = 123.0f
- val textStyle = TextStyle(lineHeight = height)
- val otherTextStyle = TextStyle()
-
- val newTextStyle = textStyle.merge(otherTextStyle)
-
- assertThat(newTextStyle.lineHeight).isEqualTo(height)
- }
-
- @Test
- fun `merge with other's height is set should use other's height`() {
- val height = 123.0f
- val otherHeight = 200.0f
- val textStyle = TextStyle(lineHeight = height)
- val otherTextStyle = TextStyle(lineHeight = otherHeight)
-
- val newTextStyle = textStyle.merge(otherTextStyle)
-
- assertThat(newTextStyle.lineHeight).isEqualTo(otherHeight)
- }
-
+// @Test
+// fun `merge with other's height is null should use this' height`() {
+// val height = 123.0f
+// val textStyle = TextStyle(lineHeight = height)
+// val otherTextStyle = TextStyle()
+//
+// val newTextStyle = textStyle.merge(otherTextStyle)
+//
+// assertThat(newTextStyle.lineHeight).isEqualTo(height)
+// }
+//
+// @Test
+// fun `merge with other's height is set should use other's height`() {
+// val height = 123.0f
+// val otherHeight = 200.0f
+// val textStyle = TextStyle(lineHeight = height)
+// val otherTextStyle = TextStyle(lineHeight = otherHeight)
+//
+// val newTextStyle = textStyle.merge(otherTextStyle)
+//
+// assertThat(newTextStyle.lineHeight).isEqualTo(otherHeight)
+// }
+//
@Test
fun `merge with other's background is null should use this' background`() {
val color = Color(0xFF00FF00.toInt())
@@ -1146,29 +1137,29 @@
assertThat(newTextStyle?.letterSpacing).isNull()
}
- @Test
- fun `lerp letterSpacing with a and b are not Null`() {
- val letterSpacing1 = 1.0f
- val letterSpacing2 = 3.0f
- val t = 0.8f
- val textStyle1 = TextStyle(
- fontSize = 4.0f,
- wordSpacing = 1.0f,
- letterSpacing = letterSpacing1,
- lineHeight = 123.0f
- )
- val textStyle2 = TextStyle(
- fontSize = 7.0f,
- wordSpacing = 2.0f,
- letterSpacing = letterSpacing2,
- lineHeight = 20.0f
- )
-
- val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
-
- // a + (b - a) * t = 1.0f + (3.0f - 1.0f) * 0.8f = 2.6f
- assertThat(newTextStyle?.letterSpacing).isEqualTo(2.6f)
- }
+// @Test
+// fun `lerp letterSpacing with a and b are not Null`() {
+// val letterSpacing1 = 1.0f
+// val letterSpacing2 = 3.0f
+// val t = 0.8f
+// val textStyle1 = TextStyle(
+// fontSize = 4.0f,
+// wordSpacing = 1.0f,
+// letterSpacing = letterSpacing1,
+// lineHeight = 123.0f
+// )
+// val textStyle2 = TextStyle(
+// fontSize = 7.0f,
+// wordSpacing = 2.0f,
+// letterSpacing = letterSpacing2,
+// lineHeight = 20.0f
+// )
+//
+// val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
+//
+// // a + (b - a) * t = 1.0f + (3.0f - 1.0f) * 0.8f = 2.6f
+// assertThat(newTextStyle?.letterSpacing).isEqualTo(2.6f)
+// }
@Test
fun `lerp wordSpacing with a is Null and t is smaller than half`() {
@@ -1214,30 +1205,30 @@
assertThat(newTextStyle?.wordSpacing).isNull()
}
- @Test
- fun `lerp wordSpacing with a and b are not Null`() {
- val wordSpacing1 = 1.0f
- val wordSpacing2 = 3.0f
- val t = 0.8f
- val textStyle1 = TextStyle(
- fontSize = 4.0f,
- wordSpacing = wordSpacing1,
- letterSpacing = 2.2f,
- lineHeight = 123.0f
- )
- val textStyle2 = TextStyle(
- fontSize = 7.0f,
- wordSpacing = wordSpacing2,
- letterSpacing = 3.0f,
- lineHeight = 20.0f
- )
-
- val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
-
- // a + (b - a) * t = 1.0f + (3.0f - 1.0f) * 0.8f = 2.6f
- assertThat(newTextStyle?.wordSpacing).isEqualTo(2.6f)
- }
-
+// @Test
+// fun `lerp wordSpacing with a and b are not Null`() {
+// val wordSpacing1 = 1.0f
+// val wordSpacing2 = 3.0f
+// val t = 0.8f
+// val textStyle1 = TextStyle(
+// fontSize = 4.0f,
+// wordSpacing = wordSpacing1,
+// letterSpacing = 2.2f,
+// lineHeight = 123.0f
+// )
+// val textStyle2 = TextStyle(
+// fontSize = 7.0f,
+// wordSpacing = wordSpacing2,
+// letterSpacing = 3.0f,
+// lineHeight = 20.0f
+// )
+//
+// val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
+//
+// // a + (b - a) * t = 1.0f + (3.0f - 1.0f) * 0.8f = 2.6f
+// assertThat(newTextStyle?.wordSpacing).isEqualTo(2.6f)
+// }
+//
@Test
fun `lerp baselineShift with a is Null and t is smaller than half`() {
val baselineShift = BaselineShift.Superscript
@@ -1354,63 +1345,63 @@
.isEqualTo(lerp(textTransform1, textTransform2, t))
}
- @Test
- fun `lerp height with a is Null and t is smaller than half`() {
- val height = 88.0f
- val t = 0.2f
- val textStyle = TextStyle(lineHeight = height)
-
- val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
-
- assertThat(newTextStyle?.lineHeight).isNull()
- }
-
- @Test
- fun `lerp height with a is Null and t is larger than half`() {
- val height = 88.0f
- val t = 0.8f
- val textStyle = TextStyle(lineHeight = height)
-
- val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
-
- assertThat(newTextStyle?.lineHeight).isEqualTo(height)
- }
-
- @Test
- fun `lerp height with b is Null and t is smaller than half`() {
- val height = 88.0f
- val t = 0.2f
- val textStyle = TextStyle(lineHeight = height)
-
- val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
-
- assertThat(newTextStyle?.lineHeight).isEqualTo(height)
- }
-
- @Test
- fun `lerp height with b is Null and t is larger than half`() {
- val height = 88.0f
- val t = 0.8f
- val textStyle = TextStyle(lineHeight = height)
-
- val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
-
- assertThat(newTextStyle?.lineHeight).isNull()
- }
-
- @Test
- fun `lerp height with a and b are not Null`() {
- val height1 = 88.0f
- val height2 = 128.0f
- val t = 0.8f
- val textStyle1 = TextStyle(lineHeight = height1)
- val textStyle2 = TextStyle(lineHeight = height2)
-
- val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
-
- // a + (b - a) * t = 88.0 + (128.0 - 88.0) * 0.8 = 120.0
- assertThat(newTextStyle?.lineHeight).isEqualTo(120.0f)
- }
+// @Test
+// fun `lerp height with a is Null and t is smaller than half`() {
+// val height = 88.0f
+// val t = 0.2f
+// val textStyle = TextStyle(lineHeight = height)
+//
+// val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
+//
+// assertThat(newTextStyle?.lineHeight).isNull()
+// }
+//
+// @Test
+// fun `lerp height with a is Null and t is larger than half`() {
+// val height = 88.0f
+// val t = 0.8f
+// val textStyle = TextStyle(lineHeight = height)
+//
+// val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
+//
+// assertThat(newTextStyle?.lineHeight).isEqualTo(height)
+// }
+//
+// @Test
+// fun `lerp height with b is Null and t is smaller than half`() {
+// val height = 88.0f
+// val t = 0.2f
+// val textStyle = TextStyle(lineHeight = height)
+//
+// val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
+//
+// assertThat(newTextStyle?.lineHeight).isEqualTo(height)
+// }
+//
+// @Test
+// fun `lerp height with b is Null and t is larger than half`() {
+// val height = 88.0f
+// val t = 0.8f
+// val textStyle = TextStyle(lineHeight = height)
+//
+// val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
+//
+// assertThat(newTextStyle?.lineHeight).isNull()
+// }
+//
+// @Test
+// fun `lerp height with a and b are not Null`() {
+// val height1 = 88.0f
+// val height2 = 128.0f
+// val t = 0.8f
+// val textStyle1 = TextStyle(lineHeight = height1)
+// val textStyle2 = TextStyle(lineHeight = height2)
+//
+// val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
+//
+// // a + (b - a) * t = 88.0 + (128.0 - 88.0) * 0.8 = 120.0
+// assertThat(newTextStyle?.lineHeight).isEqualTo(120.0f)
+// }
@Test
fun `lerp locale with a is Null and t is smaller than half`() {
@@ -1675,7 +1666,6 @@
@Test
fun `getTextStyle`() {
val fontSize = 10.0f
- val height = 123.0f
val color = Color(0xFF00FF00.toInt())
val fontSynthesis = FontSynthesis.Style
val fontFeatureSettings = "\"kern\" 0"
@@ -1684,7 +1674,6 @@
fontSize = fontSize,
fontWeight = FontWeight.w800,
color = color,
- lineHeight = height,
fontSynthesis = fontSynthesis,
fontFeatureSettings = fontFeatureSettings,
baselineShift = baselineShift
@@ -1693,7 +1682,6 @@
assertThat(textStyle.fontFamily).isNull()
assertThat(textStyle.fontSize).isEqualTo(fontSize)
assertThat(textStyle.fontWeight).isEqualTo(FontWeight.w800)
- assertThat(textStyle.lineHeight).isEqualTo(height)
assertThat(textStyle.color).isEqualTo(color)
assertThat(textStyle.fontFeatureSettings).isEqualTo(fontFeatureSettings)
@@ -1704,7 +1692,6 @@
color = color,
fontWeight = FontWeight.w800,
fontSize = fontSize,
- lineHeight = height,
fontSynthesis = fontSynthesis,
fontFeatureSettings = fontFeatureSettings,
baselineShift = baselineShift
@@ -1715,21 +1702,18 @@
@Test
fun `getParagraphStyle with text align`() {
val fontSize = 10.0f
- val height = 123.0f
val color = Color(0xFF00FF00.toInt())
val fontSynthesis = FontSynthesis.Style
val textStyle = TextStyle(
fontSize = fontSize,
fontWeight = FontWeight.w800,
color = color,
- lineHeight = height,
fontSynthesis = fontSynthesis
)
assertThat(textStyle.fontFamily).isNull()
assertThat(textStyle.fontSize).isEqualTo(fontSize)
assertThat(textStyle.fontWeight).isEqualTo(FontWeight.w800)
- assertThat(textStyle.lineHeight).isEqualTo(height)
assertThat(textStyle.color).isEqualTo(color)
val paragraphStyle = textStyle.getParagraphStyle(textAlign = TextAlign.Center)
@@ -1739,7 +1723,6 @@
textAlign = TextAlign.Center,
fontWeight = FontWeight.w800,
fontSize = fontSize,
- lineHeight = height,
fontSynthesis = fontSynthesis
)
)
@@ -1747,28 +1730,52 @@
@Test
fun `getParagraphStyle with LTR text direction`() {
- val defaultFontSize = 14.0f
+ val paragraphStyle = TextStyle().getParagraphStyle(textDirection = TextDirection.Ltr)
- val paragraphStyleLTR = TextStyle().getParagraphStyle(textDirection = TextDirection.Ltr)
-
- assertThat(paragraphStyleLTR).isEqualTo(
+ assertThat(paragraphStyle).isEqualTo(
ParagraphStyle(
textDirection = TextDirection.Ltr,
- fontSize = defaultFontSize
+ fontSize = _defaultFontSize
+ )
+ )
+ }
+
+ @Test
+ fun `getParagraphStyle with line height`() {
+ val lineHeight = 1.2f
+
+ val paragraphStyle = TextStyle().getParagraphStyle(lineHeight = lineHeight)
+
+ assertThat(paragraphStyle).isEqualTo(
+ ParagraphStyle(
+ lineHeight = lineHeight,
+ fontSize = _defaultFontSize
+ )
+ )
+ }
+
+ @Test
+ fun `getParagraphStyle with text indent`() {
+ val textIndent = TextIndent(firstLine = 10.px, restLine = 11.px)
+
+ val paragraphStyle = TextStyle().getParagraphStyle(textIndent = textIndent)
+
+ assertThat(paragraphStyle).isEqualTo(
+ ParagraphStyle(
+ textIndent = textIndent,
+ fontSize = _defaultFontSize
)
)
}
@Test
fun `getParagraphStyle with RTL text direction`() {
- val defaultFontSize = 14.0f
+ val paragraphStyle = TextStyle().getParagraphStyle(textDirection = TextDirection.Rtl)
- val paragraphStyleRTL = TextStyle().getParagraphStyle(textDirection = TextDirection.Rtl)
-
- assertThat(paragraphStyleRTL).isEqualTo(
+ assertThat(paragraphStyle).isEqualTo(
ParagraphStyle(
textDirection = TextDirection.Rtl,
- fontSize = defaultFontSize
+ fontSize = _defaultFontSize
)
)
}
@@ -1805,7 +1812,6 @@
@Test
fun `compareTo textStyle with different layout returns LAYOUT`() {
val fontSize = 10.0f
- val height = 123.0f
val bgColor = Color(0xFFFFFF00.toInt())
val fontFeatureSettings = "\"kern\" 0"
@@ -1819,7 +1825,6 @@
wordSpacing = 2.0f,
baselineShift = BaselineShift.Subscript,
textGeometricTransform = TextGeometricTransform(scaleX = 1.0f),
- lineHeight = height,
locale = Locale("en", "US"),
background = bgColor,
decoration = TextDecoration.Underline,
@@ -1862,9 +1867,6 @@
.copy(textGeometricTransform = TextGeometricTransform())))
.isEqualTo(RenderComparison.LAYOUT)
- assertThat(textStyle.compareTo(textStyle.copy(lineHeight = 20.0f)))
- .isEqualTo(RenderComparison.LAYOUT)
-
assertThat(textStyle.compareTo(textStyle.copy(locale = Locale("ja", "JP"))))
.isEqualTo(RenderComparison.LAYOUT)
}
@@ -1872,7 +1874,6 @@
@Test
fun `compareTo textStyle with different paint returns paint`() {
val fontSize = 10.0f
- val height = 123.0f
val color1 = Color(0xFF00FF00.toInt())
val color2 = Color(0x00FFFF00)
@@ -1888,7 +1889,6 @@
wordSpacing = 2.0f,
baselineShift = BaselineShift.Superscript,
textGeometricTransform = TextGeometricTransform(null, null),
- lineHeight = height,
locale = Locale("en", "US"),
decoration = TextDecoration.Underline,
debugLabel = "foo",