[go: nahoru, domu]

Use our Locale instead of java.util.Locale everywhere

Here is the result of LocaleList construction cost:

benchmark:        16,409 ns LocaleListBenchmark.create[en-US]
benchmark:        32,470 ns LocaleListBenchmark.create[en-US,ja-JP]
benchmark:        47,791 ns LocaleListBenchmark.create[en-US,ja-JP,zh-CH]
benchmark:        62,738 ns LocaleListBenchmark.create[en-US,ja-JP,zh-CH,zh-TW]
benchmark:        77,677 ns LocaleListBenchmark.create[en-US,ja-JP,zh-CH,zh-TW,sr-Latn-SR]

Bug: 139312607
Bug: 122478208
Test: ./gradlew test
Change-Id: I8f20910323e6338fe483efdc65405b2a587e7715
diff --git a/ui/ui-text/src/androidTest/java/androidx/ui/text/MultiParagraphIntegrationTest.kt b/ui/ui-text/src/androidTest/java/androidx/ui/text/MultiParagraphIntegrationTest.kt
index 7f8dc48..3dd32a6 100644
--- a/ui/ui-text/src/androidTest/java/androidx/ui/text/MultiParagraphIntegrationTest.kt
+++ b/ui/ui-text/src/androidTest/java/androidx/ui/text/MultiParagraphIntegrationTest.kt
@@ -42,7 +42,6 @@
 import org.junit.Test
 import org.junit.runner.RunWith
 import org.junit.runners.JUnit4
-import java.util.Locale
 
 @RunWith(JUnit4::class)
 @SmallTest
@@ -2484,7 +2483,7 @@
         textStyles: List<AnnotatedString.Item<TextStyle>> = listOf(),
         paragraphStyles: List<AnnotatedString.Item<ParagraphStyle>> = listOf(),
         fontFamily: FontFamily = fontFamilyMeasureFont,
-        locale: Locale? = null,
+        localeList: LocaleList? = null,
         textStyle: TextStyle? = null,
         density: Density? = null,
         layoutDirection: LayoutDirection = LayoutDirection.Ltr,
@@ -2499,7 +2498,7 @@
             textStyle = TextStyle(
                 fontFamily = fontFamily,
                 fontSize = fontSize,
-                locale = locale
+                localeList = localeList
             ).merge(textStyle),
             paragraphStyle = ParagraphStyle(
                 textIndent = textIndent,
diff --git a/ui/ui-text/src/androidTest/java/androidx/ui/text/ParagraphIntegrationTest.kt b/ui/ui-text/src/androidTest/java/androidx/ui/text/ParagraphIntegrationTest.kt
index e7b570f..902b432 100644
--- a/ui/ui-text/src/androidTest/java/androidx/ui/text/ParagraphIntegrationTest.kt
+++ b/ui/ui-text/src/androidTest/java/androidx/ui/text/ParagraphIntegrationTest.kt
@@ -54,7 +54,6 @@
 import org.junit.runner.RunWith
 import org.junit.runners.JUnit4
 import org.mockito.Mockito.mock
-import java.util.Locale
 import kotlin.math.roundToInt
 
 @RunWith(JUnit4::class)
@@ -1607,19 +1606,19 @@
             val fontSizeInPx = fontSize.toPx().value
             val locales = arrayOf(
                 // duplicate ja is on purpose
-                Locale("ja"),
-                Locale("ja"),
-                Locale("zh", "CN"),
-                Locale("zh", "TW")
+                LocaleList("ja"),
+                LocaleList("ja"),
+                LocaleList("zh-CN"),
+                LocaleList("zh-TW")
             )
 
-            val bitmaps = locales.map { locale ->
+            val bitmaps = locales.map { localeList ->
                 val paragraph = Paragraph(
                     text = text,
                     textStyles = listOf(),
                     style = TextStyle(
                         fontSize = fontSize,
-                        locale = locale
+                        localeList = localeList
                     ),
                     paragraphStyle = ParagraphStyle(),
                     density = defaultDensity,
@@ -3271,7 +3270,7 @@
         lineHeight: Float? = null,
         textStyles: List<AnnotatedString.Item<TextStyle>> = listOf(),
         fontFamily: FontFamily = fontFamilyMeasureFont,
-        locale: Locale? = null,
+        localeList: LocaleList? = null,
         textStyle: TextStyle? = null,
         density: Density? = null,
         textDirectionAlgorithm: TextDirectionAlgorithm? = null,
@@ -3283,7 +3282,7 @@
             style = TextStyle(
                 fontFamily = fontFamily,
                 fontSize = fontSize,
-                locale = locale
+                localeList = localeList
             ).merge(textStyle),
             paragraphStyle = ParagraphStyle(
                 textIndent = textIndent,
diff --git a/ui/ui-text/src/androidTest/java/androidx/ui/text/platform/AndroidParagraphTest.kt b/ui/ui-text/src/androidTest/java/androidx/ui/text/platform/AndroidParagraphTest.kt
index de877a2..8c017e3 100644
--- a/ui/ui-text/src/androidTest/java/androidx/ui/text/platform/AndroidParagraphTest.kt
+++ b/ui/ui-text/src/androidTest/java/androidx/ui/text/platform/AndroidParagraphTest.kt
@@ -49,6 +49,8 @@
 import androidx.ui.text.matchers.hasSpanOnTop
 import androidx.ui.text.AnnotatedString
 import androidx.ui.painting.Shadow
+import androidx.ui.text.Locale
+import androidx.ui.text.LocaleList
 import androidx.ui.text.ParagraphStyle
 import androidx.ui.text.TestFontResourceLoader
 import androidx.ui.text.TextStyle
@@ -70,7 +72,6 @@
 import org.junit.Test
 import org.junit.runner.RunWith
 import org.junit.runners.JUnit4
-import java.util.Locale
 import kotlin.math.ceil
 
 @RunWith(JUnit4::class)
@@ -482,8 +483,8 @@
     @Test
     fun testAnnotatedString_setLocaleOnWholeText() {
         val text = "abcde"
-        val locale = Locale("en", "US")
-        val textStyle = TextStyle(locale = locale)
+        val localeList = LocaleList("en-US")
+        val textStyle = TextStyle(localeList = localeList)
 
         val paragraph = simpleParagraph(
             text = text,
@@ -497,8 +498,8 @@
     @Test
     fun testAnnotatedString_setLocaleOnPartText() {
         val text = "abcde"
-        val locale = Locale("en", "US")
-        val textStyle = TextStyle(locale = locale)
+        val localeList = LocaleList("en-US")
+        val textStyle = TextStyle(localeList = localeList)
 
         val paragraph = simpleParagraph(
             text = text,
@@ -512,8 +513,8 @@
     @Test
     fun testAnnotatedString_setLocaleTwice_lastOneOverwrite() {
         val text = "abcde"
-        val textStyle = TextStyle(locale = Locale("en", "US"))
-        val textStyleOverwrite = TextStyle(locale = Locale("ja", "JP"))
+        val textStyle = TextStyle(localeList = LocaleList("en-US"))
+        val textStyleOverwrite = TextStyle(localeList = LocaleList("ja-JP"))
 
         val paragraph = simpleParagraph(
             text = text,
@@ -1068,16 +1069,17 @@
 
     @Test
     fun testTextStyle_locale_appliedOnTextPaint() {
-        val systemLocale = java.util.Locale.JAPANESE
-        val locale = Locale(systemLocale.language, systemLocale.country)
+        val platformLocale = java.util.Locale.JAPANESE
+        val localeList = LocaleList(platformLocale.toLanguageTag())
 
         val paragraph = simpleParagraph(
             text = "",
-            textStyle = TextStyle(locale = locale)
+            textStyle = TextStyle(localeList = localeList)
         )
         paragraph.layout(ParagraphConstraints(width = 0.0f))
 
-        assertThat(paragraph.textPaint.textLocale, equalTo(systemLocale))
+        assertThat(paragraph.textPaint.textLocale.language, equalTo(platformLocale.language))
+        assertThat(paragraph.textPaint.textLocale.country, equalTo(platformLocale.country))
     }
 
     @Test
@@ -1224,11 +1226,11 @@
 
     @Test
     fun locale_isSetOnParagraphImpl_enUS() {
-        val locale = Locale("en", "US")
+        val localeList = LocaleList("en-US")
         val text = "abc"
         val paragraph = simpleParagraph(
             text = text,
-            textStyle = TextStyle(locale = locale)
+            textStyle = TextStyle(localeList = localeList)
         )
 
         paragraph.layout(ParagraphConstraints(width = Float.MAX_VALUE))
@@ -1238,11 +1240,11 @@
 
     @Test
     fun locale_isSetOnParagraphImpl_jpJP() {
-        val locale = Locale("ja", "JP")
+        val localeList = LocaleList("ja-JP")
         val text = "abc"
         val paragraph = simpleParagraph(
             text = text,
-            textStyle = TextStyle(locale = locale)
+            textStyle = TextStyle(localeList = localeList)
         )
 
         paragraph.layout(ParagraphConstraints(width = Float.MAX_VALUE))
@@ -1252,11 +1254,11 @@
 
     @Test
     fun locale_noCountryCode_isSetOnParagraphImpl() {
-        val locale = Locale("ja")
+        val localeList = LocaleList("ja")
         val text = "abc"
         val paragraph = simpleParagraph(
             text = text,
-            textStyle = TextStyle(locale = locale)
+            textStyle = TextStyle(localeList = localeList)
         )
 
         paragraph.layout(ParagraphConstraints(width = Float.MAX_VALUE))
diff --git a/ui/ui-text/src/main/java/androidx/ui/text/TextDelegate.kt b/ui/ui-text/src/main/java/androidx/ui/text/TextDelegate.kt
index ba5b36e..189a9cc 100644
--- a/ui/ui-text/src/main/java/androidx/ui/text/TextDelegate.kt
+++ b/ui/ui-text/src/main/java/androidx/ui/text/TextDelegate.kt
@@ -41,7 +41,6 @@
 import androidx.ui.text.style.TextAlign
 import androidx.ui.text.style.TextDirection
 import androidx.ui.text.style.TextOverflow
-import java.util.Locale
 
 /** The default font size if none is specified. */
 private val DefaultFontSize: Sp = 14.sp
@@ -96,8 +95,6 @@
  * to the last line before the line truncated by [maxLines], if [maxLines] is non-null and that
  * line overflows the width constraint.
  *
- * @param locale The locale used to select region-specific glyphs.
- *
  * @param layoutDirection The widget layout direction.
  *
  * @hide
@@ -110,7 +107,6 @@
     val maxLines: Int? = null,
     val softWrap: Boolean = true,
     val overflow: TextOverflow = TextOverflow.Clip,
-    val locale: Locale? = null,
     val density: Density,
     val layoutDirection: LayoutDirection,
     val resourceLoader: Font.ResourceLoader
diff --git a/ui/ui-text/src/main/java/androidx/ui/text/TextStyle.kt b/ui/ui-text/src/main/java/androidx/ui/text/TextStyle.kt
index f8be302..b87eb42 100644
--- a/ui/ui-text/src/main/java/androidx/ui/text/TextStyle.kt
+++ b/ui/ui-text/src/main/java/androidx/ui/text/TextStyle.kt
@@ -30,7 +30,6 @@
 import androidx.ui.graphics.lerp
 import androidx.ui.lerp
 import androidx.ui.painting.Shadow
-import java.util.Locale
 
 /**
  * Configuration object to define the text style.
@@ -52,7 +51,7 @@
  * @param baselineShift This parameter specifies how much the baseline is shifted from the current
  *  position.
  * @param textGeometricTransform The geometric transformation applied the text.
- * @param locale The locale used to select region-specific glyphs.
+ * @param localeList The locale list 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 shadow The shadow effect applied on the text.
@@ -69,7 +68,7 @@
     val letterSpacing: Float? = null,
     val baselineShift: BaselineShift? = null,
     val textGeometricTransform: TextGeometricTransform? = null,
-    val locale: Locale? = null,
+    val localeList: LocaleList? = null,
     val background: Color? = null,
     val decoration: TextDecoration? = null,
     val shadow: Shadow? = null
@@ -98,7 +97,7 @@
             letterSpacing = other.letterSpacing ?: this.letterSpacing,
             baselineShift = other.baselineShift ?: this.baselineShift,
             textGeometricTransform = other.textGeometricTransform ?: this.textGeometricTransform,
-            locale = other.locale ?: this.locale,
+            localeList = other.localeList ?: this.localeList,
             background = other.background ?: this.background,
             decoration = other.decoration ?: this.decoration,
             shadow = other.shadow ?: this.shadow
@@ -219,7 +218,7 @@
                     b.textGeometricTransform ?: TextGeometricTransform.None,
                     t
                 ),
-                locale = lerpDiscrete(a.locale, b.locale, t),
+                localeList = lerpDiscrete(a.localeList, b.localeList, t),
                 background = lerpDiscrete(
                     a.background,
                     b.background,
@@ -260,7 +259,7 @@
             letterSpacing != other.letterSpacing ||
             baselineShift != other.baselineShift ||
             textGeometricTransform != other.textGeometricTransform ||
-            locale != other.locale ||
+            localeList != other.localeList ||
             background != other.background
         ) {
             return RenderComparison.LAYOUT
diff --git a/ui/ui-text/src/main/java/androidx/ui/text/platform/AndroidParagraph.kt b/ui/ui-text/src/main/java/androidx/ui/text/platform/AndroidParagraph.kt
index 7aafef4..97200de 100644
--- a/ui/ui-text/src/main/java/androidx/ui/text/platform/AndroidParagraph.kt
+++ b/ui/ui-text/src/main/java/androidx/ui/text/platform/AndroidParagraph.kt
@@ -16,6 +16,8 @@
 package androidx.ui.text.platform
 
 import android.graphics.Typeface
+import android.os.Build
+import android.os.LocaleList as AndroidLocaleList
 import android.text.SpannableString
 import android.text.Spanned
 import android.text.TextPaint
@@ -29,6 +31,7 @@
 import android.text.style.ScaleXSpan
 import android.text.style.StrikethroughSpan
 import android.text.style.UnderlineSpan
+import androidx.annotation.RequiresApi
 import androidx.annotation.VisibleForTesting
 import androidx.text.LayoutCompat.ALIGN_CENTER
 import androidx.text.LayoutCompat.ALIGN_LEFT
@@ -63,6 +66,8 @@
 import androidx.ui.painting.Canvas
 import androidx.ui.painting.Path
 import androidx.ui.text.AnnotatedString
+import androidx.ui.text.Locale
+import androidx.ui.text.LocaleList
 import androidx.ui.text.Paragraph
 import androidx.ui.text.ParagraphConstraints
 import androidx.ui.text.ParagraphStyle
@@ -76,7 +81,7 @@
 import androidx.ui.text.style.TextDirection
 import androidx.ui.text.style.TextDirectionAlgorithm
 import androidx.ui.text.style.TextIndent
-import java.util.Locale
+import java.util.Locale as JavaLocale
 import kotlin.math.roundToInt
 
 /**
@@ -142,7 +147,7 @@
         get() = layout?.didExceedMaxLines ?: false
 
     @VisibleForTesting
-    internal val textLocale: Locale
+    internal val textLocale: JavaLocale
         get() = textPaint.textLocale
 
     override val lineCount: Int
@@ -466,10 +471,14 @@
             )
         }
         // TODO(Migration/haoyuchang): implement height
-        style.locale?.let {
+        style.localeList?.let {
             spannableString.setSpan(
-                // TODO(Migration/haoyuchang): support locale fallback in the framework
-                LocaleSpan(Locale(it.language, it.country ?: "")),
+                if (Build.VERSION.SDK_INT >= 24) {
+                    LocaleSpan(it.toAndroidLocaleList())
+                } else {
+                    val locale = if (it.isEmpty()) Locale.current else it[0]
+                    LocaleSpan(locale.toJavaLocale())
+                },
                 start,
                 end,
                 Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
@@ -521,11 +530,13 @@
         typeface = createTypeface(style, typefaceAdapter)
     }
 
-    style.locale?.let {
-        textLocale = Locale(
-            it.language,
-            it.country ?: ""
-        )
+    style.localeList?.let {
+        if (Build.VERSION.SDK_INT >= 24) {
+            textLocales = it.toAndroidLocaleList()
+        } else {
+            val locale = if (it.isEmpty()) Locale.current else it[0]
+            textLocale = locale.toJavaLocale()
+        }
     }
 
     style.color?.let {
@@ -614,4 +625,10 @@
     TextAlign.Start -> ALIGN_NORMAL
     TextAlign.End -> ALIGN_OPPOSITE
     else -> DEFAULT_ALIGNMENT
-}
\ No newline at end of file
+}
+
+private fun Locale.toJavaLocale(): JavaLocale = (platformLocale as AndroidLocale).javaLocale
+
+@RequiresApi(api = 24)
+private fun LocaleList.toAndroidLocaleList(): AndroidLocaleList =
+    AndroidLocaleList(*map { it.toJavaLocale() }.toTypedArray())
\ No newline at end of file
diff --git a/ui/ui-text/src/test/java/androidx/ui/text/TextDelegateTest.kt b/ui/ui-text/src/test/java/androidx/ui/text/TextDelegateTest.kt
index 772eaae..893b59b 100644
--- a/ui/ui-text/src/test/java/androidx/ui/text/TextDelegateTest.kt
+++ b/ui/ui-text/src/test/java/androidx/ui/text/TextDelegateTest.kt
@@ -26,7 +26,6 @@
 import org.junit.Test
 import org.junit.runner.RunWith
 import org.junit.runners.JUnit4
-import java.util.Locale
 
 @RunWith(JUnit4::class)
 class TextDelegateTest() {
@@ -44,7 +43,6 @@
 
         assertThat(textDelegate.maxLines).isNull()
         assertThat(textDelegate.overflow).isEqualTo(TextOverflow.Clip)
-        assertThat(textDelegate.locale).isNull()
     }
 
     @Test
@@ -90,21 +88,6 @@
         assertThat(textDelegate.overflow).isEqualTo(overflow)
     }
 
-    @Test
-    fun `constructor with customized locale`() {
-        val locale = Locale("en", "US")
-
-        val textDelegate = TextDelegate(
-            text = AnnotatedString(text = ""),
-            locale = locale,
-            density = density,
-            resourceLoader = resourceLoader,
-            layoutDirection = LayoutDirection.Ltr
-        )
-
-        assertThat(textDelegate.locale).isEqualTo(locale)
-    }
-
     @Test(expected = AssertionError::class)
     fun `minIntrinsicWidth without layout assertion should fail`() {
         val textDelegate = TextDelegate(
diff --git a/ui/ui-text/src/test/java/androidx/ui/text/TextStyleTest.kt b/ui/ui-text/src/test/java/androidx/ui/text/TextStyleTest.kt
index 1651a1e..a9effe5 100644
--- a/ui/ui-text/src/test/java/androidx/ui/text/TextStyleTest.kt
+++ b/ui/ui-text/src/test/java/androidx/ui/text/TextStyleTest.kt
@@ -34,7 +34,6 @@
 import org.junit.Test
 import org.junit.runner.RunWith
 import org.junit.runners.JUnit4
-import java.util.Locale
 
 @RunWith(JUnit4::class)
 class TextStyleTest {
@@ -47,7 +46,7 @@
         assertThat(textStyle.fontWeight).isNull()
         assertThat(textStyle.fontStyle).isNull()
         assertThat(textStyle.letterSpacing).isNull()
-        assertThat(textStyle.locale).isNull()
+        assertThat(textStyle.localeList).isNull()
         assertThat(textStyle.background).isNull()
         assertThat(textStyle.decoration).isNull()
         assertThat(textStyle.fontFamily).isNull()
@@ -109,11 +108,11 @@
 
     @Test
     fun `constructor with customized locale`() {
-        val locale = Locale("en", "US")
+        val localeList = LocaleList("en-US")
 
-        val textStyle = TextStyle(locale = locale)
+        val textStyle = TextStyle(localeList = localeList)
 
-        assertThat(textStyle.locale).isEqualTo(locale)
+        assertThat(textStyle.localeList).isEqualTo(localeList)
     }
 
     @Test
@@ -410,25 +409,25 @@
 
     @Test
     fun `merge with other's locale is null should use this' locale`() {
-        val locale = Locale("en", "US")
-        val textStyle = TextStyle(locale = locale)
+        val localeList = LocaleList("en-US")
+        val textStyle = TextStyle(localeList = localeList)
         val otherTextStyle = TextStyle()
 
         val newTextStyle = textStyle.merge(otherTextStyle)
 
-        assertThat(newTextStyle.locale).isEqualTo(locale)
+        assertThat(newTextStyle.localeList).isEqualTo(localeList)
     }
 
     @Test
     fun `merge with other's locale is set should use other's locale`() {
-        val locale = Locale("en", "US")
-        val otherLocale = Locale("ja", "JP")
-        val textStyle = TextStyle(locale = locale)
-        val otherTextStyle = TextStyle(locale = otherLocale)
+        val localeList = LocaleList("en-US")
+        val otherlocaleList = LocaleList("ja-JP")
+        val textStyle = TextStyle(localeList = localeList)
+        val otherTextStyle = TextStyle(localeList = otherlocaleList)
 
         val newTextStyle = textStyle.merge(otherTextStyle)
 
-        assertThat(newTextStyle.locale).isEqualTo(otherLocale)
+        assertThat(newTextStyle.localeList).isEqualTo(otherlocaleList)
     }
 
     @Test
@@ -1141,72 +1140,72 @@
 
     @Test
     fun `lerp locale with a is Null and t is smaller than half`() {
-        val locale = Locale("en", "US")
+        val localeList = LocaleList("en-US")
         val t = 0.2f
-        val textStyle = TextStyle(locale = locale)
+        val textStyle = TextStyle(localeList = localeList)
 
         val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
 
-        assertThat(newTextStyle?.locale).isNull()
+        assertThat(newTextStyle?.localeList).isNull()
     }
 
     @Test
     fun `lerp locale with a is Null and t is larger than half`() {
-        val locale = Locale("en", "US")
+        val localeList = LocaleList("en-US")
         val t = 0.8f
-        val textStyle = TextStyle(locale = locale)
+        val textStyle = TextStyle(localeList = localeList)
 
         val newTextStyle = TextStyle.lerp(b = textStyle, t = t)
 
-        assertThat(newTextStyle?.locale).isEqualTo(locale)
+        assertThat(newTextStyle?.localeList).isEqualTo(localeList)
     }
 
     @Test
     fun `lerp locale with b is Null and t is smaller than half`() {
-        val locale = Locale("en", "US")
+        val localeList = LocaleList("en-US")
         val t = 0.2f
-        val textStyle = TextStyle(locale = locale)
+        val textStyle = TextStyle(localeList = localeList)
 
         val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
 
-        assertThat(newTextStyle?.locale).isEqualTo(locale)
+        assertThat(newTextStyle?.localeList).isEqualTo(localeList)
     }
 
     @Test
     fun `lerp locale with b is Null and t is larger than half`() {
-        val locale = Locale("en", "US")
+        val localeList = LocaleList("en-US")
         val t = 0.8f
-        val textStyle = TextStyle(locale = locale)
+        val textStyle = TextStyle(localeList = localeList)
 
         val newTextStyle = TextStyle.lerp(a = textStyle, t = t)
 
-        assertThat(newTextStyle?.locale).isNull()
+        assertThat(newTextStyle?.localeList).isNull()
     }
 
     @Test
     fun `lerp locale with a and b are not Null and t is smaller than half`() {
-        val locale1 = Locale("en", "US")
-        val locale2 = Locale("ja", "JP")
+        val localeList1 = LocaleList("en-US")
+        val localeList2 = LocaleList("ja-JP")
         val t = 0.3f
-        val textStyle1 = TextStyle(locale = locale1)
-        val textStyle2 = TextStyle(locale = locale2)
+        val textStyle1 = TextStyle(localeList = localeList1)
+        val textStyle2 = TextStyle(localeList = localeList2)
 
         val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
 
-        assertThat(newTextStyle?.locale).isEqualTo(locale1)
+        assertThat(newTextStyle?.localeList).isEqualTo(localeList1)
     }
 
     @Test
     fun `lerp locale with a and b are not Null and t is larger than half`() {
-        val locale1 = Locale("en", "US")
-        val locale2 = Locale("ja", "JP")
+        val localeList1 = LocaleList("en-US")
+        val localeList2 = LocaleList("ja-JP")
         val t = 0.8f
-        val textStyle1 = TextStyle(locale = locale1)
-        val textStyle2 = TextStyle(locale = locale2)
+        val textStyle1 = TextStyle(localeList = localeList1)
+        val textStyle2 = TextStyle(localeList = localeList2)
 
         val newTextStyle = TextStyle.lerp(a = textStyle1, b = textStyle2, t = t)
 
-        assertThat(newTextStyle?.locale).isEqualTo(locale2)
+        assertThat(newTextStyle?.localeList).isEqualTo(localeList2)
     }
 
     @Test
@@ -1378,7 +1377,7 @@
             letterSpacing = 1.0f,
             baselineShift = BaselineShift.Subscript,
             textGeometricTransform = TextGeometricTransform(scaleX = 1.0f),
-            locale = Locale("en", "US"),
+            localeList = LocaleList("en-US"),
             background = bgColor,
             decoration = TextDecoration.Underline,
             fontFamily = FontFamily(genericFamily = "sans-serif"),
@@ -1416,7 +1415,7 @@
             .copy(textGeometricTransform = TextGeometricTransform())))
             .isEqualTo(RenderComparison.LAYOUT)
 
-        assertThat(textStyle.compareTo(textStyle.copy(locale = Locale("ja", "JP"))))
+        assertThat(textStyle.compareTo(textStyle.copy(localeList = LocaleList("ja-JP"))))
             .isEqualTo(RenderComparison.LAYOUT)
     }
 
@@ -1437,7 +1436,7 @@
             letterSpacing = 1.0f,
             baselineShift = BaselineShift.Superscript,
             textGeometricTransform = TextGeometricTransform(null, null),
-            locale = Locale("en", "US"),
+            localeList = LocaleList("en-US"),
             decoration = TextDecoration.Underline,
             fontFamily = FontFamily(genericFamily = "sans-serif"),
             shadow = shadow1