/
with-local-fonts.js
153 lines (147 loc) · 3.12 KB
/
with-local-fonts.js
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import localFont from '@next/font/local'
const myFont1 = localFont({
src: '../fonts/my-font.woff2',
style: 'italic',
weight: '100',
fallback: ['system-ui'],
adjustFontFallback: 'Times New Roman',
})
const myFont2 = localFont({
src: '../fonts/my-other-font.woff2',
preload: false,
variable: '--my-font',
})
const roboto = localFont({
preload: false,
src: [
{
path: '../fonts/roboto/roboto-100-italic.woff2',
weight: '100',
style: 'italic',
},
{
path: '../fonts/my-font.woff2',
weight: '100',
style: 'normal',
},
{
path: '../fonts/my-font.woff2',
weight: '400',
style: 'italic',
},
{
path: '../fonts/roboto/roboto-400.woff2',
weight: '400',
},
{
path: '../fonts/my-font.woff2',
style: 'italic',
},
{
path: '../fonts/my-font.woff2',
weight: '900',
style: 'normal',
},
],
})
const robotoVar1 = localFont({
preload: false,
src: [
{
path: '../fonts/roboto/roboto-400.woff2',
weight: '100 300',
style: 'normal',
},
{
path: '../fonts/my-font.woff2',
weight: '100 300',
style: 'italic',
},
{
path: '../fonts/my-font.woff2',
weight: '500 900',
style: 'italic',
},
{
path: '../fonts/my-font.woff2',
weight: '500 900',
style: 'normal',
},
],
})
const robotoVar2 = localFont({
preload: false,
src: [
{
path: '../fonts/roboto/roboto-900.woff2',
weight: '100 900',
style: 'italic',
},
{
path: '../fonts/roboto/roboto-400.woff2',
weight: '100 900',
style: 'normal',
},
{
path: '../fonts/my-font.woff2',
weight: '300 399',
style: 'italic',
},
{
path: '../fonts/my-font.woff2',
weight: '401 500',
style: 'normal',
},
],
})
const robotoWithPreload = localFont({
src: [
{
path: '../fonts/roboto/roboto-100.woff2',
weight: '100',
style: 'normal',
},
{
path: '../fonts/roboto/roboto-900-italic.woff2',
weight: '900',
style: 'italic',
},
{
path: '../fonts/roboto/roboto-100.woff2',
weight: '100',
style: 'normal',
},
{
path: '../fonts/roboto/roboto-100-italic.woff2',
weight: '900',
style: 'italic',
},
],
})
export default function WithFonts() {
return (
<>
<div id="first-local-font" className={myFont1.className}>
{JSON.stringify(myFont1)}
</div>
<div id="second-local-font" className={myFont2.className}>
{JSON.stringify(myFont2)}
</div>
<div id="roboto-local-font" className={roboto.className}>
{JSON.stringify(roboto)}
</div>
<div id="roboto-local-font-var1" className={robotoVar1.className}>
{JSON.stringify(robotoVar1)}
</div>
<div id="roboto-local-font-var2" className={robotoVar2.className}>
{JSON.stringify(robotoVar2)}
</div>
<div
id="roboto-local-font-preload"
className={robotoWithPreload.className}
>
{JSON.stringify(robotoWithPreload)}
</div>
</>
)
}