/
githubmirror
/
pixijs
Обзор
Документация
Войти
/
githubmirror
/
pixijs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
src/scene/text-html/utils/loadFontAsBase64.ts
25 строк
658 B
Zyie
chore: documentation overhaul with typedoc (#11423)
19 май 2025, 11:44
Не верифицирован
19 май 2025, 11:44
34926f0
Код
Авторство
О чём код?
import { DOMAdapter } from '../../../environment/adapter'; /** * Resolves a font url to a base64 string * @param url - The url to load the font from * @returns - The font as a base64 string * @internal */ export async function loadFontAsBase64(url: string): Promise<string> { const response = await DOMAdapter.get().fetch(url); const blob = await response.blob(); const reader = new FileReader(); const dataSrc: string = await new Promise((resolve, reject) => { reader.onloadend = () => resolve(reader.result as string); reader.onerror = reject; reader.readAsDataURL(blob); }); return dataSrc; }