Skip to content

Commit 24d11d9

Browse files
committed
feat(minor): add support for custom font family via UserTheme
1 parent 5ffa098 commit 24d11d9

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/theme/styles.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ import spacing from "./spacing";
33
import colors, { type ColorsPropType } from "./colors";
44
import type { MarkedStyles, UserTheme } from "./types";
55

6-
const getFontStyles = (mdColors: ColorsPropType) => {
6+
const getFontStyles = (mdColors: ColorsPropType, fontFamily?: string) => {
77
return StyleSheet.create({
88
regular: {
9+
fontFamily: fontFamily,
910
fontSize: 16,
1011
lineHeight: 24,
1112
color: mdColors.text,
1213
},
1314
heading: {
15+
fontFamily: fontFamily,
1416
fontWeight: "500",
1517
color: mdColors.text,
1618
},
@@ -25,7 +27,7 @@ const getStyles = (
2527
const mdColors = { ...colors[colorScheme || "light"], ...userTheme?.colors };
2628
const mdSpacing = { ...spacing, ...userTheme?.spacing };
2729

28-
const fontStyle = getFontStyles(mdColors);
30+
const fontStyle = getFontStyles(mdColors, userTheme?.fontFamily);
2931
const defaultStyles = StyleSheet.create<MarkedStyles>({
3032
em: {
3133
...fontStyle.regular,
@@ -59,6 +61,7 @@ const getStyles = (
5961
opacity: 0.8,
6062
},
6163
h1: {
64+
fontFamily: userTheme?.fontFamily,
6265
fontSize: 32,
6366
lineHeight: 40,
6467
fontWeight: "bold",

src/theme/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ export interface MarkedStyles {
3030
export interface UserTheme {
3131
colors?: Record<ColorKeysType, string>;
3232
spacing?: Record<SpacingKeysType, number>;
33+
fontFamily?: string | undefined;
3334
}

0 commit comments

Comments
 (0)