forked from android/compose-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Type.kt
123 lines (118 loc) · 3.37 KB
/
Type.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* Copyright 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.owl.ui.theme
import androidx.compose.material.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.em
import androidx.compose.ui.unit.sp
import com.example.owl.R
private val fonts = FontFamily(
Font(R.font.rubik_regular),
Font(R.font.rubik_medium, FontWeight.W500),
Font(R.font.rubik_bold, FontWeight.Bold)
)
val typography = typographyFromDefaults(
h1 = TextStyle(
fontFamily = fonts,
fontWeight = FontWeight.Bold
),
h2 = TextStyle(
fontFamily = fonts,
fontWeight = FontWeight.Bold
),
h3 = TextStyle(
fontFamily = fonts,
fontWeight = FontWeight.Bold
),
h4 = TextStyle(
fontFamily = fonts,
fontWeight = FontWeight.Bold,
lineHeight = 40.sp
),
h5 = TextStyle(
fontFamily = fonts,
fontWeight = FontWeight.Bold
),
h6 = TextStyle(
fontFamily = fonts,
fontWeight = FontWeight.W500,
lineHeight = 28.sp
),
subtitle1 = TextStyle(
fontFamily = fonts,
fontWeight = FontWeight.W500,
lineHeight = 22.sp
),
subtitle2 = TextStyle(
fontFamily = fonts,
fontWeight = FontWeight.W500
),
body1 = TextStyle(
fontFamily = fonts,
fontWeight = FontWeight.Normal,
lineHeight = 28.sp
),
body2 = TextStyle(
fontFamily = fonts,
fontWeight = FontWeight.Normal,
lineHeight = 16.sp
),
button = TextStyle(
fontFamily = fonts,
fontWeight = FontWeight.Bold
),
caption = TextStyle(
fontFamily = fonts
),
overline = TextStyle(
letterSpacing = 0.08.em
)
)
fun typographyFromDefaults(
h1: TextStyle?,
h2: TextStyle?,
h3: TextStyle?,
h4: TextStyle?,
h5: TextStyle?,
h6: TextStyle?,
subtitle1: TextStyle?,
subtitle2: TextStyle?,
body1: TextStyle?,
body2: TextStyle?,
button: TextStyle?,
caption: TextStyle?,
overline: TextStyle?
): Typography {
val defaults = Typography()
return Typography(
h1 = defaults.h1.merge(h1),
h2 = defaults.h2.merge(h2),
h3 = defaults.h3.merge(h3),
h4 = defaults.h4.merge(h4),
h5 = defaults.h5.merge(h5),
h6 = defaults.h6.merge(h6),
subtitle1 = defaults.subtitle1.merge(subtitle1),
subtitle2 = defaults.subtitle2.merge(subtitle2),
body1 = defaults.body1.merge(body1),
body2 = defaults.body2.merge(body2),
button = defaults.button.merge(button),
caption = defaults.caption.merge(caption),
overline = defaults.overline.merge(overline)
)
}