parent
c107ce6d5d
commit
29f6298e2f
4 changed files with 31 additions and 7 deletions
@ -0,0 +1,15 @@ |
|||||||
|
type LoadFont = (options: { |
||||||
|
fontFamily: string; |
||||||
|
fontURL: string; |
||||||
|
}) => Promise<void>; |
||||||
|
|
||||||
|
export const loadFont: LoadFont = async (options) => { |
||||||
|
const { fontFamily, fontURL } = options; |
||||||
|
|
||||||
|
const font = new FontFace(fontFamily!, `url(${fontURL})`); |
||||||
|
await font.load(); |
||||||
|
|
||||||
|
if (document.fonts) { |
||||||
|
document?.fonts?.add(font); |
||||||
|
} |
||||||
|
}; |
Loading…
Reference in new issue