@@ -21,6 +21,7 @@ import android.widget.Toast
21
21
import androidx.annotation.DrawableRes
22
22
import androidx.appcompat.app.AppCompatDelegate
23
23
import androidx.browser.customtabs.CustomTabsClient
24
+ import androidx.compose.material.LocalTextStyle
24
25
import androidx.compose.runtime.Composable
25
26
import androidx.compose.ui.graphics.asImageBitmap
26
27
import androidx.compose.ui.graphics.painter.BitmapPainter
@@ -128,6 +129,8 @@ object UiUtils {
128
129
@OptIn(ExperimentalTextApi ::class )
129
130
@Composable
130
131
fun Spanned.toAnnotatedString () = buildAnnotatedString {
132
+ val style = LocalTextStyle .current.toSpanStyle()
133
+ pushStyle(style)
131
134
val spanned = this @toAnnotatedString
132
135
append(spanned.toString())
133
136
for (span in getSpans<Any >(0 , spanned.length)) {
@@ -137,11 +140,11 @@ object UiUtils {
137
140
is StyleSpan ->
138
141
when (span.style) {
139
142
Typeface .BOLD -> addStyle(
140
- SpanStyle (fontWeight = FontWeight .Bold ),
143
+ style.copy (fontWeight = FontWeight .Bold ),
141
144
start = start, end = end
142
145
)
143
146
Typeface .ITALIC -> addStyle(
144
- SpanStyle (fontStyle = FontStyle .Italic ),
147
+ style.copy (fontStyle = FontStyle .Italic ),
145
148
start = start, end = end
146
149
)
147
150
}
@@ -151,7 +154,7 @@ object UiUtils {
151
154
start = start, end = end
152
155
)
153
156
addStyle(
154
- SpanStyle (textDecoration = TextDecoration .Underline ),
157
+ style.copy (textDecoration = TextDecoration .Underline ),
155
158
start = start, end = end
156
159
)
157
160
}
0 commit comments