Make webfont formats customizable (#1266).
This commit is contained in:
parent
4b38956104
commit
c2c903ebce
5 changed files with 22 additions and 16 deletions
|
@ -1 +1,2 @@
|
|||
* Make webfont formats customizable (#1266).
|
||||
* Fix localization of Macedonian GJE (#1267).
|
|
@ -63,6 +63,7 @@ Inside the plan, top-level properties include:
|
|||
* `no-cv-ss`: Optional, Boolean, disables `cv##` and `ss##` OpenType features.
|
||||
* `no-ligation`: Optional, Boolean, disables ligations.
|
||||
* `export-glyph-names`: Optional, Boolean, whether to export glyph names into the fonts. Setting this to `true` will increase file footprint, however this is necessary for ligature support in [Kitty](https://sw.kovidgoyal.net/kitty/).
|
||||
* `webfont-formats`: Optional, Array of String. Controls the formats needed to be exported into the webfont CSS. Valid options are `'ttf'` and `'woff2'`, or including both.
|
||||
|
||||
Build plan could have 5 optional subsections: `ligations`, `variants`, `weights`, `widths` and `slopes`.
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ family = "Iosevka Custom" # Font menu family name
|
|||
spacing = "normal" # Optional; Values: `normal`, `term`, `fontconfig-mono`, or `fixed`
|
||||
serifs = "sans" # Optional; Values: `sans` or `slab`
|
||||
|
||||
webfont-formats = ['ttf', 'woff2']
|
||||
|
||||
###################################################################################################
|
||||
# Configure variants
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
23
verdafile.js
23
verdafile.js
|
@ -26,12 +26,10 @@ const ARCHIVE_DIR = "release-archives";
|
|||
|
||||
const PATEL_C = ["node", "node_modules/patel/bin/patel-c"];
|
||||
const TTCIZE = ["node", "node_modules/otb-ttc-bundle/bin/otb-ttc-bundle"];
|
||||
const webfontFormats = [
|
||||
["woff2", "woff2"],
|
||||
["ttf", "truetype"]
|
||||
];
|
||||
const webfontFormatsFast = [["ttf", "truetype"]];
|
||||
const webfontFormatsPages = [["woff2", "woff2"]];
|
||||
|
||||
const defaultWebFontFormats = ["ttf", "woff2"];
|
||||
const webfontFormatsFast = ["ttf"];
|
||||
const webfontFormatsPages = ["woff2"];
|
||||
|
||||
const WIDTH_NORMAL = "normal";
|
||||
const WEIGHT_NORMAL = "regular";
|
||||
|
@ -129,7 +127,7 @@ const BuildPlans = computed("metadata:build-plans", async target => {
|
|||
for (const prefix in rawBuildPlans) {
|
||||
const bp = { ...rawBuildPlans[prefix] };
|
||||
validateAndShimBuildPlans(prefix, bp, rp.weights, rp.slopes, rp.widths);
|
||||
|
||||
bp.webfontFormats = bp["webfont-formats"] || defaultWebFontFormats;
|
||||
bp.targets = [];
|
||||
const weights = bp.weights,
|
||||
slopes = bp.slopes,
|
||||
|
@ -314,8 +312,9 @@ const GroupContents = task.group("contents", async (target, gr) => {
|
|||
const DistWebFontCSS = file.make(
|
||||
gr => `${DIST}/${gr}/${gr}.css`,
|
||||
async (target, out, gr) => {
|
||||
const [plan] = await target.need(BuildPlanOf(gr));
|
||||
await target.need(de(out.dir));
|
||||
await createWebFontCssImpl(target, out.full, gr, webfontFormats);
|
||||
await createWebFontCssImpl(target, out.full, gr, plan.webfontFormats);
|
||||
}
|
||||
);
|
||||
async function createWebFontCssImpl(target, output, gr, formats) {
|
||||
|
@ -547,14 +546,10 @@ const GroupTtfUnhintedArchiveFile = file.make(
|
|||
const GroupWebArchiveFile = file.make(
|
||||
(gr, version) => `${ARCHIVE_DIR}/webfont-${gr}-${version}.zip`,
|
||||
async (target, out, gr) => {
|
||||
const [plan] = await target.need(BuildPlanOf(gr));
|
||||
await target.need(de`${out.dir}`);
|
||||
await target.need(GroupContents(gr));
|
||||
await CreateGroupArchiveFile(
|
||||
`${DIST}/${gr}`,
|
||||
out,
|
||||
"*.css",
|
||||
...webfontFormats.map(([suffix, cssFormat]) => suffix)
|
||||
);
|
||||
await CreateGroupArchiveFile(`${DIST}/${gr}`, out, "*.css", ...plan.webfontFormats);
|
||||
}
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue