From 40b7c1452eb8edf518d76e56d44daf756a9ea523 Mon Sep 17 00:00:00 2001 From: Belleve Invis Date: Fri, 27 Dec 2019 06:21:31 -0800 Subject: [PATCH] Widths --- build-plans.toml | 73 +++++++++++++++++++++++++++---------- gen/generator.js | 1 + meta/naming.ptl | 10 ++--- parameters.toml | 16 ++------ utility/make-webfont-css.js | 2 + verdafile.js | 62 ++++++++++++++++++++----------- 6 files changed, 105 insertions(+), 59 deletions(-) diff --git a/build-plans.toml b/build-plans.toml index 54df670ef..8845b2da4 100644 --- a/build-plans.toml +++ b/build-plans.toml @@ -82,6 +82,7 @@ design = ["termlig", "slab", "shape-curly-bar", "v-at-fourfold"] family = "IosevkaCC Curly Slab" design = ["cc", "slab", "shape-curly-bar", "v-at-fourfold"] +################################################################################################### # SSxx [buildPlans.iosevka-ss01] family = "Iosevka SS01" @@ -286,8 +287,8 @@ design = ["type", "ss12"] family = "Iosevka TermLig SS12" design = ["termlig", "ss12"] - - +################################################################################################### +# Proportional families [buildPlans.iosevka-aile] family = "Iosevka Aile" design = ["type", "v-at-fourfold", "v-j-narrow", 'v-capital-i-straight', 'v-capital-j-straight', 'v-g-singlestorey', 'v-r-narrow', "no-cv-ss", "no-ligation"] @@ -296,7 +297,15 @@ italic = ["v-i-line", "v-l-line", 'v-f-narrow', 'v-t-narrow'] oblique = ["v-i-line", "v-l-line", 'v-f-narrow', 'v-t-narrow'] [buildPlans.iosevka-aile.post] -design = ['wd-extended', "diversity-2"] +design = ["diversity-2"] + +[buildPlans.iosevka-aile.widths.normal] +shape = 7 +menu = 5 +css = "normal" + + + [buildPlans.iosevka-etoile] family = "Iosevka Etoile" @@ -306,7 +315,15 @@ italic = ['v-i-italic', 'v-l-italic'] oblique = ['v-i-serifed', 'v-l-serifed'] [buildPlans.iosevka-etoile.post] -design = ['wd-extended', "diversity-1"] +design = ["diversity-1"] + +[buildPlans.iosevka-etoile.widths.normal] +shape = 7 +menu = 5 +css = "normal" + + + [buildPlans.iosevka-sparkle] family = "Iosevka Sparkle" @@ -316,21 +333,15 @@ italic = ['v-i-italic', 'v-l-italic', "v-f-tailed", 'v-r-standard'] oblique = ['v-i-serifed', 'v-l-serifed', "v-f-force-serifed", "v-r-force-serifed"] [buildPlans.iosevka-sparkle.post] -design = ['wd-extended', "diversity-1"] +design = ["diversity-1"] -[buildPlans.iosevka-extended] -family = "Iosevka" +[buildPlans.iosevka-sparkle.widths.normal] +shape = 7 +menu = 5 +css = "normal" -[buildPlans.iosevka-extended.post] -design = ['wd-extended', 'menu-subfamily-extended'] - -[buildPlans.iosevka-slab-extended] -family = "Iosevka Slab" -design = ["slab"] - -[buildPlans.iosevka-slab-extended.post] -design = ['wd-extended', 'menu-subfamily-extended'] +################################################################################################### # Export plans # This mapping affects the process of creating ZIP archives only [exportPlans] @@ -424,9 +435,8 @@ iosevka-term-lig-ss12 = "iosevka-term-lig-ss12" iosevka-aile = "iosevka-aile" iosevka-etoile = "iosevka-etoile" iosevka-sparkle = "iosevka-sparkle" -iosevka-extended = "iosevka-extended" -iosevka-slab-extended = "iosevka-slab-extended" +################################################################################################### # TTC collection plans [collectPlans.iosevka] from = [ @@ -460,9 +470,11 @@ from = [ "iosevka-term-lig-curly-slab" ] -# Weight mappings (style => shape weight, CSS weight) +################################################################################################### +# Weight mappings (style => shape weight, menu weight, CSS weight) # Shape weight : affects the shape of the glyphs -# CSS weight : affects the font menu name and webfont CSS +# Menu weight : affects the font menu name +# CSS weight : affects the webfont CSS "font-weight" property [weights.thin] shape = 100 menu = 100 @@ -515,3 +527,24 @@ css = 900 upright = "normal" oblique = "oblique" italic = "italic" + +# Width mappings (style => shape width, menu width, CSS stretch) +# Shape width : affects the shape of the glyphs +# Menu width : affects the font menu name +# CSS stretch : affects the webfont CSS "font-stretch" property +# IMPORTANT!! +# Currently "shape" property only support 3, 5, and 7 +[widths.condensed] +shape = 3 +menu = 3 +css = "condensed" + +[widths.normal] +shape = 5 +menu = 5 +css = "normal" + +[widths.extended] +shape = 7 +menu = 7 +css = "expanded" diff --git a/gen/generator.js b/gen/generator.js index c0984a008..132469a48 100644 --- a/gen/generator.js +++ b/gen/generator.js @@ -49,6 +49,7 @@ function getParameters(argv) { family: argv.family, version: argv.ver, weight: argv["menu-weight"] - 0, + width: argv["menu-width"] - 0, slant: argv["menu-slant"] }; diff --git a/meta/naming.ptl b/meta/naming.ptl index 243970983..0b9ef94fc 100644 --- a/meta/naming.ptl +++ b/meta/naming.ptl @@ -89,7 +89,7 @@ export : define [assignFontNames para metrics font] : begin set font.name {} define family : para.naming.family.trim - define style : getStyle para.naming.weight para.menuWidth para.naming.slant + define style : getStyle para.naming.weight para.naming.width para.naming.slant define version para.naming.version define isItalic : para.naming.slant == "italic" @@ -110,7 +110,7 @@ export : define [assignFontNames para metrics font] : begin if [not : isRBIBI style] : begin if isItalic : begin set compatStyle slantToMenuStyleMap.italic - set compatFamily : family + ' ' + [getStyle para.naming.weight para.menuWidth 'normal'] + set compatFamily : family + ' ' + [getStyle para.naming.weight para.naming.width 'normal'] : else : begin set compatStyle 'Regular' set compatFamily : family + ' ' + style @@ -119,9 +119,9 @@ export : define [assignFontNames para metrics font] : begin if (compatFamily.length >= 31) : begin if isItalic : begin set compatStyle slantToMenuStyleMap.italic - set compatFamily : family + ' ' + [getShortStyle para.naming.weight para.menuWidth 'normal'] + set compatFamily : family + ' ' + [getShortStyle para.naming.weight para.naming.width 'normal'] : else : begin - local shortStyle : getShortStyle para.naming.weight para.menuWidth para.naming.slant + local shortStyle : getShortStyle para.naming.weight para.naming.width para.naming.slant set compatStyle 'Regular' set compatFamily : family + ' ' + shortStyle @@ -150,7 +150,7 @@ export : define [assignFontNames para metrics font] : begin # Weight, width and slantness set font.OS_2.usWeightClass para.naming.weight - set font.OS_2.usWidthClass para.menuWidth + set font.OS_2.usWidthClass para.naming.width set font.OS_2.panose.2 : 1 + para.naming.weight / 100 set font.OS_2.fsSelection : object oblique : not : not isOblique diff --git a/parameters.toml b/parameters.toml index bfa95d6a3..84ef0bee6 100644 --- a/parameters.toml +++ b/parameters.toml @@ -74,8 +74,6 @@ lllcrowdedness = 3.33333333 spacing = 1 # Spacing indicator -menuWidth = 5 # Menu width - # Powerline-specific parameters powerlineScaleY = 1 # Vertical scale powerlineScaleX = 1 # Horizontal scale @@ -255,7 +253,7 @@ spacing = 3 # NOTE: this section is highly experimental # HANDLE WITH EXTREME CARE # Expanded : I heard someone want it being wider... -[wd-extended.multiplies] +[wd-7.multiplies] width = 1.152 # 576mem for normal char sb = 1.375 jut = 1.15 @@ -265,20 +263,14 @@ rbalance = 1.375 tbalance = 1.100 [extended] -inherits = ['wd-extended'] - -[menu-subfamily-extended] -menuWidth = 7 +inherits = ['wd-7'] # Compressed : And someone else want it being narrower -[wd-condensed.multiplies] +[wd-3.multiplies] width = 0.9 sb = 0.9 [condensed] -inherits = ['wd-condensed'] - -[menu-subfamily-condensed] -menuWidth = 3 +inherits = ['wd-3'] [shape-curly-bar] straightBar = 0 diff --git a/utility/make-webfont-css.js b/utility/make-webfont-css.js index 86495e50f..607c1ad17 100644 --- a/utility/make-webfont-css.js +++ b/utility/make-webfont-css.js @@ -11,6 +11,7 @@ module.exports = function(output, family, hs, formats) { font-family: '${family + " Web"}'; font-display: swap; font-weight: ${term.cssWeight}; + font-stretch: ${term.cssStretch}; font-style: ${term.cssStyle}; src: ${src}; } @@ -22,6 +23,7 @@ module.exports = function(output, family, hs, formats) { font-family: '${family + " Web Oblique"}'; font-display: swap; font-weight: ${term.cssWeight}; + font-stretch: ${term.cssStretch}; src: ${src}; } `; diff --git a/verdafile.js b/verdafile.js index 22cb06c2d..f22f943e1 100644 --- a/verdafile.js +++ b/verdafile.js @@ -102,53 +102,68 @@ const RawCollectPlans = computed("raw-collect-plans", async target => { const [rp] = await target.need(RawPlans); return rp.collectPlans; }); -const Weights = computed("weights", async target => { +const Weights = computed("metadata:global-weights", async target => { const [rp] = await target.need(RawPlans); return rp.weights; }); -const Slants = computed("slants", async target => { +const Slants = computed("metadata:global-slants", async target => { const [rp] = await target.need(RawPlans); return rp.slants; }); +const Widths = computed("metadata:global-widths", async target => { + const [rp] = await target.need(RawPlans); + return rp.widths; +}); -function getSuffixSet(weights, slants) { +function getSuffixSet(weights, slants, widths) { const mapping = {}; for (const w in weights) { for (const s in slants) { - const suffix = - (w === "regular" ? (s === "upright" ? "regular" : "") : w) + - (s === "upright" ? "" : s); - mapping[suffix] = { - hives: [`w-${weights[w].shape}`, `s-${s}`], - weight: w, - cssWeight: weights[w].css || w, - menuWeight: weights[w].menu || weights[w].css || w, - slant: s, - cssStyle: slants[s] || s, - menuStyle: slants[s] || s - }; + for (const wd in widths) { + const suffix = + (wd === "normal" ? "" : wd) + + (w === "regular" ? "" : w) + + (s === "upright" ? "" : s) || "regular"; + mapping[suffix] = { + hives: [`w-${weights[w].shape}`, `s-${s}`, `wd-${widths[wd].shape}`], + weight: w, + cssWeight: weights[w].css || w, + menuWeight: weights[w].menu || weights[w].css || w, + width: wd, + cssStretch: widths[wd].css || wd, + menuWidth: widths[wd].menu || widths[wd].css || wd, + slant: s, + cssStyle: slants[s] || s, + menuStyle: slants[s] || s + }; + } } } return mapping; } const Suffixes = computed(`suffixes`, async target => { - const [weights, slants] = await target.need(Weights, Slants); - return getSuffixSet(weights, slants); + const [weights, slants, widths] = await target.need(Weights, Slants, Widths); + return getSuffixSet(weights, slants, widths); }); const FontBuildingParameters = computed(`font-building-parameters`, async target => { - const [buildPlans, defaultWeights, defaultSlants] = await target.need( + const [buildPlans, defaultWeights, defaultSlants, defaultWidths] = await target.need( BuildPlans, Weights, - Slants + Slants, + Widths ); const fontInfos = {}; const bp = {}; for (const p in buildPlans) { - const { pre, post, prefix, family, weights, slants, hintParams } = buildPlans[p]; + const { pre, post, prefix, family, weights, slants, widths, hintParams } = buildPlans[p]; const targets = []; - const suffixMapping = getSuffixSet(weights || defaultWeights, slants || defaultSlants); + const suffixMapping = getSuffixSet( + weights || defaultWeights, + slants || defaultSlants, + widths || defaultWidths + ); for (const suffix in suffixMapping) { if (weights && !weights[suffixMapping[suffix].weight]) continue; if (slants && !slants[suffixMapping[suffix].slant]) continue; @@ -160,8 +175,10 @@ const FontBuildingParameters = computed(`font-building-parameters`, async target family, hives: ["iosevka", ...preHives, ...suffixMapping[suffix].hives, ...postHives], menuWeight: suffixMapping[suffix].menuWeight, + menuWidth: suffixMapping[suffix].menuWidth, menuStyle: suffixMapping[suffix].menuStyle, cssWeight: suffixMapping[suffix].cssWeight, + cssStretch: suffixMapping[suffix].cssStretch, cssStyle: suffixMapping[suffix].cssStyle, hintParams: hintParams || [] }; @@ -227,7 +244,7 @@ const CollectionPartsOf = computed.group("collection-parts-of", async (target, i const BuildTTF = file.make( (gr, fn) => `${BUILD}/${gr}/${fn}.ttf`, async (target, output, _gr, fn) => { - const [{ hives, family, menuWeight, menuStyle }, version] = await target.need( + const [{ hives, family, menuWeight, menuStyle, menuWidth }, version] = await target.need( HivesOf(fn), Version ); @@ -244,6 +261,7 @@ const BuildTTF = file.make( ["--ver", version], ["--menu-weight", menuWeight], ["--menu-slant", menuStyle], + ["--menu-width", menuWidth], hives ); await run("otfccbuild", otdTmp, "-o", ttfTmp, "-O3", "--keep-average-char-width");