Add relative fontSize
Add relative fontSize. Plus, fixed document format issue in TextStyle.
Bug: 132994744
Test: ./gradlew test
Test: ./gradlew connectedAndroidTest
Change-Id: I568a9f28566077c7105cb23b0965d7fc39e90a7e
diff --git a/ui/text/api/1.0.0-alpha01.txt b/ui/text/api/1.0.0-alpha01.txt
index 0415261..c48cc92 100644
--- a/ui/text/api/1.0.0-alpha01.txt
+++ b/ui/text/api/1.0.0-alpha01.txt
@@ -230,27 +230,28 @@
}
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, String? fontFeatureSettings, Float? letterSpacing, Float? wordSpacing, androidx.ui.engine.text.BaselineShift? baselineShift, androidx.ui.engine.text.TextGeometricTransform? textGeometricTransform, Float? height, 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, Float? height, 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();
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.FontSynthesis? component15();
- method public androidx.ui.engine.text.TextIndent? component16();
- method public androidx.ui.engine.text.TextAlign? component17();
- method public androidx.ui.painting.Shadow? component18();
+ 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.text.TextDecoration? component2();
method public androidx.ui.engine.text.FontWeight? component3();
method public androidx.ui.engine.text.FontStyle? component4();
method public androidx.ui.engine.text.font.FontFamily? component5();
method public Float? component6();
- method public String? component7();
- method public Float? component8();
+ 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, String? fontFeatureSettings, Float? letterSpacing, Float? wordSpacing, androidx.ui.engine.text.BaselineShift? baselineShift, androidx.ui.engine.text.TextGeometricTransform? textGeometricTransform, Float? height, 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, Float? height, 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.graphics.Color? getBackground();
method public androidx.ui.engine.text.BaselineShift? getBaselineShift();
method public androidx.ui.graphics.Color? getColor();
@@ -258,6 +259,7 @@
method public androidx.ui.engine.text.font.FontFamily? getFontFamily();
method public String? getFontFeatureSettings();
method public Float? getFontSize();
+ method public Float? getFontSizeScale();
method public androidx.ui.engine.text.FontStyle? getFontStyle();
method public androidx.ui.engine.text.FontSynthesis? getFontSynthesis();
method public androidx.ui.engine.text.FontWeight? getFontWeight();
@@ -484,29 +486,30 @@
}
public final class TextStyle {
- ctor public TextStyle(androidx.ui.graphics.Color? color, Float? fontSize, 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? height, 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, Float? height, 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();
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.TextGeometricTransform? component10();
- method public Float? component11();
- 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.engine.text.TextIndent? component16();
- method public androidx.ui.engine.text.TextAlign? component17();
- method public androidx.ui.painting.Shadow? component18();
- method public String? component19();
+ 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 Float? component2();
- method public androidx.ui.engine.text.FontWeight? component3();
- method public androidx.ui.engine.text.FontStyle? component4();
- method public androidx.ui.engine.text.FontSynthesis? component5();
- method public String? component6();
- method public Float? component7();
+ method public String? component20();
+ method public Float? component3();
+ method public androidx.ui.engine.text.FontWeight? component4();
+ method public androidx.ui.engine.text.FontStyle? component5();
+ method public androidx.ui.engine.text.FontSynthesis? component6();
+ method public String? component7();
method public Float? component8();
- method public androidx.ui.engine.text.BaselineShift? component9();
- method public androidx.ui.painting.TextStyle copy(androidx.ui.graphics.Color? color, Float? fontSize, 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? height, 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 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? height, 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.graphics.Color? getBackground();
method public androidx.ui.engine.text.BaselineShift? getBaselineShift();
method public androidx.ui.graphics.Color? getColor();
@@ -515,6 +518,7 @@
method public androidx.ui.engine.text.font.FontFamily? getFontFamily();
method public String? getFontFeatureSettings();
method public Float? getFontSize();
+ method public Float? getFontSizeScale();
method public androidx.ui.engine.text.FontStyle? getFontStyle();
method public androidx.ui.engine.text.FontSynthesis? getFontSynthesis();
method public androidx.ui.engine.text.FontWeight? getFontWeight();
diff --git a/ui/text/api/current.txt b/ui/text/api/current.txt
index 0415261..c48cc92 100644
--- a/ui/text/api/current.txt
+++ b/ui/text/api/current.txt
@@ -230,27 +230,28 @@
}
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, String? fontFeatureSettings, Float? letterSpacing, Float? wordSpacing, androidx.ui.engine.text.BaselineShift? baselineShift, androidx.ui.engine.text.TextGeometricTransform? textGeometricTransform, Float? height, 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, Float? height, 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();
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.FontSynthesis? component15();
- method public androidx.ui.engine.text.TextIndent? component16();
- method public androidx.ui.engine.text.TextAlign? component17();
- method public androidx.ui.painting.Shadow? component18();
+ 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.text.TextDecoration? component2();
method public androidx.ui.engine.text.FontWeight? component3();
method public androidx.ui.engine.text.FontStyle? component4();
method public androidx.ui.engine.text.font.FontFamily? component5();
method public Float? component6();
- method public String? component7();
- method public Float? component8();
+ 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, String? fontFeatureSettings, Float? letterSpacing, Float? wordSpacing, androidx.ui.engine.text.BaselineShift? baselineShift, androidx.ui.engine.text.TextGeometricTransform? textGeometricTransform, Float? height, 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, Float? height, 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.graphics.Color? getBackground();
method public androidx.ui.engine.text.BaselineShift? getBaselineShift();
method public androidx.ui.graphics.Color? getColor();
@@ -258,6 +259,7 @@
method public androidx.ui.engine.text.font.FontFamily? getFontFamily();
method public String? getFontFeatureSettings();
method public Float? getFontSize();
+ method public Float? getFontSizeScale();
method public androidx.ui.engine.text.FontStyle? getFontStyle();
method public androidx.ui.engine.text.FontSynthesis? getFontSynthesis();
method public androidx.ui.engine.text.FontWeight? getFontWeight();
@@ -484,29 +486,30 @@
}
public final class TextStyle {
- ctor public TextStyle(androidx.ui.graphics.Color? color, Float? fontSize, 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? height, 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, Float? height, 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();
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.TextGeometricTransform? component10();
- method public Float? component11();
- 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.engine.text.TextIndent? component16();
- method public androidx.ui.engine.text.TextAlign? component17();
- method public androidx.ui.painting.Shadow? component18();
- method public String? component19();
+ 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 Float? component2();
- method public androidx.ui.engine.text.FontWeight? component3();
- method public androidx.ui.engine.text.FontStyle? component4();
- method public androidx.ui.engine.text.FontSynthesis? component5();
- method public String? component6();
- method public Float? component7();
+ method public String? component20();
+ method public Float? component3();
+ method public androidx.ui.engine.text.FontWeight? component4();
+ method public androidx.ui.engine.text.FontStyle? component5();
+ method public androidx.ui.engine.text.FontSynthesis? component6();
+ method public String? component7();
method public Float? component8();
- method public androidx.ui.engine.text.BaselineShift? component9();
- method public androidx.ui.painting.TextStyle copy(androidx.ui.graphics.Color? color, Float? fontSize, 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? height, 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 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? height, 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.graphics.Color? getBackground();
method public androidx.ui.engine.text.BaselineShift? getBaselineShift();
method public androidx.ui.graphics.Color? getColor();
@@ -515,6 +518,7 @@
method public androidx.ui.engine.text.font.FontFamily? getFontFamily();
method public String? getFontFeatureSettings();
method public Float? getFontSize();
+ method public Float? getFontSizeScale();
method public androidx.ui.engine.text.FontStyle? getFontStyle();
method public androidx.ui.engine.text.FontSynthesis? getFontSynthesis();
method public androidx.ui.engine.text.FontWeight? getFontWeight();
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 3c786fa..9b91ef5 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
@@ -99,6 +99,8 @@
TextDemoSelection()
TagLine(tag = "composable textspan")
TextDemoComposableTextSpan()
+ TagLine(tag = "fontSizeScale")
+ TextDemoFontSizeScale()
}
}
}
@@ -593,3 +595,17 @@
}
}
}
+
+@Composable
+fun TextDemoFontSizeScale() {
+ CraneWrapper {
+ Text {
+ Span(style = TextStyle(fontSize = fontSize8)) {
+ for (i in 4..12 step 4) {
+ val scale = i * 0.1f
+ Span("fontSizeScale=$scale\n", style = TextStyle(fontSizeScale = scale))
+ }
+ }
+ }
+ }
+}
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 9b7fa98..d8a13ca 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
@@ -1100,6 +1100,142 @@
}
@Test
+ fun textStyle_fontSizeScale() {
+ val text = "abcde"
+ val fontSize = 20f
+ val fontSizeScale = 0.5f
+ val textStyle = TextStyle(fontSizeScale = fontSizeScale)
+
+ val paragraph = simpleParagraph(
+ text = text,
+ textStyles = listOf(ParagraphBuilder.TextStyleIndex(textStyle, 0, text.length)),
+ fontSize = fontSize
+ )
+ paragraph.layout(ParagraphConstraints(width = Float.MAX_VALUE))
+ val paragraphImpl = paragraph.paragraphImpl
+
+ assertThat(
+ paragraphImpl.getLineRight(0),
+ equalTo(text.length * fontSize * fontSizeScale)
+ )
+ }
+
+ @Test
+ fun textStyle_fontSizeScaleNested() {
+ val text = "abcde"
+ val fontSize = 20f
+ val fontSizeScale = 0.5f
+ val textStyle = TextStyle(fontSizeScale = fontSizeScale)
+
+ val fontSizeScaleNested = 2f
+ val textStyleNested = TextStyle(fontSizeScale = fontSizeScaleNested)
+
+ val paragraph = simpleParagraph(
+ text = text,
+ textStyles = listOf(
+ ParagraphBuilder.TextStyleIndex(textStyle, 0, text.length),
+ ParagraphBuilder.TextStyleIndex(textStyleNested, 0, text.length)
+ ),
+ fontSize = fontSize
+ )
+ paragraph.layout(ParagraphConstraints(width = Float.MAX_VALUE))
+ val paragraphImpl = paragraph.paragraphImpl
+
+ assertThat(
+ paragraphImpl.getLineRight(0),
+ equalTo(text.length * fontSize * fontSizeScale * fontSizeScaleNested)
+ )
+ }
+
+ @Test
+ fun textStyle_fontSizeScaleWithFontSizeFirst() {
+ val text = "abcde"
+ val paragraphFontSize = 20f
+
+ val fontSize = 30f
+ val fontSizeStyle = TextStyle(fontSize = fontSize)
+
+ val fontSizeScale = 0.5f
+ val fontSizeScaleStyle = TextStyle(fontSizeScale = fontSizeScale)
+
+ val paragraph = simpleParagraph(
+ text = text,
+ textStyles = listOf(
+ ParagraphBuilder.TextStyleIndex(fontSizeStyle, 0, text.length),
+ ParagraphBuilder.TextStyleIndex(fontSizeScaleStyle, 0, text.length)
+ ),
+ fontSize = paragraphFontSize
+ )
+ paragraph.layout(ParagraphConstraints(width = Float.MAX_VALUE))
+ val paragraphImpl = paragraph.paragraphImpl
+
+ assertThat(
+ paragraphImpl.getLineRight(0),
+ equalTo(text.length * fontSize * fontSizeScale)
+ )
+ }
+
+ @Test
+ fun textStyle_fontSizeScaleWithFontSizeSecond() {
+ val text = "abcde"
+ val paragraphFontSize = 20f
+
+ val fontSize = 30f
+ val fontSizeStyle = TextStyle(fontSize = fontSize)
+
+ val fontSizeScale = 0.5f
+ val fontSizeScaleStyle = TextStyle(fontSizeScale = fontSizeScale)
+
+ val paragraph = simpleParagraph(
+ text = text,
+ textStyles = listOf(
+ ParagraphBuilder.TextStyleIndex(fontSizeScaleStyle, 0, text.length),
+ ParagraphBuilder.TextStyleIndex(fontSizeStyle, 0, text.length)
+ ),
+ fontSize = paragraphFontSize
+ )
+ paragraph.layout(ParagraphConstraints(width = Float.MAX_VALUE))
+ val paragraphImpl = paragraph.paragraphImpl
+
+ assertThat(
+ paragraphImpl.getLineRight(0),
+ equalTo(text.length * fontSize)
+ )
+ }
+
+ @Test
+ fun textStyle_fontSizeScaleWithFontSizeNested() {
+ val text = "abcde"
+ val paragraphFontSize = 20f
+
+ val fontSize = 30f
+ val fontSizeStyle = TextStyle(fontSize = fontSize)
+
+ val fontSizeScale1 = 0.5f
+ val fontSizeScaleStyle1 = TextStyle(fontSizeScale = fontSizeScale1)
+
+ val fontSizeScale2 = 2f
+ val fontSizeScaleStyle2 = TextStyle(fontSizeScale = fontSizeScale2)
+
+ val paragraph = simpleParagraph(
+ text = text,
+ textStyles = listOf(
+ ParagraphBuilder.TextStyleIndex(fontSizeScaleStyle1, 0, text.length),
+ ParagraphBuilder.TextStyleIndex(fontSizeStyle, 0, text.length),
+ ParagraphBuilder.TextStyleIndex(fontSizeScaleStyle2, 0, text.length)
+ ),
+ fontSize = paragraphFontSize
+ )
+ paragraph.layout(ParagraphConstraints(width = Float.MAX_VALUE))
+ val paragraphImpl = paragraph.paragraphImpl
+
+ assertThat(
+ paragraphImpl.getLineRight(0),
+ equalTo(text.length * fontSize * fontSizeScale2)
+ )
+ }
+
+ @Test
fun textStyle_setLetterSpacingOnWholeText() {
val text = "abcde"
val fontSize = 20.0f
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 dfd090d..3e0fbc2 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
@@ -7,6 +7,7 @@
import android.text.style.ForegroundColorSpan
import android.text.style.LeadingMarginSpan
import android.text.style.LocaleSpan
+import android.text.style.RelativeSizeSpan
import android.text.style.ScaleXSpan
import android.text.style.StrikethroughSpan
import android.text.style.UnderlineSpan
@@ -296,6 +297,46 @@
}
@Test
+ fun textStyle_setFontSizeScaleOnWholeText() {
+ val text = "abcde"
+ val fontSizeScale = 2.0f
+ val textStyle = TextStyle(fontSizeScale = fontSizeScale)
+
+ val paragraph = simpleParagraph(
+ text = text,
+ textStyles = listOf(ParagraphBuilder.TextStyleIndex(textStyle, 0, text.length))
+ )
+ paragraph.layout(100f)
+
+ assertThat(
+ paragraph.underlyingText,
+ hasSpan(RelativeSizeSpan::class, 0, text.length) {
+ it.sizeChange == fontSizeScale
+ }
+ )
+ }
+
+ @Test
+ fun textStyle_setFontSizeScaleOnPartText() {
+ val text = "abcde"
+ val fontSizeScale = 2.0f
+ val textStyle = TextStyle(fontSizeScale = fontSizeScale)
+
+ val paragraph = simpleParagraph(
+ text = text,
+ textStyles = listOf(ParagraphBuilder.TextStyleIndex(textStyle, 0, "abc".length))
+ )
+ paragraph.layout(100f)
+
+ assertThat(
+ paragraph.underlyingText,
+ hasSpan(RelativeSizeSpan::class, 0, "abc".length) {
+ it.sizeChange == fontSizeScale
+ }
+ )
+ }
+
+ @Test
fun textStyle_setLetterSpacingOnWholeText() {
val text = "abcde"
val letterSpacing = 2.0f
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 9d836e2..f313959 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
@@ -26,28 +26,31 @@
* Creates a new TextStyle object.
*
* @param color The color to use when painting the text. If this is specified, `foreground` must be
- * null.
+ * null.
* @param decoration The decorations to paint near the text (e.g., an underline).
* @param fontWeight The typeface thickness to use when painting the text (e.g., bold).
* @param fontStyle The typeface variant to use when drawing the letters (e.g., italics).
* @param fontFamily The name of the font to use when painting the text (e.g., Roboto).
* @param fontSize The size of glyphs (in logical pixels) to use when painting the text.
+ * @param fontSizeScale The scale factor of the font size. When [fontSize] is also given in this
+ * TextStyle, the final fontSize will be the [fontSize] times this value.
+ * Otherwise, the final fontSize will be the current fontSize times this value.
* @param fontFeatureSettings The advanced typography settings provided by font. The format is the same as the CSS font-feature-settings attribute:
- * https://www.w3.org/TR/css-fonts-3/#font-feature-settings-prop
+ * https://www.w3.org/TR/css-fonts-3/#font-feature-settings-prop
* @param letterSpacing The amount of space (in EM) to add between each letter.
* @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.
+ * (i.e. between each word). Only works on Android Q and above.
* @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.
+ * 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 height The height of this text span, 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.
+ * 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.
+ * 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.
*/
@@ -58,6 +61,7 @@
val fontStyle: FontStyle? = null,
val fontFamily: FontFamily? = null,
val fontSize: Float? = null,
+ val fontSizeScale: Float? = null,
val fontFeatureSettings: String? = null,
val letterSpacing: Float? = null,
val wordSpacing: Float? = null,
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 e7a964e..ebe7230 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
@@ -26,6 +26,7 @@
import android.text.style.ForegroundColorSpan
import android.text.style.LeadingMarginSpan
import android.text.style.LocaleSpan
+import android.text.style.RelativeSizeSpan
import android.text.style.ScaleXSpan
import android.text.style.StrikethroughSpan
import android.text.style.UnderlineSpan
@@ -424,6 +425,16 @@
)
}
+ // Be aware that fontSizeScale must be applied after fontSize.
+ style.fontSizeScale?.let {
+ spannableString.setSpan(
+ RelativeSizeSpan(it),
+ start,
+ end,
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
+ )
+ }
+
style.fontFeatureSettings?.let {
spannableString.setSpan(
FontFeatureSpan(it),
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 944434a..4d4250a 100644
--- a/ui/text/src/main/java/androidx/ui/painting/TextStyle.kt
+++ b/ui/text/src/main/java/androidx/ui/painting/TextStyle.kt
@@ -45,12 +45,15 @@
*
* @param color The color to use when painting the text. If this is specified, `foreground` must be null.
* @param fontSize The size of glyphs (in logical pixels) to use when painting the text.
+ * @param fontSizeScale The scale factor of the font size. When [fontSize] is also given in this
+ * TextStyle, the final fontSize will be the [fontSize] times this value.
+ * Otherwise, the final fontSize will be the current fontSize times this value.
* @param fontWeight The typeface thickness to use when painting the text (e.g., bold).
* @param fontStyle The typeface variant to use when drawing the letters (e.g., italics).
* @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.
+ * style cannot be found in the provided custom font family.
* @param fontFeatureSettings The advanced typography settings provided by font. The format is the same as the CSS font-feature-settings attribute:
- * https://www.w3.org/TR/css-fonts-3/#font-feature-settings-prop
+ * https://www.w3.org/TR/css-fonts-3/#font-feature-settings-prop
* @param letterSpacing The amount of space (in logical pixels) to add between each letter.
* @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.
@@ -68,6 +71,7 @@
data class TextStyle(
val color: Color? = null,
val fontSize: Float? = null,
+ val fontSizeScale: Float? = null,
val fontWeight: FontWeight? = null,
val fontStyle: FontStyle? = null,
val fontSynthesis: FontSynthesis? = null,
@@ -114,6 +118,7 @@
color = other.color ?: this.color,
fontFamily = other.fontFamily ?: this.fontFamily,
fontSize = other.fontSize ?: this.fontSize,
+ fontSizeScale = other.fontSizeScale ?: this.fontSizeScale,
fontWeight = other.fontWeight ?: this.fontWeight,
fontStyle = other.fontStyle ?: this.fontStyle,
fontSynthesis = other.fontSynthesis ?: this.fontSynthesis,
@@ -215,6 +220,7 @@
color = lerpColor(a.color, b.color, t),
fontFamily = lerpDiscrete(a.fontFamily, b.fontFamily, t),
fontSize = lerpFloat(a.fontSize, b.fontSize, t),
+ fontSizeScale = lerpFloat(a.fontSizeScale, b.fontSizeScale, t, 1f),
fontWeight = FontWeight.lerp(a.fontWeight, b.fontWeight, t),
fontStyle = lerpDiscrete(a.fontStyle, b.fontStyle, t),
fontSynthesis = lerpDiscrete(a.fontSynthesis, b.fontSynthesis, t),
@@ -258,6 +264,7 @@
fontFeatureSettings = fontFeatureSettings,
fontFamily = fontFamily,
fontSize = if (fontSize == null) null else (fontSize * textScaleFactor),
+ fontSizeScale = fontSizeScale,
letterSpacing = letterSpacing,
wordSpacing = wordSpacing,
baselineShift = baselineShift,
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 7d8120f..5c721ff 100644
--- a/ui/text/src/test/java/androidx/ui/painting/TextStyleTest.kt
+++ b/ui/text/src/test/java/androidx/ui/painting/TextStyleTest.kt
@@ -773,6 +773,59 @@
}
@Test
+ fun `lerp fontSizeScale with a and b are not Null`() {
+ val fontSizeScale1 = 2.0f
+ val fontSizeScale2 = 4.0f
+ val t = 0.8f
+ val textStyle1 = TextStyle(fontSizeScale = fontSizeScale1)
+ val textStyle2 = TextStyle(fontSizeScale = fontSizeScale2)
+
+ val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
+
+ // a + (b - a) * t = 2.0f + (4.0f - 2.0f) * 0.8f = 3.6f
+ assertThat(newTextStyle?.fontSizeScale).isEqualTo(3.6f)
+ }
+
+ @Test
+ fun `lerp fontSizeScale with a not Null and b is Null`() {
+ val fontSizeScale = 2.0f
+ val t = 0.8f
+ val textStyle1 = TextStyle(fontSizeScale = fontSizeScale)
+ val textStyle2 = TextStyle()
+
+ val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
+
+ // b is Null and is considered 1.0f
+ // a + (b - a) * t = 2.0f + (1.0f - 2.0f) * 0.8f = 1.2f
+ assertThat(newTextStyle?.fontSizeScale).isEqualTo(1.2f)
+ }
+
+ @Test
+ fun `lerp fontSizeScale with a is Null and b not Null`() {
+ val fontSizeScale = 2.0f
+ val t = 0.8f
+ val textStyle1 = TextStyle()
+ val textStyle2 = TextStyle(fontSizeScale = fontSizeScale)
+
+ val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
+
+ // a is Null and is considered 1.0f
+ // a + (b - a) * t = 1.0f + (2.0f - 1.0f) * 0.8f = 1.8f
+ assertThat(newTextStyle?.fontSizeScale).isEqualTo(1.8f)
+ }
+
+ @Test
+ fun `lerp fontSizeScale with a and b are Null`() {
+ val t = 0.8f
+ val textStyle1 = TextStyle()
+ val textStyle2 = TextStyle()
+
+ val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
+
+ assertThat(newTextStyle?.fontSizeScale).isNull()
+ }
+
+ @Test
fun `lerp fontWeight with a is Null and t is smaller than half`() {
val fontWeight = FontWeight.w700
val t = 0.3f