Initial filename work

This commit is contained in:
be5invis 2023-11-11 17:12:56 -08:00
parent 3c122b72a0
commit 8dbb7c6e23
178 changed files with 411 additions and 4170 deletions

View file

@ -35,14 +35,14 @@ const MAKE_TTC = ["node", "node_modules/otb-ttc-bundle/bin/otb-ttc-bundle"];
const SEVEN_ZIP = process.env.SEVEN_ZIP_PATH || "7z";
const TTFAUTOHINT = process.env.TTFAUTOHINT_PATH || "ttfautohint";
const defaultWebFontFormats = ["woff2", "ttf"];
const webfontFormatsFast = ["ttf"];
const webfontFormatsPages = ["woff2"];
const defaultWebFontFormats = ["WOFF2", "TTF"];
const webfontFormatsFast = ["TTF"];
const webfontFormatsPages = ["WOFF2"];
const WIDTH_NORMAL = "normal";
const WEIGHT_NORMAL = "regular";
const SLOPE_NORMAL = "upright";
const DEFAULT_SUBFAMILY = "regular";
const WIDTH_NORMAL = "Normal";
const WEIGHT_NORMAL = "Regular";
const SLOPE_NORMAL = "Upright";
const DEFAULT_SUBFAMILY = "Regular";
const BUILD_PLANS = "build-plans.toml";
const PRIVATE_BUILD_PLANS = "private-build-plans.toml";
@ -389,12 +389,12 @@ function whyBuildPlanIsnNotThere(gid) {
const ageKey = uuid.v4();
const DistUnhintedTTF = file.make(
(gr, fn) => `${DIST}/${gr}/ttf-unhinted/${fn}.ttf`,
(gr, fn) => `${DIST}/${gr}/TTF-Unhinted/${fn}.ttf`,
async (target, out, gr, fn) => {
await target.need(Scripts, Parameters, Dependencies, de(out.dir));
const [fi] = await target.need(FontInfoOf(fn));
const charMapDir = `${BUILD}/ttf/${gr}`;
const charMapDir = `${BUILD}/TTF/${gr}`;
const charMapPath = `${charMapDir}/${fn}.charmap.mpz`;
const ttfaControlsPath = `${charMapDir}/${fn}.ttfa.txt`;
@ -459,21 +459,21 @@ const DistUnhintedTTF = file.make(
);
const BuildCM = file.make(
(gr, f) => `${BUILD}/ttf/${gr}/${f}.charmap.mpz`,
(gr, f) => `${BUILD}/TTF/${gr}/${f}.charmap.mpz`,
async (target, output, gr, f) => {
await target.need(DistUnhintedTTF(gr, f));
}
);
const BuildTtfaControls = file.make(
(gr, f) => `${BUILD}/ttf/${gr}/${f}.ttfa.txt`,
(gr, f) => `${BUILD}/TTF/${gr}/${f}.ttfa.txt`,
async (target, output, gr, f) => {
await target.need(DistUnhintedTTF(gr, f));
}
);
const DistHintedTTF = file.make(
(gr, fn) => `${DIST}/${gr}/ttf/${fn}.ttf`,
(gr, fn) => `${DIST}/${gr}/TTF/${fn}.ttf`,
async (target, out, gr, fn) => {
const [fi, hint] = await target.need(
FontInfoOf(fn),
@ -485,7 +485,7 @@ const DistHintedTTF = file.make(
// normally-spaced variant.
const spD = fi.spacingDerive;
const charMapDir = `${BUILD}/ttf/${gr}`;
const charMapDir = `${BUILD}/TTF/${gr}`;
const noGcTtfPath = `${charMapDir}/${fn}.no-gc.hinted.ttf`;
const [deriveFrom] = await target.need(
@ -512,7 +512,7 @@ const DistHintedTTF = file.make(
);
const BuildNoGcTtfImpl = file.make(
(gr, f) => `${BUILD}/ttf/${gr}/${f}.no-gc.hinted.ttf`,
(gr, f) => `${BUILD}/TTF/${gr}/${f}.no-gc.hinted.ttf`,
async (target, output, gr, f) => {
await target.need(DistHintedTTF(gr, f));
}
@ -533,10 +533,10 @@ const BuildNoGcTtf = task.make(
);
function formatSuffix(fmt, unhinted) {
return fmt + (unhinted ? "-unhinted" : "");
return fmt + (unhinted ? "-Unhinted" : "");
}
const DistWoff2 = file.make(
(gr, fn, unhinted) => `${DIST}/${gr}/${formatSuffix("woff2", unhinted)}/${fn}.woff2`,
(gr, fn, unhinted) => `${DIST}/${gr}/${formatSuffix("WOFF2", unhinted)}/${fn}.woff2`,
async (target, out, group, f, unhinted) => {
const Ctor = unhinted ? DistUnhintedTTF : DistHintedTTF;
@ -598,7 +598,7 @@ async function createWebFontCssImpl(target, output, gr, formats, unhinted) {
// Content files
const GroupTtfsImpl = task.make(
(gr, unhinted) => `group-${formatSuffix("ttf-impl", unhinted)}::${gr}`,
(gr, unhinted) => `group-${formatSuffix("TTFImpl", unhinted)}::${gr}`,
async (target, gr, unhinted) => {
const Ctor = unhinted ? DistUnhintedTTF : DistHintedTTF;
const [ts] = await target.need(GroupFontsOf(gr));
@ -607,7 +607,7 @@ const GroupTtfsImpl = task.make(
}
);
const GroupWoff2Impl = task.make(
(gr, unhinted) => `group-${formatSuffix("woff2-impl", unhinted)}::${gr}`,
(gr, unhinted) => `group-${formatSuffix("WOFF2Impl", unhinted)}::${gr}`,
async (target, gr, unhinted) => {
const [ts] = await target.need(GroupFontsOf(gr));
await target.need(ts.map(tn => DistWoff2(gr, tn, unhinted)));
@ -615,16 +615,16 @@ const GroupWoff2Impl = task.make(
}
);
const GroupWebFontsImpl = task.make(
(gr, unhinted) => `group-${formatSuffix("webfont-impl", unhinted)}::${gr}`,
(gr, unhinted) => `group-${formatSuffix("WebFontImpl", unhinted)}::${gr}`,
async (target, gr, unhinted) => {
const [bp] = await target.need(BuildPlanOf(gr));
const groupsNeeded = [];
for (const ext of bp.webfontFormats) {
switch (ext) {
case "ttf":
case "TTF":
groupsNeeded.push(GroupTtfsImpl(gr, unhinted));
break;
case "woff2":
case "WOFF2":
groupsNeeded.push(GroupWoff2Impl(gr, unhinted));
break;
}
@ -655,7 +655,7 @@ async function getCollectPlans(target, rawCollectPlans) {
const amendedRawCollectPlans = { ...rawCollectPlans };
for (const gr of allCollectableGroups) {
amendedRawCollectPlans[`sgr-` + gr] = { release: true, isAmended: true, from: [gr] };
amendedRawCollectPlans[`SGr-` + gr] = { release: true, isAmended: true, from: [gr] };
}
for (const collectPrefix in amendedRawCollectPlans) {
@ -780,7 +780,7 @@ async function buildGlyphSharingTtc(target, parts, out) {
// Collection Archives
const TtcZip = file.make(
(cgr, version) => `${ARCHIVE_DIR}/ttc-${cgr}-${version}.zip`,
(cgr, version) => `${ARCHIVE_DIR}/PkgTTC-${cgr}-${version}.zip`,
async (target, out, cgr) => {
const [cPlan] = await target.need(CollectPlans, de`${out.dir}`);
const ttcFiles = Array.from(Object.keys(cPlan[cgr].ttcComposition));
@ -789,7 +789,7 @@ const TtcZip = file.make(
}
);
const SuperTtcZip = file.make(
(cgr, version) => `${ARCHIVE_DIR}/super-ttc-${cgr}-${version}.zip`,
(cgr, version) => `${ARCHIVE_DIR}/SuperTTC-${cgr}-${version}.zip`,
async (target, out, cgr) => {
await target.need(de`${out.dir}`, CollectedSuperTtcFile(cgr));
await CreateGroupArchiveFile(DIST_SUPER_TTC, out, `${cgr}.ttc`);
@ -799,12 +799,12 @@ const SuperTtcZip = file.make(
// Single-group Archives
const GroupTtfZip = file.make(
(gr, version, unhinted) =>
`${ARCHIVE_DIR}/${formatSuffix("ttf", unhinted)}-${gr}-${version}.zip`,
`${ARCHIVE_DIR}/${formatSuffix("PkgTTF", unhinted)}-${gr}-${version}.zip`,
async (target, out, gr, _version_, unhinted) => {
await target.need(de`${out.dir}`);
await target.need(GroupTtfsImpl(gr, unhinted));
await CreateGroupArchiveFile(
`${DIST}/${gr}/${formatSuffix("ttf", unhinted)}`,
`${DIST}/${gr}/${formatSuffix("TTF", unhinted)}`,
out,
"*.ttf"
);
@ -812,7 +812,7 @@ const GroupTtfZip = file.make(
);
const GroupWebZip = file.make(
(gr, version, unhinted) =>
`${ARCHIVE_DIR}/${formatSuffix("webfont", unhinted)}-${gr}-${version}.zip`,
`${ARCHIVE_DIR}/${formatSuffix("PkgWebFont", unhinted)}-${gr}-${version}.zip`,
async (target, out, gr, _version_, unhinted) => {
const [plan] = await target.need(BuildPlanOf(gr));
await target.need(de`${out.dir}`);
@ -848,14 +848,14 @@ async function CreateGroupArchiveFile(dir, out, ...files) {
const Pages = task(`pages`, async t => {
await t.need(
PagesDataExport,
PagesFontExport`iosevka`,
PagesFontExport`iosevka-slab`,
PagesFontExport`iosevka-aile`,
PagesFontExport`iosevka-etoile`,
PagesFontExport`iosevka-QP`,
PagesFontExport`iosevka-QP-slab`,
PagesFontExport`iosevka-QPE`,
PagesFontExport`iosevka-QPE-slab`
PagesFontExport`Iosevka`,
PagesFontExport`IosevkaSlab`,
PagesFontExport`IosevkaAile`,
PagesFontExport`IosevkaEtoile`,
PagesFontExport`IosevkaQp`,
PagesFontExport`IosevkaQpSlab`,
PagesFontExport`IosevkaQpe`,
PagesFontExport`IosevkaQpeSlab`
);
});
@ -868,9 +868,9 @@ const PagesDir = oracle(`pages-dir-path`, async t => {
const PagesDataExport = task(`pages:data-export`, async t => {
const [pagesDir] = await t.need(PagesDir, Version, Parameters, UtilScripts);
const [cm, cmi, cmo] = await t.need(
BuildCM("iosevka", "iosevka-regular"),
BuildCM("iosevka", "iosevka-italic"),
BuildCM("iosevka", "iosevka-oblique")
BuildCM("Iosevka", "Iosevka-Regular"),
BuildCM("Iosevka", "Iosevka-Italic"),
BuildCM("Iosevka", "Iosevka-Oblique")
);
await node(`utility/export-tokenized-sample-code.mjs`, {
output: Path.resolve(pagesDir, "shared/tokenized-sample-code/alphabet.txt.json")
@ -888,18 +888,18 @@ const PagesFontExport = task.group(`pages:font-export`, async (target, gr) => {
target.is.volatile();
const [pagesDir] = await target.need(PagesDir);
if (!pagesDir) return;
const outDir = Path.resolve(pagesDir, "shared/fonts", gr);
const outDir = Path.resolve(pagesDir, "shared/fonts/imports", gr);
await target.need(GroupWebFontsImpl(gr, false), de(outDir));
await cp(`${DIST}/${gr}/woff2`, Path.resolve(outDir, "woff2"));
await cp(`${DIST}/${gr}/WOFF2`, Path.resolve(outDir, "WOFF2"));
await createWebFontCssImpl(target, Path.resolve(outDir, `${gr}.css`), gr, webfontFormatsPages);
await rm(Path.resolve(outDir, "ttf"));
await rm(Path.resolve(outDir, "TTF"));
});
const PagesFastFontExport = task.group(`pages:fast-font-export`, async (target, gr) => {
target.is.volatile();
const [pagesDir] = await target.need(PagesDir);
if (!pagesDir) return;
const outDir = Path.resolve(pagesDir, "shared/fonts", gr);
const outDir = Path.resolve(pagesDir, "shared/fonts/imports", gr);
await target.need(GroupTtfsImpl(gr, true), de(outDir));
// Next.js 12 has some problem about refreshing fonts, so write an empty CSS first
@ -907,9 +907,9 @@ const PagesFastFontExport = task.group(`pages:fast-font-export`, async (target,
await Delay(2000);
// Then do the copy
await cp(`${DIST}/${gr}/ttf-unhinted`, Path.resolve(outDir, "ttf"));
await cp(`${DIST}/${gr}/TTF-Unhinted`, Path.resolve(outDir, "TTF"));
await createWebFontCssImpl(target, Path.resolve(outDir, `${gr}.css`), gr, webfontFormatsFast);
await rm(Path.resolve(outDir, "woff2"));
await rm(Path.resolve(outDir, "WOFF2"));
});
///////////////////////////////////////////////////////////
@ -931,9 +931,9 @@ const AmendReadmeFor = task.make(
async (target, f) => {
await target.need(Parameters, UtilScripts);
const [cm, cmi, cmo] = await target.need(
BuildCM("iosevka", "iosevka-regular"),
BuildCM("iosevka", "iosevka-italic"),
BuildCM("iosevka", "iosevka-oblique")
BuildCM("Iosevka", "Iosevka-Regular"),
BuildCM("Iosevka", "Iosevka-Italic"),
BuildCM("Iosevka", "Iosevka-Oblique")
);
return node(`utility/amend-readme/index.mjs`, {
mdFilePath: f,
@ -962,15 +962,15 @@ const SampleImages = task(`sample-images`, async target => {
const SampleImagesPre = task(`sample-images:pre`, async target => {
const [version] = await target.need(Version, de(IMAGE_TASKS), UtilScripts);
const fontGroups = await target.need(
GroupTtfsImpl(`iosevka`, false),
GroupTtfsImpl(`iosevka-slab`, false),
GroupTtfsImpl(`iosevka-aile`, false),
GroupTtfsImpl(`iosevka-etoile`, false)
GroupTtfsImpl(`Iosevka`, false),
GroupTtfsImpl(`IosevkaSlab`, false),
GroupTtfsImpl(`IosevkaAile`, false),
GroupTtfsImpl(`IosevkaEtoile`, false)
);
const [cm, cmi, cmo] = await target.need(
BuildCM("iosevka", "iosevka-regular"),
BuildCM("iosevka", "iosevka-italic"),
BuildCM("iosevka", "iosevka-oblique")
BuildCM("Iosevka", "Iosevka-Regular"),
BuildCM("Iosevka", "Iosevka-Italic"),
BuildCM("Iosevka", "Iosevka-Oblique")
);
return await node("utility/generate-samples/index.mjs", {
version,
@ -989,7 +989,7 @@ const PackageSnapshotConfig = async target => {
const p = plan.buildPlans[key];
if (!p || !p.snapshotFamily) continue;
cfg.push({
name: key,
name: "package-sample-" + key,
fontFamily: p.snapshotFamily,
fontFeatures: p.snapshotFeature
});