UNPKG

pixi.js

Version:

<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">

1 lines 1.72 kB
{"version":3,"file":"loadFontCSS.mjs","sources":["../../../../src/scene/text-html/utils/loadFontCSS.ts"],"sourcesContent":["import { loadFontAsBase64 } from './loadFontAsBase64';\n\n/**\n * Options for the font CSS style\n * @category text\n * @internal\n */\nexport interface FontCSSStyleOptions\n{\n /**\n * The font family to use in the CSS\n * @example\n * 'Arial' or ['Arial', 'Helvetica']\n */\n fontFamily: string | string[]\n /**\n * The font weight to use in the CSS\n * @example\n * 'normal', 'bold', '100', '200', etc.\n */\n fontWeight: string\n /**\n * The font style to use in the CSS\n * @example\n * 'normal', 'italic', 'oblique'\n */\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 * @internal\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":";;;AAqCsB,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;;;;"}