1 line
1.2 KiB
Plaintext
1 line
1.2 KiB
Plaintext
{"version":3,"file":"loadFontCSS.mjs","sources":["../../../../src/scene/text-html/utils/loadFontCSS.ts"],"sourcesContent":["import { loadFontAsBase64 } from './loadFontAsBase64';\n\nexport interface FontCSSStyleOptions\n{\n fontFamily: string | string[]\n fontWeight: string\n fontStyle: string\n}\n\n/**\n * This will take a font url and a style and return a css string that can be injected into a style tag\n * This will contain inlined base64 font and the font family information\n * @param style - the style to generate the css for\n * @param url - The url to load the font from\n * @returns - The css string\n */\nexport async function loadFontCSS(style: FontCSSStyleOptions, url: string): Promise<string>\n{\n const dataSrc = await loadFontAsBase64(url);\n\n return `@font-face {\n font-family: \"${style.fontFamily}\";\n src: url('${dataSrc}');\n font-weight: ${style.fontWeight};\n font-style: ${style.fontStyle};\n }`;\n}\n"],"names":[],"mappings":";;;AAgBsB,eAAA,WAAA,CAAY,OAA4B,GAC9D,EAAA;AACI,EAAM,MAAA,OAAA,GAAU,MAAM,gBAAA,CAAiB,GAAG,CAAA,CAAA;AAE1C,EAAO,OAAA,CAAA;AAAA,sBAAA,EACa,MAAM,UAAU,CAAA;AAAA,kBAAA,EACpB,OAAO,CAAA;AAAA,qBAAA,EACJ,MAAM,UAAU,CAAA;AAAA,oBAAA,EACjB,MAAM,SAAS,CAAA;AAAA,KAAA,CAAA,CAAA;AAErC;;;;"} |