@uuki/svg2font
Version:
Webfont generater based on jaywcjlove/svgtofont
29 lines • 1.74 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.cssVarArrFormat = exports.cssVarFormat = exports.cssStrFormat = exports.cssFontFaceFormat = void 0;
const typeOrder = ['eot', 'woff2', 'woff', 'ttf', 'svg'];
const cssFontFaceFormat = (options) => {
const types = options.types.sort((a, b) => typeOrder.indexOf(a) - typeOrder.indexOf(b));
const format = {
eot: `url('${options.cssPath}${options.name}.eot?t=${options.timestamp}#iefix') format('embedded-opentype')/* IE6-IE8 */`,
woff: `url("${options.cssPath}${options.name}.woff?t=${options.timestamp}") format("woff")`,
woff2: `url("${options.cssPath}${options.name}.woff2?t=${options.timestamp}") format("woff2")`,
ttf: `url('${options.cssPath}${options.name}.ttf?t=${options.timestamp}') format('truetype')/* chrome, firefox, opera, Safari, Android, iOS 4.2+*/`,
svg: `url('${options.cssPath}${options.name}.svg?t=${options.timestamp}#{{fontname}}') format('svg')/* iOS 4.1- */`,
};
return `@font-face {
font-family: '${options.name}';
${types.includes('eot')
? `src: url('${options.cssPath}${options.name}.eot?t=${options.timestamp}'); /* IE9*/`
: ''}
src: ${types.map((type) => format[type]).join(',\n')};
}`;
};
exports.cssFontFaceFormat = cssFontFaceFormat;
const cssStrFormat = (name, code, prefix) => `.${prefix}-${name}:before { content: "\\${code}"; }`;
exports.cssStrFormat = cssStrFormat;
const cssVarFormat = (name, code, prefix) => `$${prefix}-${name}: "\\${code}";`;
exports.cssVarFormat = cssVarFormat;
const cssVarArrFormat = (name, code) => ` ${name}: "\\${code}",`;
exports.cssVarArrFormat = cssVarArrFormat;
//# sourceMappingURL=templateFormat.js.map