@@ -11,10 +11,10 @@ You can use custom fonts by adding them to the `./public/fonts` directory,
11
11
fonts. You will also need to add the ` css ` file for the font to the
12
12
` ./app/styles ` directory, if your font doesn't come with one (Google Fonts
13
13
don't) you can generate one using a tool like
14
- [ Transfonter] ( https://transfonter.org/ ) .
14
+ [ Transfonter] ( https://transfonter.org/ ) . Transfonter now has a fonts directory
15
+ setting. Set that to ` fonts ` to have the ` url ` preset.
15
16
16
- You may need to edit the ` url ` property in the ` css ` file to point to the
17
- correct location of the font files, that path is relative to the ` public `
17
+ Verify the ` url ` in the ` css ` is relative to the ` public `
18
18
folder. So it should look something like
19
19
` url('/fonts/yourfont/yourfont-200.woff2') ` .
20
20
@@ -31,14 +31,14 @@ Now you've added your font, there's a few places you need to update to use it.
31
31
}
32
32
```
33
33
34
- 2 . Add your font to the ` fontFamily ` property.
34
+ 2 . Import the default theme and add your font to the ` fontFamily ` property.
35
35
36
36
``` ts
37
+ import defaultTheme from ' tailwindcss/defaultTheme.js'
37
38
// tailwind.config.ts
38
39
extend : {
39
- ...
40
+ ... extendedTheme ,
40
41
fontFamily : {
41
- ...
42
42
sans : [' var(--font-sans)' , ... defaultTheme .fontFamily .sans ],
43
43
}
44
44
}
@@ -48,14 +48,14 @@ Now you've added your font, there's a few places you need to update to use it.
48
48
3 . Import your font stylesheet.
49
49
50
50
``` tsx
51
- // root.tsx
52
- import fontStyleSheetUrl from ' ./styles/yourfont.css'
51
+ // app/routes/ root.tsx
52
+ import fontStyleSheetUrl from ' ./styles/yourfont.css?url '
53
53
```
54
54
55
55
Add the font stylesheet to the links array.
56
56
57
57
``` tsx
58
- // root.tsx
58
+ // app/routes/ root.tsx
59
59
...
60
60
{ rel : ' preload' , href : fontStyleSheetUrl , as : ' style' },
61
61
{ rel : ' stylesheet' , href : fontStyleSheetUrl },
@@ -64,7 +64,7 @@ Now you've added your font, there's a few places you need to update to use it.
64
64
4 . Expose and cache your fonts folder.
65
65
66
66
``` ts
67
- // server.ts
67
+ // server/index .ts
68
68
...
69
69
app .use (
70
70
' /fonts' ,
0 commit comments