1 /*
2  * Copyright 2021 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.material3
18 
19 import androidx.compose.material3.tokens.TypographyKeyTokens
20 import androidx.compose.material3.tokens.TypographyTokens
21 import androidx.compose.runtime.Composable
22 import androidx.compose.runtime.Immutable
23 import androidx.compose.runtime.ReadOnlyComposable
24 import androidx.compose.runtime.staticCompositionLocalOf
25 import androidx.compose.ui.text.TextStyle
26 
27 /**
28  * The Material Design type scale includes a range of contrasting styles that support the needs of
29  * your product and its content.
30  *
31  * Use typography to make writing legible and beautiful. Material's default type scale includes
32  * contrasting and flexible styles to support a wide range of use cases.
33  *
34  * The type scale is a combination of thirteen styles that are supported by the type system. It
35  * contains reusable categories of text, each with an intended application and meaning.
36  *
37  * The emphasized versions of the baseline styles add dynamism and personality to the baseline
38  * styles. It can be used to further stylize select pieces of text. The emphasized states have
39  * pragmatic uses, such as creating clearer division of content and drawing users' eyes to relevant
40  * material.
41  *
42  * To learn more about typography, see
43  * [Material Design typography](https://m3.material.io/styles/typography/overview).
44  *
45  * @property displayLarge displayLarge is the largest display text.
46  * @property displayMedium displayMedium is the second largest display text.
47  * @property displaySmall displaySmall is the smallest display text.
48  * @property headlineLarge headlineLarge is the largest headline, reserved for short, important text
49  *   or numerals. For headlines, you can choose an expressive font, such as a display, handwritten,
50  *   or script style. These unconventional font designs have details and intricacy that help attract
51  *   the eye.
52  * @property headlineMedium headlineMedium is the second largest headline, reserved for short,
53  *   important text or numerals. For headlines, you can choose an expressive font, such as a
54  *   display, handwritten, or script style. These unconventional font designs have details and
55  *   intricacy that help attract the eye.
56  * @property headlineSmall headlineSmall is the smallest headline, reserved for short, important
57  *   text or numerals. For headlines, you can choose an expressive font, such as a display,
58  *   handwritten, or script style. These unconventional font designs have details and intricacy that
59  *   help attract the eye.
60  * @property titleLarge titleLarge is the largest title, and is typically reserved for
61  *   medium-emphasis text that is shorter in length. Serif or sans serif typefaces work well for
62  *   subtitles.
63  * @property titleMedium titleMedium is the second largest title, and is typically reserved for
64  *   medium-emphasis text that is shorter in length. Serif or sans serif typefaces work well for
65  *   subtitles.
66  * @property titleSmall titleSmall is the smallest title, and is typically reserved for
67  *   medium-emphasis text that is shorter in length. Serif or sans serif typefaces work well for
68  *   subtitles.
69  * @property bodyLarge bodyLarge is the largest body, and is typically used for long-form writing as
70  *   it works well for small text sizes. For longer sections of text, a serif or sans serif typeface
71  *   is recommended.
72  * @property bodyMedium bodyMedium is the second largest body, and is typically used for long-form
73  *   writing as it works well for small text sizes. For longer sections of text, a serif or sans
74  *   serif typeface is recommended.
75  * @property bodySmall bodySmall is the smallest body, and is typically used for long-form writing
76  *   as it works well for small text sizes. For longer sections of text, a serif or sans serif
77  *   typeface is recommended.
78  * @property labelLarge labelLarge text is a call to action used in different types of buttons (such
79  *   as text, outlined and contained buttons) and in tabs, dialogs, and cards. Button text is
80  *   typically sans serif, using all caps text.
81  * @property labelMedium labelMedium is one of the smallest font sizes. It is used sparingly to
82  *   annotate imagery or to introduce a headline.
83  * @property labelSmall labelSmall is one of the smallest font sizes. It is used sparingly to
84  *   annotate imagery or to introduce a headline.
85  * @property displayLargeEmphasized an emphasized version of [displayLarge].
86  * @property displayMediumEmphasized an emphasized version of [displayMedium].
87  * @property displaySmallEmphasized an emphasized version of [displaySmall].
88  * @property headlineLargeEmphasized an emphasized version of [headlineLarge].
89  * @property headlineMediumEmphasized an emphasized version of [headlineMedium].
90  * @property headlineSmallEmphasized an emphasized version of [headlineSmall].
91  * @property titleLargeEmphasized an emphasized version of [titleLarge].
92  * @property titleMediumEmphasized an emphasized version of [titleMedium].
93  * @property titleSmallEmphasized an emphasized version of [titleSmall].
94  * @property bodyLargeEmphasized an emphasized version of [bodyLarge].
95  * @property bodyMediumEmphasized an emphasized version of [bodyMedium].
96  * @property bodySmallEmphasized an emphasized version of [bodySmall].
97  * @property labelLargeEmphasized an emphasized version of [labelLarge].
98  * @property labelMediumEmphasized an emphasized version of [labelMedium].
99  * @property labelSmallEmphasized an emphasized version of [labelSmall].
100  */
101 @Immutable
102 class Typography
103 @ExperimentalMaterial3ExpressiveApi
104 constructor(
105     val displayLarge: TextStyle = TypographyTokens.DisplayLarge,
106     val displayMedium: TextStyle = TypographyTokens.DisplayMedium,
107     val displaySmall: TextStyle = TypographyTokens.DisplaySmall,
108     val headlineLarge: TextStyle = TypographyTokens.HeadlineLarge,
109     val headlineMedium: TextStyle = TypographyTokens.HeadlineMedium,
110     val headlineSmall: TextStyle = TypographyTokens.HeadlineSmall,
111     val titleLarge: TextStyle = TypographyTokens.TitleLarge,
112     val titleMedium: TextStyle = TypographyTokens.TitleMedium,
113     val titleSmall: TextStyle = TypographyTokens.TitleSmall,
114     val bodyLarge: TextStyle = TypographyTokens.BodyLarge,
115     val bodyMedium: TextStyle = TypographyTokens.BodyMedium,
116     val bodySmall: TextStyle = TypographyTokens.BodySmall,
117     val labelLarge: TextStyle = TypographyTokens.LabelLarge,
118     val labelMedium: TextStyle = TypographyTokens.LabelMedium,
119     val labelSmall: TextStyle = TypographyTokens.LabelSmall,
120     displayLargeEmphasized: TextStyle = TypographyTokens.DisplayLargeEmphasized,
121     displayMediumEmphasized: TextStyle = TypographyTokens.DisplayMediumEmphasized,
122     displaySmallEmphasized: TextStyle = TypographyTokens.DisplaySmallEmphasized,
123     headlineLargeEmphasized: TextStyle = TypographyTokens.HeadlineLargeEmphasized,
124     headlineMediumEmphasized: TextStyle = TypographyTokens.HeadlineMediumEmphasized,
125     headlineSmallEmphasized: TextStyle = TypographyTokens.HeadlineSmallEmphasized,
126     titleLargeEmphasized: TextStyle = TypographyTokens.TitleLargeEmphasized,
127     titleMediumEmphasized: TextStyle = TypographyTokens.TitleMediumEmphasized,
128     titleSmallEmphasized: TextStyle = TypographyTokens.TitleSmallEmphasized,
129     bodyLargeEmphasized: TextStyle = TypographyTokens.BodyLargeEmphasized,
130     bodyMediumEmphasized: TextStyle = TypographyTokens.BodyMediumEmphasized,
131     bodySmallEmphasized: TextStyle = TypographyTokens.BodySmallEmphasized,
132     labelLargeEmphasized: TextStyle = TypographyTokens.LabelLargeEmphasized,
133     labelMediumEmphasized: TextStyle = TypographyTokens.LabelMediumEmphasized,
134     labelSmallEmphasized: TextStyle = TypographyTokens.LabelSmallEmphasized,
135 ) {
136     @Suppress("OPT_IN_MARKER_ON_WRONG_TARGET")
137     @get:ExperimentalMaterial3ExpressiveApi
138     @ExperimentalMaterial3ExpressiveApi
139     /** an emphasized version of [displayLarge]. */
140     val displayLargeEmphasized = displayLargeEmphasized
141 
142     @Suppress("OPT_IN_MARKER_ON_WRONG_TARGET")
143     @get:ExperimentalMaterial3ExpressiveApi
144     @ExperimentalMaterial3ExpressiveApi
145     /** an emphasized version of [displayMedium]. */
146     val displayMediumEmphasized = displayMediumEmphasized
147 
148     @Suppress("OPT_IN_MARKER_ON_WRONG_TARGET")
149     @get:ExperimentalMaterial3ExpressiveApi
150     @ExperimentalMaterial3ExpressiveApi
151     /** an emphasized version of [displaySmall]. */
152     val displaySmallEmphasized = displaySmallEmphasized
153 
154     @Suppress("OPT_IN_MARKER_ON_WRONG_TARGET")
155     @get:ExperimentalMaterial3ExpressiveApi
156     @ExperimentalMaterial3ExpressiveApi
157     /** an emphasized version of [headlineLarge]. */
158     val headlineLargeEmphasized = headlineLargeEmphasized
159 
160     @Suppress("OPT_IN_MARKER_ON_WRONG_TARGET")
161     @get:ExperimentalMaterial3ExpressiveApi
162     @ExperimentalMaterial3ExpressiveApi
163     /** an emphasized version of [headlineMedium]. */
164     val headlineMediumEmphasized = headlineMediumEmphasized
165 
166     @Suppress("OPT_IN_MARKER_ON_WRONG_TARGET")
167     @get:ExperimentalMaterial3ExpressiveApi
168     @ExperimentalMaterial3ExpressiveApi
169     /** an emphasized version of [headlineSmall]. */
170     val headlineSmallEmphasized = headlineSmallEmphasized
171 
172     @Suppress("OPT_IN_MARKER_ON_WRONG_TARGET")
173     @get:ExperimentalMaterial3ExpressiveApi
174     @ExperimentalMaterial3ExpressiveApi
175     /** an emphasized version of [titleLarge]. */
176     val titleLargeEmphasized = titleLargeEmphasized
177 
178     @Suppress("OPT_IN_MARKER_ON_WRONG_TARGET")
179     @get:ExperimentalMaterial3ExpressiveApi
180     @ExperimentalMaterial3ExpressiveApi
181     /** an emphasized version of [titleMedium]. */
182     val titleMediumEmphasized = titleMediumEmphasized
183 
184     @Suppress("OPT_IN_MARKER_ON_WRONG_TARGET")
185     @get:ExperimentalMaterial3ExpressiveApi
186     @ExperimentalMaterial3ExpressiveApi
187     /** an emphasized version of [titleSmall]. */
188     val titleSmallEmphasized = titleSmallEmphasized
189 
190     @Suppress("OPT_IN_MARKER_ON_WRONG_TARGET")
191     @get:ExperimentalMaterial3ExpressiveApi
192     @ExperimentalMaterial3ExpressiveApi
193     /** an emphasized version of [bodyLarge]. */
194     val bodyLargeEmphasized = bodyLargeEmphasized
195 
196     @Suppress("OPT_IN_MARKER_ON_WRONG_TARGET")
197     @get:ExperimentalMaterial3ExpressiveApi
198     @ExperimentalMaterial3ExpressiveApi
199     /** an emphasized version of [bodyMedium]. */
200     val bodyMediumEmphasized = bodyMediumEmphasized
201 
202     @Suppress("OPT_IN_MARKER_ON_WRONG_TARGET")
203     @get:ExperimentalMaterial3ExpressiveApi
204     @ExperimentalMaterial3ExpressiveApi
205     /** an emphasized version of [bodySmall]. */
206     val bodySmallEmphasized = bodySmallEmphasized
207 
208     @Suppress("OPT_IN_MARKER_ON_WRONG_TARGET")
209     @get:ExperimentalMaterial3ExpressiveApi
210     @ExperimentalMaterial3ExpressiveApi
211     /** an emphasized version of [labelLarge]. */
212     val labelLargeEmphasized = labelLargeEmphasized
213 
214     @Suppress("OPT_IN_MARKER_ON_WRONG_TARGET")
215     @get:ExperimentalMaterial3ExpressiveApi
216     @ExperimentalMaterial3ExpressiveApi
217     /** an emphasized version of [labelMedium]. */
218     val labelMediumEmphasized = labelMediumEmphasized
219 
220     @Suppress("OPT_IN_MARKER_ON_WRONG_TARGET")
221     @get:ExperimentalMaterial3ExpressiveApi
222     @ExperimentalMaterial3ExpressiveApi
223     /** an emphasized version of [labelSmall]. */
224     val labelSmallEmphasized = labelSmallEmphasized
225 
226     /**
227      * The Material Design type scale includes a range of contrasting styles that support the needs
228      * of your product and its content.
229      *
230      * Use typography to make writing legible and beautiful. Material's default type scale includes
231      * contrasting and flexible styles to support a wide range of use cases.
232      *
233      * The type scale is a combination of thirteen styles that are supported by the type system. It
234      * contains reusable categories of text, each with an intended application and meaning.
235      *
236      * To learn more about typography, see
237      * [Material Design typography](https://m3.material.io/styles/typography/overview).
238      *
239      * @param displayLarge displayLarge is the largest display text.
240      * @param displayMedium displayMedium is the second largest display text.
241      * @param displaySmall displaySmall is the smallest display text.
242      * @param headlineLarge headlineLarge is the largest headline, reserved for short, important
243      *   text or numerals. For headlines, you can choose an expressive font, such as a display,
244      *   handwritten, or script style. These unconventional font designs have details and intricacy
245      *   that help attract the eye.
246      * @param headlineMedium headlineMedium is the second largest headline, reserved for short,
247      *   important text or numerals. For headlines, you can choose an expressive font, such as a
248      *   display, handwritten, or script style. These unconventional font designs have details and
249      *   intricacy that help attract the eye.
250      * @param headlineSmall headlineSmall is the smallest headline, reserved for short, important
251      *   text or numerals. For headlines, you can choose an expressive font, such as a display,
252      *   handwritten, or script style. These unconventional font designs have details and intricacy
253      *   that help attract the eye.
254      * @param titleLarge titleLarge is the largest title, and is typically reserved for
255      *   medium-emphasis text that is shorter in length. Serif or sans serif typefaces work well for
256      *   subtitles.
257      * @param titleMedium titleMedium is the second largest title, and is typically reserved for
258      *   medium-emphasis text that is shorter in length. Serif or sans serif typefaces work well for
259      *   subtitles.
260      * @param titleSmall titleSmall is the smallest title, and is typically reserved for
261      *   medium-emphasis text that is shorter in length. Serif or sans serif typefaces work well for
262      *   subtitles.
263      * @param bodyLarge bodyLarge is the largest body, and is typically used for long-form writing
264      *   as it works well for small text sizes. For longer sections of text, a serif or sans serif
265      *   typeface is recommended.
266      * @param bodyMedium bodyMedium is the second largest body, and is typically used for long-form
267      *   writing as it works well for small text sizes. For longer sections of text, a serif or sans
268      *   serif typeface is recommended.
269      * @param bodySmall bodySmall is the smallest body, and is typically used for long-form writing
270      *   as it works well for small text sizes. For longer sections of text, a serif or sans serif
271      *   typeface is recommended.
272      * @param labelLarge labelLarge text is a call to action used in different types of buttons
273      *   (such as text, outlined and contained buttons) and in tabs, dialogs, and cards. Button text
274      *   is typically sans serif, using all caps text.
275      * @param labelMedium labelMedium is one of the smallest font sizes. It is used sparingly to
276      *   annotate imagery or to introduce a headline.
277      * @param labelSmall labelSmall is one of the smallest font sizes. It is used sparingly to
278      *   annotate imagery or to introduce a headline.
279      */
280     @OptIn(ExperimentalMaterial3ExpressiveApi::class)
281     constructor(
282         displayLarge: TextStyle = TypographyTokens.DisplayLarge,
283         displayMedium: TextStyle = TypographyTokens.DisplayMedium,
284         displaySmall: TextStyle = TypographyTokens.DisplaySmall,
285         headlineLarge: TextStyle = TypographyTokens.HeadlineLarge,
286         headlineMedium: TextStyle = TypographyTokens.HeadlineMedium,
287         headlineSmall: TextStyle = TypographyTokens.HeadlineSmall,
288         titleLarge: TextStyle = TypographyTokens.TitleLarge,
289         titleMedium: TextStyle = TypographyTokens.TitleMedium,
290         titleSmall: TextStyle = TypographyTokens.TitleSmall,
291         bodyLarge: TextStyle = TypographyTokens.BodyLarge,
292         bodyMedium: TextStyle = TypographyTokens.BodyMedium,
293         bodySmall: TextStyle = TypographyTokens.BodySmall,
294         labelLarge: TextStyle = TypographyTokens.LabelLarge,
295         labelMedium: TextStyle = TypographyTokens.LabelMedium,
296         labelSmall: TextStyle = TypographyTokens.LabelSmall,
297     ) : this(
298         displayLarge = displayLarge,
299         displayMedium = displayMedium,
300         displaySmall = displaySmall,
301         headlineLarge = headlineLarge,
302         headlineMedium = headlineMedium,
303         headlineSmall = headlineSmall,
304         titleLarge = titleLarge,
305         titleMedium = titleMedium,
306         titleSmall = titleSmall,
307         bodyLarge = bodyLarge,
308         bodyMedium = bodyMedium,
309         bodySmall = bodySmall,
310         labelLarge = labelLarge,
311         labelMedium = labelMedium,
312         labelSmall = labelSmall,
313         displayLargeEmphasized = displayLarge,
314         displayMediumEmphasized = displayMedium,
315         displaySmallEmphasized = displaySmall,
316         headlineLargeEmphasized = headlineLarge,
317         headlineMediumEmphasized = headlineMedium,
318         headlineSmallEmphasized = headlineSmall,
319         titleLargeEmphasized = titleLarge,
320         titleMediumEmphasized = titleMedium,
321         titleSmallEmphasized = titleSmall,
322         bodyLargeEmphasized = bodyLarge,
323         bodyMediumEmphasized = bodyMedium,
324         bodySmallEmphasized = bodySmall,
325         labelLargeEmphasized = labelLarge,
326         labelMediumEmphasized = labelMedium,
327         labelSmallEmphasized = labelSmall,
328     )
329 
330     /** Returns a copy of this Typography, optionally overriding some of the values. */
331     @ExperimentalMaterial3ExpressiveApi
copynull332     fun copy(
333         displayLarge: TextStyle = this.displayLarge,
334         displayMedium: TextStyle = this.displayMedium,
335         displaySmall: TextStyle = this.displaySmall,
336         headlineLarge: TextStyle = this.headlineLarge,
337         headlineMedium: TextStyle = this.headlineMedium,
338         headlineSmall: TextStyle = this.headlineSmall,
339         titleLarge: TextStyle = this.titleLarge,
340         titleMedium: TextStyle = this.titleMedium,
341         titleSmall: TextStyle = this.titleSmall,
342         bodyLarge: TextStyle = this.bodyLarge,
343         bodyMedium: TextStyle = this.bodyMedium,
344         bodySmall: TextStyle = this.bodySmall,
345         labelLarge: TextStyle = this.labelLarge,
346         labelMedium: TextStyle = this.labelMedium,
347         labelSmall: TextStyle = this.labelSmall,
348         displayLargeEmphasized: TextStyle = this.displayLargeEmphasized,
349         displayMediumEmphasized: TextStyle = this.displayMediumEmphasized,
350         displaySmallEmphasized: TextStyle = this.displaySmallEmphasized,
351         headlineLargeEmphasized: TextStyle = this.headlineLargeEmphasized,
352         headlineMediumEmphasized: TextStyle = this.headlineMediumEmphasized,
353         headlineSmallEmphasized: TextStyle = this.headlineSmallEmphasized,
354         titleLargeEmphasized: TextStyle = this.titleLargeEmphasized,
355         titleMediumEmphasized: TextStyle = this.titleMediumEmphasized,
356         titleSmallEmphasized: TextStyle = this.titleSmallEmphasized,
357         bodyLargeEmphasized: TextStyle = this.bodyLargeEmphasized,
358         bodyMediumEmphasized: TextStyle = this.bodyMediumEmphasized,
359         bodySmallEmphasized: TextStyle = this.bodySmallEmphasized,
360         labelLargeEmphasized: TextStyle = this.labelLargeEmphasized,
361         labelMediumEmphasized: TextStyle = this.labelMediumEmphasized,
362         labelSmallEmphasized: TextStyle = this.labelSmallEmphasized,
363     ): Typography =
364         Typography(
365             displayLarge = displayLarge,
366             displayMedium = displayMedium,
367             displaySmall = displaySmall,
368             headlineLarge = headlineLarge,
369             headlineMedium = headlineMedium,
370             headlineSmall = headlineSmall,
371             titleLarge = titleLarge,
372             titleMedium = titleMedium,
373             titleSmall = titleSmall,
374             bodyLarge = bodyLarge,
375             bodyMedium = bodyMedium,
376             bodySmall = bodySmall,
377             labelLarge = labelLarge,
378             labelMedium = labelMedium,
379             labelSmall = labelSmall,
380             displayLargeEmphasized = displayLargeEmphasized,
381             displayMediumEmphasized = displayMediumEmphasized,
382             displaySmallEmphasized = displaySmallEmphasized,
383             headlineLargeEmphasized = headlineLargeEmphasized,
384             headlineMediumEmphasized = headlineMediumEmphasized,
385             headlineSmallEmphasized = headlineSmallEmphasized,
386             titleLargeEmphasized = titleLargeEmphasized,
387             titleMediumEmphasized = titleMediumEmphasized,
388             titleSmallEmphasized = titleSmallEmphasized,
389             bodyLargeEmphasized = bodyLargeEmphasized,
390             bodyMediumEmphasized = bodyMediumEmphasized,
391             bodySmallEmphasized = bodySmallEmphasized,
392             labelLargeEmphasized = labelLargeEmphasized,
393             labelMediumEmphasized = labelMediumEmphasized,
394             labelSmallEmphasized = labelSmallEmphasized,
395         )
396 
397     /** Returns a copy of this Typography, optionally overriding some of the values. */
398     @OptIn(ExperimentalMaterial3ExpressiveApi::class)
399     fun copy(
400         displayLarge: TextStyle = this.displayLarge,
401         displayMedium: TextStyle = this.displayMedium,
402         displaySmall: TextStyle = this.displaySmall,
403         headlineLarge: TextStyle = this.headlineLarge,
404         headlineMedium: TextStyle = this.headlineMedium,
405         headlineSmall: TextStyle = this.headlineSmall,
406         titleLarge: TextStyle = this.titleLarge,
407         titleMedium: TextStyle = this.titleMedium,
408         titleSmall: TextStyle = this.titleSmall,
409         bodyLarge: TextStyle = this.bodyLarge,
410         bodyMedium: TextStyle = this.bodyMedium,
411         bodySmall: TextStyle = this.bodySmall,
412         labelLarge: TextStyle = this.labelLarge,
413         labelMedium: TextStyle = this.labelMedium,
414         labelSmall: TextStyle = this.labelSmall,
415     ): Typography =
416         copy(
417             displayLarge = displayLarge,
418             displayMedium = displayMedium,
419             displaySmall = displaySmall,
420             headlineLarge = headlineLarge,
421             headlineMedium = headlineMedium,
422             headlineSmall = headlineSmall,
423             titleLarge = titleLarge,
424             titleMedium = titleMedium,
425             titleSmall = titleSmall,
426             bodyLarge = bodyLarge,
427             bodyMedium = bodyMedium,
428             bodySmall = bodySmall,
429             labelLarge = labelLarge,
430             labelMedium = labelMedium,
431             labelSmall = labelSmall,
432             displayLargeEmphasized = this.displayLargeEmphasized,
433             displayMediumEmphasized = this.displayMediumEmphasized,
434             displaySmallEmphasized = this.displaySmallEmphasized,
435             headlineLargeEmphasized = this.headlineLargeEmphasized,
436             headlineMediumEmphasized = this.headlineMediumEmphasized,
437             headlineSmallEmphasized = this.headlineSmallEmphasized,
438             titleLargeEmphasized = this.titleLargeEmphasized,
439             titleMediumEmphasized = this.titleMediumEmphasized,
440             titleSmallEmphasized = this.titleSmallEmphasized,
441             bodyLargeEmphasized = this.bodyLargeEmphasized,
442             bodyMediumEmphasized = this.bodyMediumEmphasized,
443             bodySmallEmphasized = this.bodySmallEmphasized,
444             labelLargeEmphasized = this.labelLargeEmphasized,
445             labelMediumEmphasized = this.labelMediumEmphasized,
446             labelSmallEmphasized = this.labelSmallEmphasized,
447         )
448 
449     @OptIn(ExperimentalMaterial3ExpressiveApi::class)
450     override fun equals(other: Any?): Boolean {
451         if (this === other) return true
452         if (other !is Typography) return false
453 
454         if (displayLarge != other.displayLarge) return false
455         if (displayMedium != other.displayMedium) return false
456         if (displaySmall != other.displaySmall) return false
457         if (headlineLarge != other.headlineLarge) return false
458         if (headlineMedium != other.headlineMedium) return false
459         if (headlineSmall != other.headlineSmall) return false
460         if (titleLarge != other.titleLarge) return false
461         if (titleMedium != other.titleMedium) return false
462         if (titleSmall != other.titleSmall) return false
463         if (bodyLarge != other.bodyLarge) return false
464         if (bodyMedium != other.bodyMedium) return false
465         if (bodySmall != other.bodySmall) return false
466         if (labelLarge != other.labelLarge) return false
467         if (labelMedium != other.labelMedium) return false
468         if (labelSmall != other.labelSmall) return false
469         if (displayLargeEmphasized != other.displayLargeEmphasized) return false
470         if (displayMediumEmphasized != other.displayMediumEmphasized) return false
471         if (displaySmallEmphasized != other.displaySmallEmphasized) return false
472         if (headlineLargeEmphasized != other.headlineLargeEmphasized) return false
473         if (headlineMediumEmphasized != other.headlineMediumEmphasized) return false
474         if (headlineSmallEmphasized != other.headlineSmallEmphasized) return false
475         if (titleLargeEmphasized != other.titleLargeEmphasized) return false
476         if (titleMediumEmphasized != other.titleMediumEmphasized) return false
477         if (titleSmallEmphasized != other.titleSmallEmphasized) return false
478         if (bodyLargeEmphasized != other.bodyLargeEmphasized) return false
479         if (bodyMediumEmphasized != other.bodyMediumEmphasized) return false
480         if (bodySmallEmphasized != other.bodySmallEmphasized) return false
481         if (labelLargeEmphasized != other.labelLargeEmphasized) return false
482         if (labelMediumEmphasized != other.labelMediumEmphasized) return false
483         if (labelSmallEmphasized != other.labelSmallEmphasized) return false
484         return true
485     }
486 
487     @OptIn(ExperimentalMaterial3ExpressiveApi::class)
hashCodenull488     override fun hashCode(): Int {
489         var result = displayLarge.hashCode()
490         result = 31 * result + displayMedium.hashCode()
491         result = 31 * result + displaySmall.hashCode()
492         result = 31 * result + headlineLarge.hashCode()
493         result = 31 * result + headlineMedium.hashCode()
494         result = 31 * result + headlineSmall.hashCode()
495         result = 31 * result + titleLarge.hashCode()
496         result = 31 * result + titleMedium.hashCode()
497         result = 31 * result + titleSmall.hashCode()
498         result = 31 * result + bodyLarge.hashCode()
499         result = 31 * result + bodyMedium.hashCode()
500         result = 31 * result + bodySmall.hashCode()
501         result = 31 * result + labelLarge.hashCode()
502         result = 31 * result + labelMedium.hashCode()
503         result = 31 * result + labelSmall.hashCode()
504         result = 31 * result + displayLargeEmphasized.hashCode()
505         result = 31 * result + displayMediumEmphasized.hashCode()
506         result = 31 * result + displaySmallEmphasized.hashCode()
507         result = 31 * result + headlineLargeEmphasized.hashCode()
508         result = 31 * result + headlineMediumEmphasized.hashCode()
509         result = 31 * result + headlineSmallEmphasized.hashCode()
510         result = 31 * result + titleLargeEmphasized.hashCode()
511         result = 31 * result + titleMediumEmphasized.hashCode()
512         result = 31 * result + titleSmallEmphasized.hashCode()
513         result = 31 * result + bodyLargeEmphasized.hashCode()
514         result = 31 * result + bodyMediumEmphasized.hashCode()
515         result = 31 * result + bodySmallEmphasized.hashCode()
516         result = 31 * result + labelLargeEmphasized.hashCode()
517         result = 31 * result + labelMediumEmphasized.hashCode()
518         result = 31 * result + labelSmallEmphasized.hashCode()
519         return result
520     }
521 
522     @OptIn(ExperimentalMaterial3ExpressiveApi::class)
toStringnull523     override fun toString(): String {
524         return "Typography(displayLarge=$displayLarge, displayMedium=$displayMedium," +
525             "displaySmall=$displaySmall, " +
526             "headlineLarge=$headlineLarge, headlineMedium=$headlineMedium," +
527             " headlineSmall=$headlineSmall, " +
528             "titleLarge=$titleLarge, titleMedium=$titleMedium, titleSmall=$titleSmall, " +
529             "bodyLarge=$bodyLarge, bodyMedium=$bodyMedium, bodySmall=$bodySmall, " +
530             "labelLarge=$labelLarge, labelMedium=$labelMedium, labelSmall=$labelSmall, " +
531             "displayLargeEmphasized=$displayLargeEmphasized, " +
532             "displayMediumEmphasized=$displayMediumEmphasized, " +
533             "displaySmallEmphasized=$displaySmallEmphasized, " +
534             "headlineLargeEmphasized=$headlineLargeEmphasized, " +
535             "headlineMediumEmphasized=$headlineMediumEmphasized, " +
536             "headlineSmallEmphasized=$headlineSmallEmphasized, " +
537             "titleLargeEmphasized=$titleLargeEmphasized, " +
538             "titleMediumEmphasized=$titleMediumEmphasized, " +
539             "titleSmallEmphasized=$titleSmallEmphasized, " +
540             "bodyLargeEmphasized=$bodyLargeEmphasized, " +
541             "bodyMediumEmphasized=$bodyMediumEmphasized, " +
542             "bodySmallEmphasized=$bodySmallEmphasized, " +
543             "labelLargeEmphasized=$labelLargeEmphasized, " +
544             "labelMediumEmphasized=$labelMediumEmphasized, " +
545             "labelSmallEmphasized=$labelSmallEmphasized)"
546     }
547 }
548 
549 /** Helper function for component typography tokens. */
550 @OptIn(ExperimentalMaterial3ExpressiveApi::class)
fromTokennull551 internal fun Typography.fromToken(value: TypographyKeyTokens): TextStyle {
552     return when (value) {
553         TypographyKeyTokens.DisplayLarge -> displayLarge
554         TypographyKeyTokens.DisplayMedium -> displayMedium
555         TypographyKeyTokens.DisplaySmall -> displaySmall
556         TypographyKeyTokens.HeadlineLarge -> headlineLarge
557         TypographyKeyTokens.HeadlineMedium -> headlineMedium
558         TypographyKeyTokens.HeadlineSmall -> headlineSmall
559         TypographyKeyTokens.TitleLarge -> titleLarge
560         TypographyKeyTokens.TitleMedium -> titleMedium
561         TypographyKeyTokens.TitleSmall -> titleSmall
562         TypographyKeyTokens.BodyLarge -> bodyLarge
563         TypographyKeyTokens.BodyMedium -> bodyMedium
564         TypographyKeyTokens.BodySmall -> bodySmall
565         TypographyKeyTokens.LabelLarge -> labelLarge
566         TypographyKeyTokens.LabelMedium -> labelMedium
567         TypographyKeyTokens.LabelSmall -> labelSmall
568         TypographyKeyTokens.DisplayLargeEmphasized -> displayLargeEmphasized
569         TypographyKeyTokens.DisplayMediumEmphasized -> displayMediumEmphasized
570         TypographyKeyTokens.DisplaySmallEmphasized -> displaySmallEmphasized
571         TypographyKeyTokens.HeadlineLargeEmphasized -> headlineLargeEmphasized
572         TypographyKeyTokens.HeadlineMediumEmphasized -> headlineMediumEmphasized
573         TypographyKeyTokens.HeadlineSmallEmphasized -> headlineSmallEmphasized
574         TypographyKeyTokens.TitleLargeEmphasized -> titleLargeEmphasized
575         TypographyKeyTokens.TitleMediumEmphasized -> titleMediumEmphasized
576         TypographyKeyTokens.TitleSmallEmphasized -> titleSmallEmphasized
577         TypographyKeyTokens.BodyLargeEmphasized -> bodyLargeEmphasized
578         TypographyKeyTokens.BodyMediumEmphasized -> bodyMediumEmphasized
579         TypographyKeyTokens.BodySmallEmphasized -> bodySmallEmphasized
580         TypographyKeyTokens.LabelLargeEmphasized -> labelLargeEmphasized
581         TypographyKeyTokens.LabelMediumEmphasized -> labelMediumEmphasized
582         TypographyKeyTokens.LabelSmallEmphasized -> labelSmallEmphasized
583     }
584 }
585 
586 internal val TypographyKeyTokens.value: TextStyle
587     @Composable @ReadOnlyComposable get() = MaterialTheme.typography.fromToken(this)
588 
<lambda>null589 internal val LocalTypography = staticCompositionLocalOf { Typography() }
590