Add support for private-build-plane.toml
This commit is contained in:
parent
8e34152e9c
commit
b82ce595ce
3 changed files with 38 additions and 24 deletions
25
README.md
25
README.md
|
@ -55,7 +55,9 @@ You will find TTFs, as well as WOFF(2) web fonts and one Webfont CSS in the `dis
|
|||
|
||||
Since version 2.0, Iosevka would no longer support building via `makefile`. To initialize a custom build, you need:
|
||||
|
||||
1. Add a new term into `buildPlans` in `build-plans.toml`, following this format:
|
||||
1. Create `private-build-plans.toml` file.
|
||||
|
||||
2. Add a build plan into `private-build-plans.toml`, following this format:
|
||||
|
||||
```toml
|
||||
[buildPlans.iosevka-custom] # <iosevka-custom> is your plan name
|
||||
|
@ -64,9 +66,28 @@ Since version 2.0, Iosevka would no longer support building via `makefile`. To i
|
|||
upright = ["upright-only", "styles"] # Upright-only styles
|
||||
italic = ["italic-only", "styles"] # Italic-only styles
|
||||
oblique = ["oblique-only", "styles"] # Oblique-only styles
|
||||
|
||||
# Override default building weights
|
||||
# When buildPlans.<plan name>.weights is absent
|
||||
# All weights would built and mapped to default shape/CSS
|
||||
[buildPlans.iosevka-custom.weights.regular]
|
||||
shape = 400 # Weight of glyph shapes
|
||||
css = 400 # Weight of menu and CSS
|
||||
|
||||
[buildPlans.iosevka-custom.weights.bold]
|
||||
shape = 700
|
||||
css = 700
|
||||
|
||||
# Override default building slant sets
|
||||
# Format: <upright|italic|oblique> = <"normal"|"italic"|"oblique">
|
||||
# When this section is absent, all slants would be built.
|
||||
[buildPlans.iosevka-custom.slants]
|
||||
upright = "normal"
|
||||
italic = "italic"
|
||||
oblique = "oblique"
|
||||
```
|
||||
|
||||
2. Run `npm run build -- contents:<your plan name>` and the built fonts would be avaliable in `dist/`. Aside from `contents:<plan>`, other options are:
|
||||
3. Run `npm run build -- contents:<your plan name>` and the built fonts would be avaliable in `dist/`. Aside from `contents:<plan>`, other options are:
|
||||
|
||||
1. `contents:<plan>` : TTF (Hinted and Unhinted), WOFF(2) and Webfont CSS;
|
||||
2. `ttf:<plan>` : TTF;
|
||||
|
|
|
@ -176,7 +176,6 @@ from = [
|
|||
# Weight mappings (style => shape weight, CSS weight)
|
||||
# Shape weight : affects the shape of the glyphs
|
||||
# CSS weight : affects the font menu name and webfont CSS
|
||||
# Comment the lines to build less weights
|
||||
[weights.thin]
|
||||
shape = 100
|
||||
css = 100
|
||||
|
@ -220,18 +219,3 @@ css = 900
|
|||
upright = "normal"
|
||||
italic = "italic"
|
||||
oblique = "oblique"
|
||||
|
||||
|
||||
################################################
|
||||
# To define your custom build #
|
||||
# Add a new term into buildPlans #
|
||||
# and run `npm run build -- fonts:<plan name>` #
|
||||
################################################
|
||||
# [buildPlans.iosevka-custom] # <iosevka-custom> is your plan name
|
||||
# family = "Iosevka Custom" # Font menu family name
|
||||
# design = ["common styles"] # Common styles
|
||||
# upright = ["upright-only", "styles"] # Upright-only styles
|
||||
# italic = ["italic-only", "styles"] # Italic-only styles
|
||||
# oblique = ["oblique-only", "styles"] # Oblique-only styles
|
||||
# weights = ["regular", "bold"] # Build only regular and bold fonts
|
||||
# slants = ["upright", "italic"] # Build only upright and italic fonts
|
||||
|
|
21
verdafile.js
21
verdafile.js
|
@ -86,8 +86,7 @@ oracle("o:slants").def(async target => {
|
|||
return rp.slants;
|
||||
});
|
||||
|
||||
oracle(`o:suffixes`).def(async target => {
|
||||
const [weights, slants] = await target.need(`o:weights`, `o:slants`);
|
||||
function getSuffixSet(weights, slants) {
|
||||
const mapping = {};
|
||||
for (const w in weights) {
|
||||
for (const s in slants) {
|
||||
|
@ -104,18 +103,28 @@ oracle(`o:suffixes`).def(async target => {
|
|||
}
|
||||
}
|
||||
return mapping;
|
||||
}
|
||||
|
||||
oracle(`o:suffixes`).def(async target => {
|
||||
const [weights, slants] = await target.need(`o:weights`, `o:slants`);
|
||||
return getSuffixSet(weights, slants);
|
||||
});
|
||||
|
||||
oracle(`o:font-building-parameters`).def(async target => {
|
||||
const [buildPlans, suffixMapping] = await target.need(`o:build-plans`, `o:suffixes`);
|
||||
const [buildPlans, defaultWeights, defaultSlants] = await target.need(
|
||||
`o:build-plans`,
|
||||
`o:weights`,
|
||||
`o:slants`
|
||||
);
|
||||
const fontInfos = {};
|
||||
const bp = {};
|
||||
for (const p in buildPlans) {
|
||||
const { pre, post, prefix, family, weights, slants } = buildPlans[p];
|
||||
const targets = [];
|
||||
const suffixMapping = getSuffixSet(weights || defaultWeights, slants || defaultSlants);
|
||||
for (const suffix in suffixMapping) {
|
||||
if (weights && !weights.includes(suffixMapping[suffix].weight)) continue;
|
||||
if (slants && !slants.includes(suffixMapping[suffix].slant)) continue;
|
||||
if (weights && !weights[suffixMapping[suffix].weight]) continue;
|
||||
if (slants && !slants[suffixMapping[suffix].slant]) continue;
|
||||
const fileName = [prefix, suffix].join("-");
|
||||
const preHives = [...pre.design, ...pre[suffixMapping[suffix].slant]];
|
||||
const postHives = [...post.design, ...post[suffixMapping[suffix].slant]];
|
||||
|
@ -223,7 +232,7 @@ file(`${DIST}/*/ttf/*.ttf`).def(async (target, dir, file) => {
|
|||
`${DIST}/${dir}/ttf-unhinted/${file}.ttf`,
|
||||
`dir:${target.path.dir}`
|
||||
);
|
||||
await run("ttfautohint", "-c", from.full, target.path.full);
|
||||
await run("ttfautohint", from.full, target.path.full);
|
||||
});
|
||||
file(`${DIST}/*/woff/*.woff`).def(async (target, dir, file) => {
|
||||
const [from] = await target.need(`${DIST}/${dir}/ttf/${file}.ttf`, `dir:${target.path.dir}`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue