Add derived bold / italic / sans-serif / typewriter letters in Mathematical Alphanumeric Symbols block.

This commit is contained in:
be5invis 2020-11-08 18:12:14 -08:00
parent aa033e2802
commit 73619b0d6d
8 changed files with 205 additions and 39 deletions

View file

@ -440,6 +440,33 @@ no-ligation = true
snapshotFamily = 'iosevka-aile' snapshotFamily = 'iosevka-aile'
quasiProportionalDiversity = 2 quasiProportionalDiversity = 2
[buildPlans.iosevka-aile.derivingVariants.mathtt.design]
at = 'threefold'
j = 'flat-hook-serifed'
capital-i = 'serifed'
capital-j = 'serifed'
g = 'singlestorey'
r = 'straight'
a = 'doublestorey'
d = 'toothed'
u = 'toothed'
t = 'flat-hook'
[buildPlans.iosevka-aile.derivingVariants.mathtt.upright]
i = 'serifed'
l = 'serifed'
f = 'flat-hook'
[buildPlans.iosevka-aile.derivingVariants.mathtt.oblique]
i = 'serifed'
l = 'serifed'
f = 'flat-hook'
[buildPlans.iosevka-aile.derivingVariants.mathtt.italic]
i = 'italic'
l = 'italic'
f = 'flat-hook-flat-tailed'
[buildPlans.iosevka-aile.variants.design] [buildPlans.iosevka-aile.variants.design]
at = 'fourfold' at = 'fourfold'
j = 'narrow' j = 'narrow'
@ -450,18 +477,10 @@ r = 'narrow'
a = 'doublestorey' a = 'doublestorey'
d = 'toothed' d = 'toothed'
u = 'toothed' u = 'toothed'
[buildPlans.iosevka-aile.variants.upright]
i = 'line' i = 'line'
l = 'line' l = 'line'
f = 'narrow'
t = 'narrow' t = 'narrow'
[buildPlans.iosevka-aile.variants.italic]
i = 'line'
l = 'line'
f = 'narrow' f = 'narrow'
t = 'narrow'
[buildPlans.iosevka-aile.widths.normal] [buildPlans.iosevka-aile.widths.normal]
shape = 576 shape = 576
@ -486,6 +505,10 @@ j = 'serifed'
i = 'serifed' i = 'serifed'
l = 'serifed' l = 'serifed'
[buildPlans.iosevka-etoile.variants.oblique]
i = 'serifed'
l = 'serifed'
[buildPlans.iosevka-etoile.variants.italic] [buildPlans.iosevka-etoile.variants.italic]
i = 'italic' i = 'italic'
l = 'italic' l = 'italic'
@ -514,12 +537,40 @@ l = 'serifed'
f = 'serifed' f = 'serifed'
r = 'serifed' r = 'serifed'
[buildPlans.iosevka-sparkle.variants.oblique]
i = 'serifed'
l = 'serifed'
f = 'serifed'
r = 'serifed'
[buildPlans.iosevka-sparkle.variants.italic] [buildPlans.iosevka-sparkle.variants.italic]
i = 'italic' i = 'italic'
l = 'italic' l = 'italic'
f = 'tailed' f = 'tailed'
r = 'top-serifed' r = 'top-serifed'
[buildPlans.iosevka-sparkle.derivingVariants.mathtt.design]
at = 'threefold'
j = 'flat-hook-serifed'
[buildPlans.iosevka-sparkle.derivingVariants.mathtt.upright]
i = 'serifed'
l = 'serifed'
f = 'serifed'
r = 'serifed'
[buildPlans.iosevka-sparkle.derivingVariants.mathtt.oblique]
i = 'serifed'
l = 'serifed'
f = 'serifed'
r = 'serifed'
[buildPlans.iosevka-sparkle.derivingVariants.mathtt.italic]
i = 'italic'
l = 'italic'
f = 'tailed'
r = 'top-serifed'
[buildPlans.iosevka-sparkle.widths.normal] [buildPlans.iosevka-sparkle.widths.normal]
shape = 576 shape = 576
menu = 5 menu = 5

View file

@ -2,3 +2,4 @@
* Fix broken serif shapes in Italic Cyrillic Small I (#717). * Fix broken serif shapes in Italic Cyrillic Small I (#717).
* Make variant selectors for `m` and `u` have more effect on Cyrillic letters. * Make variant selectors for `m` and `u` have more effect on Cyrillic letters.
* Fix incorrect serifs of Greek Small Rho (#718). * Fix incorrect serifs of Greek Small Rho (#718).
* Add derived bold / italic / sans-serif / typewriter letters in Mathematical Alphanumeric Symbols block.

View file

@ -2,7 +2,7 @@
$$include '../../meta/macros.ptl' $$include '../../meta/macros.ptl'
import [mix linreg clamp fallback] from '../../support/utils' import [mix linreg clamp fallback] from '../../support/utils'
import [getGrMesh AnyDerivingCv CvDecompose] from "../../support/gr" import [getGrMesh AnyCv CvDecompose] from "../../support/gr"
extern Map extern Map
extern Set extern Set
@ -32,7 +32,7 @@ glyph-block Autobuild-Enclosure-Shared : begin
define [EnsureComponentGlyphT gidPart fnBuildup] : begin define [EnsureComponentGlyphT gidPart fnBuildup] : begin
local rs : new Set local rs : new Set
local gniPart : fnBuildup gidPart local gniPart : fnBuildup gidPart
local grs : AnyDerivingCv.query [query-glyph gidPart] local grs : AnyCv.query [query-glyph gidPart]
if (para.enableCvSs && grs) : foreach gr [items-of grs] : begin if (para.enableCvSs && grs) : foreach gr [items-of grs] : begin
local relatedGidPart : gr.get [query-glyph gidPart] local relatedGidPart : gr.get [query-glyph gidPart]
local gniRelated : fnBuildup relatedGidPart local gniRelated : fnBuildup relatedGidPart
@ -57,7 +57,7 @@ glyph-block Autobuild-Enclosure-Shared : begin
local demandDecomposable : para.enableCvSs && globallyDecomposable local demandDecomposable : para.enableCvSs && globallyDecomposable
foreach part [items-of parts] : if [query-glyph part] : begin foreach part [items-of parts] : if [query-glyph part] : begin
local g : query-glyph part local g : query-glyph part
local relatedGlyphs : AnyDerivingCv.query g local relatedGlyphs : AnyCv.query g
foreach gr [items-of relatedGlyphs] : if [query-glyph : gr.get g] : begin foreach gr [items-of relatedGlyphs] : if [query-glyph : gr.get g] : begin
if ([query-glyph : gr.get g].advanceWidth != g.advanceWidth) if ([query-glyph : gr.get g].advanceWidth != g.advanceWidth)
set demandDecomposable false set demandDecomposable false
@ -67,7 +67,7 @@ glyph-block Autobuild-Enclosure-Shared : begin
jobsOrig.push { origJobGlyphGn unicode parts :: restInfo } jobsOrig.push { origJobGlyphGn unicode parts :: restInfo }
if para.enableCvSs : begin if para.enableCvSs : begin
local mesh : getGrMesh parts AnyDerivingCv query-glyph local mesh : getGrMesh parts AnyCv query-glyph
foreach {gr fromParts toParts} [items-of mesh] : do foreach {gr fromParts toParts} [items-of mesh] : do
local fromGn : CircNameNoCheck unicode prefix fromParts suffix local fromGn : CircNameNoCheck unicode prefix fromParts suffix
local toGn : CircName unicode prefix toParts suffix local toGn : CircName unicode prefix toParts suffix

View file

@ -2,16 +2,15 @@
$$include '../../meta/macros.ptl' $$include '../../meta/macros.ptl'
import [linreg clamp mix fallback] from '../../support/utils' import [linreg clamp mix fallback] from '../../support/utils'
import [AnyDerivingCv DotlessOrNot getGrTree getGrMesh CvDecompose] from "../../support/gr" import [AnyCv DotlessOrNot getGrTree getGrMesh CvDecompose] from "../../support/gr"
extern Map
extern Set extern Set
glyph-module glyph-module
glyph-block Autobuild-Transformed : begin glyph-block Autobuild-Transformed-Shared : begin
glyph-block-import CommonShapes glyph-block-import CommonShapes
glyph-block-import Common-Derivatives glyph-block-import Common-Derivatives
glyph-block-import Recursive-Build : Fork Miniature
glyph-block-import Marks : markMiddle aboveMarkBot aboveMarkTop belowMarkBot belowMarkTop
define [suggestName _name] : begin define [suggestName _name] : begin
local name _name local name _name
@ -27,6 +26,7 @@ glyph-block Autobuild-Transformed : begin
set map.(key) amended set map.(key) amended
return amended return amended
glyph-block-export extendRelatedGlyphs
define [extendRelatedGlyphs records suffix] : begin define [extendRelatedGlyphs records suffix] : begin
local relatedRecords {} local relatedRecords {}
local relSets {} local relSets {}
@ -37,7 +37,7 @@ glyph-block Autobuild-Transformed : begin
suggestMappedName targetNameMap srcName (srcName + '+' + suffix) suggestMappedName targetNameMap srcName (srcName + '+' + suffix)
local dstName : srcName + '+' + suffix local dstName : srcName + '+' + suffix
local tree : getGrTree srcName {DotlessOrNot AnyDerivingCv} query-glyph local tree : getGrTree srcName {DotlessOrNot AnyCv} query-glyph
foreach [{gr origSrcName relSrcName} : items-of tree] : if [query-glyph relSrcName] : begin foreach [{gr origSrcName relSrcName} : items-of tree] : if [query-glyph relSrcName] : begin
local origDstName : suggestMappedName targetNameMap origSrcName (origSrcName + '+' + suffix) local origDstName : suggestMappedName targetNameMap origSrcName (origSrcName + '+' + suffix)
local relDstName : suggestMappedName targetNameMap relSrcName (relSrcName + '+' + suffix) local relDstName : suggestMappedName targetNameMap relSrcName (relSrcName + '+' + suffix)
@ -51,6 +51,7 @@ glyph-block Autobuild-Transformed : begin
return { [records.concat relatedRecords] relSets targetNameMap } return { [records.concat relatedRecords] relSets targetNameMap }
glyph-block-export link-relations
define [link-relations relSets] : begin define [link-relations relSets] : begin
local rs : new Set local rs : new Set
foreach [{gr origDstName relDstName} : items-of relSets] foreach [{gr origDstName relDstName} : items-of relSets]
@ -59,6 +60,13 @@ glyph-block Autobuild-Transformed : begin
if [query-glyph relDstName] : begin if [query-glyph relDstName] : begin
[query-glyph origDstName].tryBecomeMirrorOf [query-glyph relDstName] rs [query-glyph origDstName].tryBecomeMirrorOf [query-glyph relDstName] rs
glyph-block Autobuild-Transformed : begin
glyph-block-import CommonShapes
glyph-block-import Common-Derivatives
glyph-block-import Recursive-Build : Fork Miniature
glyph-block-import Marks : markMiddle aboveMarkBot aboveMarkTop belowMarkBot belowMarkTop
glyph-block-import Autobuild-Transformed-Shared : extendRelatedGlyphs link-relations
define [createSuperscripts _records] : begin define [createSuperscripts _records] : begin
local {records relSets targetNameMap} : extendRelatedGlyphs _records 'sup' local {records relSets targetNameMap} : extendRelatedGlyphs _records 'sup'
local pendingGlyphs : records.map : [record] => record.1 local pendingGlyphs : records.map : [record] => record.1
@ -480,6 +488,99 @@ glyph-block Autobuild-Transformed : begin
list 0x2148 'mathbb/i' list 0x2148 'mathbb/i'
list 0x2149 'mathbb/j' list 0x2149 'mathbb/j'
glyph-block Autobuild-Transformed-Mathematical : begin
glyph-block-import CommonShapes
glyph-block-import Common-Derivatives
glyph-block-import Recursive-Build : Fork Miniature
glyph-block-import Autobuild-Transformed-Shared : extendRelatedGlyphs link-relations
define [createMathDerivedSeriesImpl groupName tfm _records] : begin
local { records relSets targetNameMap } : extendRelatedGlyphs _records groupName
local pendingGlyphs : records.map : [record] => record.1
local forked : Fork pendingGlyphs [para.reinit tfm]
foreach {unicode glyphid} [items-of records] : if [not : query-glyph targetNameMap.(glyphid)]
create-glyph targetNameMap.(glyphid) unicode : glyph-proc
include [forked.queryByName glyphid] AS_BASE ALSO_METRICS
link-relations relSets
define [boldGrade g] : begin
local pGrade : (900 - g) / 100
return : 900 - 100 * (2 / 25) * pGrade * pGrade
define [tfBold a] : begin [set a.shape.weight : boldGrade a.shape.weight]
define [tfItalic a] : begin [set a.shape.slope 'italic']
define [tfSans a] : begin [set a.shape.serifs 'sans']
define [tfBoldItalic a] : begin [tfBold a] [tfItalic a]
define [tfSansBold a] : begin [tfSans a] [tfBold a]
define [tfSansItalic a] : begin [tfSans a] [tfItalic a]
define [tfSansBoldItalic a] : begin [tfSans a] [tfBold a] [tfItalic a]
define [tfTypeWriter a] : begin
set a.shape.quasiProportionalDiversity 0
if (a.derivingVariants && a.derivingVariants.mathtt)
set a.variants a.derivingVariants.mathtt
define Digits : Array.from '0123456789'
define UpperLatin : Array.from 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
define LowerLatin : Array.from 'abcdefghijklmnopqrstuvwxyz'
define UpperGreek : Array.from 'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡϴΣΤΥΦΧΨΩ∇'
define LowerGreek : Array.from 'αβγδεζηθικλμνξοπρςστυφχψω∂ϵϑϰϕϱϖ' # Some are missing though
define [CreateMathDerivatives groupName tfm base letters overrides] : begin
if recursive : return nothing
local jobs {}
local overrideMap : new Map (overrides || {})
foreach j [range 0 letters.length] : begin
local letter letters.(j)
local source : glyphStore.queryNameOfUnicode : letter.codePointAt 0
local dst : base + j
if [overrideMap.has letter] : set dst [overrideMap.get letter]
if source : jobs.push { dst source }
createMathDerivedSeriesImpl groupName tfm jobs
# Math bold
CreateMathDerivatives 'mathbf' tfBold 0x1D400 UpperLatin
CreateMathDerivatives 'mathbf' tfBold 0x1D41A LowerLatin
CreateMathDerivatives 'mathbf' tfBold 0x1D6A8 UpperGreek
CreateMathDerivatives 'mathbf' tfBold 0x1D6C2 LowerGreek
CreateMathDerivatives 'mathbf' tfBold 0x1D7CE Digits
# Math Italic
CreateMathDerivatives 'mathit' tfItalic 0x1D434 UpperLatin
CreateMathDerivatives 'mathit' tfItalic 0x1D44E LowerLatin : list { 'h' 0x210E }
CreateMathDerivatives 'mathit' tfItalic 0x1D6E2 UpperGreek
CreateMathDerivatives 'mathit' tfItalic 0x1D6FC LowerGreek
# Math Bold Italic
CreateMathDerivatives 'mathbi' tfBoldItalic 0x1D468 UpperLatin
CreateMathDerivatives 'mathbi' tfBoldItalic 0x1D482 LowerLatin
CreateMathDerivatives 'mathbi' tfBoldItalic 0x1D71C UpperGreek
CreateMathDerivatives 'mathbi' tfBoldItalic 0x1D736 LowerGreek
# Math Sans-serif
CreateMathDerivatives 'mathss' tfSans 0x1D5A0 UpperLatin
CreateMathDerivatives 'mathss' tfSans 0x1D5BA LowerLatin
CreateMathDerivatives 'mathss' tfSans 0x1D7E2 Digits
CreateMathDerivatives 'mathsi' tfSansItalic 0x1D608 UpperLatin
CreateMathDerivatives 'mathsi' tfSansItalic 0x1D622 LowerLatin
CreateMathDerivatives 'mathsb' tfSansBold 0x1D5D4 UpperLatin
CreateMathDerivatives 'mathsb' tfSansBold 0x1D5EE LowerLatin
CreateMathDerivatives 'mathsb' tfSansBold 0x1D756 UpperGreek
CreateMathDerivatives 'mathsb' tfSansBold 0x1D770 LowerGreek
CreateMathDerivatives 'mathsb' tfSansBold 0x1D7EC Digits
CreateMathDerivatives 'mathsz' tfSansBoldItalic 0x1D63C UpperLatin
CreateMathDerivatives 'mathsz' tfSansBoldItalic 0x1D656 LowerLatin
CreateMathDerivatives 'mathsz' tfSansBoldItalic 0x1D790 UpperGreek
CreateMathDerivatives 'mathsz' tfSansBoldItalic 0x1D7AA LowerGreek
# Math Typewriter
CreateMathDerivatives 'mathtt' tfTypeWriter 0x1D670 UpperLatin
CreateMathDerivatives 'mathtt' tfTypeWriter 0x1D68A LowerLatin
CreateMathDerivatives 'mathtt' tfTypeWriter 0x1D7F6 Digits
glyph-block Autobuild-Rhotic : begin glyph-block Autobuild-Rhotic : begin
glyph-block-import Marks : markFine glyph-block-import Marks : markFine
glyph-block-import CommonShapes glyph-block-import CommonShapes

View file

@ -16,8 +16,11 @@ glyph-block Common-Derivatives : begin
foreach { kPrime prime } para.variants.primes : foreach h [prime.variants.values] : begin foreach { kPrime prime } para.variants.primes : foreach h [prime.variants.values] : begin
local suffix : h.resolveFor para follow local suffix : h.resolveFor para follow
if (suffix && transform && transform.(suffix)) : set suffix transform.(suffix) if (suffix && transform && transform.(suffix)) : set suffix transform.(suffix)
if (suffix && h.tag && h.rank) : begin if suffix : begin
[Cv h.tag h.rank].set g ([fallback name follow] + '.' + suffix) local dstName : [fallback name follow] + '.' + suffix
local dst : glyphStore.queryByName dstName
if dst : g.dependsOn dst
if (h.tag && h.rank) : [Cv h.tag h.rank].set g dstName
define [select-variant] : params [name unicode [to-name name] transform [follow name]] : begin define [select-variant] : params [name unicode [to-name name] transform [follow name]] : begin
if [not : glyph-is-needed name] : return nothing if [not : glyph-is-needed name] : return nothing

View file

@ -13,14 +13,14 @@ const ApplyLigationData = require("./support/ligation-data");
const { createGrDisplaySheet } = require("./support/gr"); const { createGrDisplaySheet } = require("./support/gr");
module.exports = async function main(argv) { module.exports = async function main(argv) {
const para = await getParameters(argv); const paraT = await getParameters();
const { font, glyphStore } = BuildFont(para); const { font, glyphStore } = BuildFont(paraT(argv));
if (argv.oCharMap) await saveCharMap(argv, glyphStore); if (argv.oCharMap) await saveCharMap(argv, glyphStore);
if (argv.o) await saveTTF(argv, font); if (argv.o) await saveTTF(argv, font);
}; };
// Parameter preparation // Parameter preparation
async function getParameters(argv) { async function getParameters() {
const PARAMETERS_TOML = path.resolve(__dirname, "../params/parameters.toml"); const PARAMETERS_TOML = path.resolve(__dirname, "../params/parameters.toml");
const WEIGHTS_TOML = path.resolve(__dirname, "../params/shape-weight.toml"); const WEIGHTS_TOML = path.resolve(__dirname, "../params/shape-weight.toml");
const WIDTHS_TOML = path.resolve(__dirname, "../params/shape-width.toml"); const WIDTHS_TOML = path.resolve(__dirname, "../params/shape-width.toml");
@ -38,6 +38,7 @@ async function getParameters(argv) {
const rawVariantsData = await tryParseToml(VARIANTS_TOML); const rawVariantsData = await tryParseToml(VARIANTS_TOML);
const rawLigationData = await tryParseToml(LIGATIONS_TOML); const rawLigationData = await tryParseToml(LIGATIONS_TOML);
function reinit(argv) {
let para = Parameters.init(parametersData, argv); let para = Parameters.init(parametersData, argv);
VariantData.apply(rawVariantsData, para, argv); VariantData.apply(rawVariantsData, para, argv);
ApplyLigationData(rawLigationData, para, argv); ApplyLigationData(rawLigationData, para, argv);
@ -54,7 +55,15 @@ async function getParameters(argv) {
width: argv.menu.width - 0, width: argv.menu.width - 0,
slope: argv.menu.slope slope: argv.menu.slope
}; };
para.reinit = function (tf) {
const argv1 = JSON.parse(JSON.stringify(argv));
tf(argv1, argv);
return reinit(argv1);
};
return para; return para;
}
return reinit;
} }
async function tryParseToml(str) { async function tryParseToml(str) {

View file

@ -24,6 +24,7 @@ function apply(sink, parametersData, styles, blendArgs) {
for (const item of styles) intro(parametersData, item, blendArgs, sink); for (const item of styles) intro(parametersData, item, blendArgs, sink);
} }
// eslint-disable-next-line complexity
function intro(source, style, blendArgs, sink) { function intro(source, style, blendArgs, sink) {
let hive = source[style]; let hive = source[style];
if (!hive) return; if (!hive) return;

View file

@ -166,7 +166,7 @@ const FontInfoOf = computed.group("metadata:font-info-of", async (target, fileNa
return { return {
name: fileName, name: fileName,
variants: bp.variants || null, variants: bp.variants || null,
ligations: bp["ligations"] || null, derivingVariants: bp.derivingVariants,
featureControl: { featureControl: {
noCvSs: bp["no-cv-ss"] || false, noCvSs: bp["no-cv-ss"] || false,
noLigation: bp["no-ligation"] || false noLigation: bp["no-ligation"] || false