Make webfont formats customizable (#1266).
This commit is contained in:
parent
4b38956104
commit
c2c903ebce
5 changed files with 22 additions and 16 deletions
|
@ -2,11 +2,18 @@
|
|||
|
||||
const fs = require("fs");
|
||||
|
||||
const WebfontFormatMap = new Map([
|
||||
["woff2", "woff2"],
|
||||
["ttf", "truetype"]
|
||||
]);
|
||||
module.exports = function (output, family, hs, formats) {
|
||||
let ans = ``;
|
||||
for (const ext of formats) {
|
||||
if (!WebfontFormatMap.get(ext)) throw new TypeError("Invalid webfont file format " + ext);
|
||||
}
|
||||
for (const term of hs) {
|
||||
let src = formats
|
||||
.map(([ext, format]) => `url('${ext}/${term.name}.${ext}') format('${format}')`)
|
||||
const src = formats
|
||||
.map(ext => `url('${ext}/${term.name}.${ext}') format('${WebfontFormatMap.get(ext)}')`)
|
||||
.join(", ");
|
||||
ans += `
|
||||
@font-face {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue