1 /*
2  * Copyright 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package androidx.compose.ui.text
18 
19 /** Provides platform specific [TextStyle] configuration options for styling and compatibility. */
20 expect class PlatformTextStyle {
21     /** Platform specific text span styling and compatibility configuration. */
22     val spanStyle: PlatformSpanStyle?
23 
24     /** Platform specific paragraph styling and compatibility configuration. */
25     val paragraphStyle: PlatformParagraphStyle?
26 }
27 
createPlatformTextStylenull28 internal expect fun createPlatformTextStyle(
29     spanStyle: PlatformSpanStyle?,
30     paragraphStyle: PlatformParagraphStyle?
31 ): PlatformTextStyle
32 
33 /**
34  * Provides platform specific [ParagraphStyle] configuration options for styling and compatibility.
35  */
36 expect class PlatformParagraphStyle {
37     companion object {
38         val Default: PlatformParagraphStyle
39     }
40 
41     fun merge(other: PlatformParagraphStyle?): PlatformParagraphStyle
42 }
43 
44 /** Provides platform specific [SpanStyle] configuration options for styling and compatibility. */
45 expect class PlatformSpanStyle {
46     companion object {
47         val Default: PlatformSpanStyle
48     }
49 
mergenull50     fun merge(other: PlatformSpanStyle?): PlatformSpanStyle
51 }
52 
53 /**
54  * Interpolate between two PlatformParagraphStyle's.
55  *
56  * This will not work well if the styles don't set the same fields.
57  *
58  * The [fraction] argument represents position on the timeline, with 0.0 meaning that the
59  * interpolation has not started, returning [start] (or something equivalent to [start]), 1.0
60  * meaning that the interpolation has finished, returning [stop] (or something equivalent to
61  * [stop]), and values in between meaning that the interpolation is at the relevant point on the
62  * timeline between [start] and [stop]. The interpolation can be extrapolated beyond 0.0 and 1.0, so
63  * negative values and values greater than 1.0 are valid.
64  */
65 expect fun lerp(
66     start: PlatformParagraphStyle,
67     stop: PlatformParagraphStyle,
68     fraction: Float
69 ): PlatformParagraphStyle
70 
71 /**
72  * Interpolate between two PlatformSpanStyle's.
73  *
74  * This will not work well if the styles don't set the same fields.
75  *
76  * The [fraction] argument represents position on the timeline, with 0.0 meaning that the
77  * interpolation has not started, returning [start] (or something equivalent to [start]), 1.0
78  * meaning that the interpolation has finished, returning [stop] (or something equivalent to
79  * [stop]), and values in between meaning that the interpolation is at the relevant point on the
80  * timeline between [start] and [stop]. The interpolation can be extrapolated beyond 0.0 and 1.0, so
81  * negative values and values greater than 1.0 are valid.
82  */
83 expect fun lerp(
84     start: PlatformSpanStyle,
85     stop: PlatformSpanStyle,
86     fraction: Float
87 ): PlatformSpanStyle
88