From 990d5a9a887802b2f2490f946f5d6aac4e2fff5f Mon Sep 17 00:00:00 2001 From: Belleve Invis Date: Wed, 27 May 2020 03:33:41 -0700 Subject: [PATCH] Add `f` with straight tail (`v-f-straight-tailed`, `VXAD`, #519). --- changes/3.1.0.md | 3 +- glyphs/letters-unified-basic.ptl | 7 +++++ otl/gsub-ccmp.ptl | 7 ++++- otl/gsub-cv-ss.ptl | 6 +++- otl/gsub-ligation.ptl | 4 ++- otl/gsub-locl.ptl | 12 +++++--- otl/gsub-pairing.ptl | 5 +++- otl/gsub-thousands.ptl | 7 +++-- otl/index.ptl | 15 ++++++++-- otl/table-util.ptl | 47 ++++++++++++++++++++++---------- variants.toml | 12 ++++++-- 11 files changed, 94 insertions(+), 31 deletions(-) diff --git a/changes/3.1.0.md b/changes/3.1.0.md index d723b10644..7f24330eea 100644 --- a/changes/3.1.0.md +++ b/changes/3.1.0.md @@ -14,4 +14,5 @@ * Fix broken long ligature at beginning of line in macOS TextEdit (#548). * Add `v-eszet-longs-s-lig` (#455). * Make `cv##` and `ss##` features work on enclosed/braced/superscript/subscript letters (#516). - * Add playback symbols. \ No newline at end of file + * Add playback symbols. + * Add `f` with straight tail (`v-f-straight-tailed`, `VXAD`, #519). diff --git a/glyphs/letters-unified-basic.ptl b/glyphs/letters-unified-basic.ptl index 8b2a15de61..83a8f6bdf2 100644 --- a/glyphs/letters-unified-basic.ptl +++ b/glyphs/letters-unified-basic.ptl @@ -4074,6 +4074,7 @@ glyph-block LetterUnified-Basic : begin sketch # f.straight local fovershoot2 (O * 2) include MarkSet.b + local barleft : [mix SB RightSB 0.35] - Stroke * 0.25 * HVContrast include : dispiro widths.lhs @@ -4099,6 +4100,11 @@ glyph-block LetterUnified-Basic : begin curl ([mix SB RightSB 0.875] + HalfStroke * TanSlope) 0 save 'f.serifed' + branch + include MarkSet.if + include : VBarLeft barleft 0 (Descender * 0.9) + save 'f.straightTailed' + branch include : dispiro widths.rhs @@ -4144,6 +4150,7 @@ glyph-block LetterUnified-Basic : begin turned 'turnf.straight' nothing 'f.straight' Middle (XH / 2) MarkSet.p turned 'turnf.serifed' nothing 'f.serifed' Middle (XH / 2) MarkSet.p + turned 'turnf.straightTailed' nothing 'f.straightTailed' Middle (XH / 2) MarkSet.p turned 'turnf.narrow' nothing 'f.narrow' dfNarrowF.middle (XH / 2) dfNarrowF.markSet.p turned 'turnf.tailed' nothing 'f.tailed' Middle (XH / 2) MarkSet.p select-variant 'turnf' 0x25F (follow -- 'f') diff --git a/otl/gsub-ccmp.ptl b/otl/gsub-ccmp.ptl index 122e15db26..0e5db895a9 100644 --- a/otl/gsub-ccmp.ptl +++ b/otl/gsub-ccmp.ptl @@ -1,10 +1,13 @@ -import [add-common-feature add-feature add-lookup ChainRuleBuilder] from "./table-util" +import [add-common-feature add-feature add-lookup ChainRuleBuilder BeginLookupBlock EndLookupBlock] from "./table-util" import [Dotless] from "../support/gr" +extern Set define-operator "~>" 880 'right' : syntax-rules `(@l ~> @r) `{.left @l .right @r} export : define [buildCCMP sink glyphs markGlyphs] : begin + local rec : BeginLookupBlock sink + define ccmp : add-feature sink 'ccmp' define {chain-rule} : ChainRuleBuilder sink @@ -187,3 +190,5 @@ export : define [buildCCMP sink glyphs markGlyphs] : begin sink.lookupDep.push {lookupCcmp-ToneSandhiStart lookupCcmp-ToneSandhiMid} sink.lookupDep.push {lookupCcmp-ToneSandhiMid lookupCcmp-ToneSandhiEnd} add-common-feature sink ccmp + + EndLookupBlock rec sink \ No newline at end of file diff --git a/otl/gsub-cv-ss.ptl b/otl/gsub-cv-ss.ptl index 603b675847..9bb966dabd 100644 --- a/otl/gsub-cv-ss.ptl +++ b/otl/gsub-cv-ss.ptl @@ -1,4 +1,4 @@ -import [add-common-feature pick-feature add-feature-lookup pick-lookup] from "./table-util" +import [add-common-feature pick-feature add-feature-lookup pick-lookup BeginLookupBlock EndLookupBlock] from "./table-util" import [AnyCv] from "../support/gr" define [FeatureName tag] : tag + '_cvss' @@ -7,6 +7,8 @@ define [LookupName tag] : 'lookup_cvss_' + tag export : define [buildCVSS sink para glyphList] : begin if [not para.enableCvSs] : return nothing + local rec : BeginLookupBlock sink + # cvxx foreach [glyph : items-of glyphList] foreach [gr : items-of : AnyCv.query glyph] : if gr.tag : begin @@ -27,3 +29,5 @@ export : define [buildCVSS sink para glyphList] : begin foreach [{ch tag} : pairs-of composition.__cvmap] add-feature-lookup feature [LookupName tag] + + EndLookupBlock rec sink diff --git a/otl/gsub-ligation.ptl b/otl/gsub-ligation.ptl index eae5ffb6f9..acfff571fd 100644 --- a/otl/gsub-ligation.ptl +++ b/otl/gsub-ligation.ptl @@ -1,4 +1,4 @@ -import [add-common-feature add-feature ChainRuleBuilder query-related-glyphs] from "./table-util" +import [add-common-feature add-feature ChainRuleBuilder query-related-glyphs BeginLookupBlock EndLookupBlock] from "./table-util" extern Set @@ -12,8 +12,10 @@ define preserved null define advance : lambda [t] : t.map : lambda [x] x export : define [buildLigations sink para plm glyphs] : begin + local rec : BeginLookupBlock sink local rankedLookups {} foreach [ {featureName mappedFeature} : pairs-of plm] : buildLigationsImpl sink para glyphs featureName mappedFeature rankedLookups + EndLookupBlock rec sink define [buildLigationsImpl sink para glyphs featureName mappedFeature rankedLookups] : begin define {chain-rule reverse-rule} : ChainRuleBuilder sink diff --git a/otl/gsub-locl.ptl b/otl/gsub-locl.ptl index 73ef8cd0d8..4c4560afea 100644 --- a/otl/gsub-locl.ptl +++ b/otl/gsub-locl.ptl @@ -1,6 +1,8 @@ -import [copy-language add-feature add-lookup] from "./table-util" +import [copy-language add-feature add-lookup BeginLookupBlock EndLookupBlock] from "./table-util" export : define [buildLOCL sink para] : begin + local rec : BeginLookupBlock sink + define cyrlSRB : copy-language sink 'cyrl_SRB ' 'cyrl_DFLT' define cyrlMKD : copy-language sink 'cyrl_MKD ' 'cyrl_DFLT' define cyrlBGR : copy-language sink 'cyrl_BGR ' 'cyrl_DFLT' @@ -9,7 +11,7 @@ export : define [buildLOCL sink para] : begin define loclSRB : add-feature sink 'locl' cyrlSRB.features.unshift loclSRB.name cyrlMKD.features.unshift loclSRB.name - loclSRB.lookups.push : add-lookup.front sink : object + loclSRB.lookups.push : add-lookup sink : object type 'gsub_single' subtables : list : if para.isItalic object @@ -24,7 +26,7 @@ export : define [buildLOCL sink para] : begin # BGR define loclBGR : add-feature sink 'locl' cyrlBGR.features.unshift loclBGR.name - loclBGR.lookups.push : add-lookup.front sink : object + loclBGR.lookups.push : add-lookup sink : object type 'gsub_single' subtables : list : object cyrve 'cyrve.BGR' @@ -42,4 +44,6 @@ export : define [buildLOCL sink para] : begin cyrsha 'cyrsha.italic' cyrshcha 'cyrshcha.italic' cyryu 'cyryu.BGR' - cyrtse 'cyrtse.italic' \ No newline at end of file + cyrtse 'cyrtse.italic' + + EndLookupBlock.Front rec sink \ No newline at end of file diff --git a/otl/gsub-pairing.ptl b/otl/gsub-pairing.ptl index 6bc8272972..2ab342caeb 100644 --- a/otl/gsub-pairing.ptl +++ b/otl/gsub-pairing.ptl @@ -1,7 +1,9 @@ -import [add-common-feature add-feature add-lookup] from "./table-util" +import [add-common-feature add-feature add-lookup BeginLookupBlock EndLookupBlock] from "./table-util" # Name-driven feature pairs export : define [buildPairFeature sink tag1 tag2 glyphs glyphList] : begin + local rec : BeginLookupBlock sink + local mapTag2 {.} local mapTag1 {.} define reHidden : regex "^\\." @@ -23,3 +25,4 @@ export : define [buildPairFeature sink tag1 tag2 glyphs glyphList] : begin add-common-feature sink feature1 add-common-feature sink feature2 + EndLookupBlock rec sink diff --git a/otl/gsub-thousands.ptl b/otl/gsub-thousands.ptl index 2acc5b6a21..db8c5b739e 100644 --- a/otl/gsub-thousands.ptl +++ b/otl/gsub-thousands.ptl @@ -1,9 +1,11 @@ -import [add-common-feature add-feature add-lookup ChainRuleBuilder query-related-glyphs] from "./table-util" +import [add-common-feature add-feature add-lookup ChainRuleBuilder query-related-glyphs BeginLookupBlock EndLookupBlock] from "./table-util" define-operator "~>" 880 'right' : syntax-rules `(@l ~> @r) `{.left @l .right @r} export : define [buildGsubThousands sink para glyphs] : begin + local rec : BeginLookupBlock sink + define Thousand : add-feature sink 'THND' define {chain-rule reverse-rule} : ChainRuleBuilder sink define numberGlyphIDs : query-related-glyphs glyphs para { @@ -43,4 +45,5 @@ export : define [buildGsubThousands sink para glyphs] : begin Thousand.lookups.push lookupThousand1 lookupThousand2 lookupThousand3 - add-common-feature sink Thousand \ No newline at end of file + add-common-feature sink Thousand + EndLookupBlock rec sink diff --git a/otl/index.ptl b/otl/index.ptl index 82ad08a2c3..3d494ae331 100644 --- a/otl/index.ptl +++ b/otl/index.ptl @@ -3,7 +3,7 @@ import 'object-assign' as objectAssign import '../support/glyph' as Glyph import '../support/transform' as Transform -import [CreateEmptyTable] from "./table-util" +import [CreateEmptyTable finalizeTable MoveBackUtilityLookups] from "./table-util" import [buildLigations] from './gsub-ligation' import [buildCCMP] from './gsub-ccmp' @@ -23,11 +23,14 @@ define [buildGSUB para glyphs glyphList markGlyphs] : begin define gsub : CreateEmptyTable set gsub.lookupDep {} + # lnum / onum buildPairFeature gsub 'lnum' 'onum' glyphs glyphList + + # NWID / WWID if (!para.forceMonospace || para.spacing > 0) : begin buildPairFeature gsub 'NWID' 'WWID' glyphs glyphList - # CCMP + # ccmp buildCCMP gsub glyphs markGlyphs # Ligation @@ -37,18 +40,26 @@ define [buildGSUB para glyphs glyphList markGlyphs] : begin set plm.calt para.ligation.caltBuildup buildLigations gsub para plm glyphs + # cv##, ss## buildCVSS gsub para glyphList + + # THND buildGsubThousands gsub para glyphs + # locl + # Builds last, but the lookups are added into the beginning of the lookup list buildLOCL gsub para + MoveBackUtilityLookups gsub set gsub.lookupOrder : topsort gsub.lookupDep + finalizeTable gsub return gsub # GPOS define [buildGPOS para glyphs glyphList markGlyphs] : begin define gpos : CreateEmptyTable buildMarkMkmk gpos glyphList + finalizeTable gpos return gpos # GDEF diff --git a/otl/table-util.ptl b/otl/table-util.ptl index 0d74899d88..f0051b6697 100644 --- a/otl/table-util.ptl +++ b/otl/table-util.ptl @@ -48,17 +48,6 @@ export : define [add-lookup sink data _prefix] : begin return (prefix + n) set n : n + 1 -set add-lookup.front : lambda [sink data _prefix] : begin - local prefix : _prefix || '_lut_' - local n 0 - while true : begin - if [not sink.lookups.(prefix + n)] : begin - if sink.lookupDep : foreach [{key lookup} : pairs-of sink.lookups] : begin - sink.lookupDep.push {(prefix + n) key} - set sink.lookups.(prefix + n) data - return (prefix + n) - set n : n + 1 - export : define [pick-lookup sink name fallback] : begin if sink.lookups.(name) : return sink.lookups.(name) set sink.lookups.(name) fallback @@ -77,13 +66,37 @@ export : define [add-common-feature sink fea] : begin return fea -export : define [ChainRuleBuilder sink] : begin - define utilityLookupPrefix '.utility-single.' +define UtilityLookupPrefix '.utility-single.' + +export : define [BeginLookupBlock sink] : begin + return : object + existingLookupNames : new Set : Object.keys sink.lookups + +define [IsUtilityLookupId name] : [name.slice 0 UtilityLookupPrefix.length] === UtilityLookupPrefix + +export : define [EndLookupBlock rec sink] : begin + local currentLookupNames : new Set : Object.keys sink.lookups + foreach existing rec.existingLookupNames : foreach current currentLookupNames + if (![IsUtilityLookupId existing] && ![IsUtilityLookupId current] && ![rec.existingLookupNames.has current]) + sink.lookupDep.push { existing current } +set EndLookupBlock.Front : lambda [rec sink] : begin + local currentLookupNames : new Set : Object.keys sink.lookups + foreach existing rec.existingLookupNames : foreach current currentLookupNames + if (![IsUtilityLookupId existing] && ![IsUtilityLookupId current] && ![rec.existingLookupNames.has current]) + sink.lookupDep.push { current existing } + +export : define [MoveBackUtilityLookups sink] : begin + local lns : new Set : Object.keys sink.lookups + foreach [front lns] : foreach [rear lns] + if (![IsUtilityLookupId front] && [IsUtilityLookupId rear]) + sink.lookupDep.push { front rear } + +export : define [ChainRuleBuilder sink] : begin define [createNewLookup f t] : begin local subtable {.} foreach [j : range 0 f.length] : set subtable.(f.(j)) t.(j) - return : add-lookup sink {.type 'gsub_single' .subtables {subtable}} utilityLookupPrefix + return : add-lookup sink {.type 'gsub_single' .subtables {subtable}} UtilityLookupPrefix define [getSubLookup left right] : piecewise [not right] null @@ -95,7 +108,7 @@ export : define [ChainRuleBuilder sink] : begin local lookupKeys : [Object.keys sink.lookups].reverse foreach [name : items-of lookupKeys] : begin local st sink.lookups.(name).subtables.0 - if ([name.slice 0 utilityLookupPrefix.length] === utilityLookupPrefix) : begin + if [IsUtilityLookupId name] : begin local compatible true local matchCount 0 foreach [j : range 0 left.length] : begin @@ -165,3 +178,7 @@ export : define [query-related-glyphs glyphs para entries] : begin if para.enableCvSs : foreach [gr : items-of : AnyCv.query glyphs.(gid)] : begin sink.push : gr.get glyphs.(gid) return sink + +export : define [finalizeTable table] : begin + foreach [{key lang} : pairs-of table.languages] : begin + if lang.features : lang.features.sort diff --git a/variants.toml b/variants.toml index 661f5606f8..dad050ab2f 100644 --- a/variants.toml +++ b/variants.toml @@ -93,6 +93,12 @@ sampler = 'f' description = '`f` with bottom serif' f = "serifed" +[simple.v-f-straight-tailed] +tag = "VXAD" +sampler = 'f' +description = '`f` with straight tail' +f = "straightTailed" + [simple.v-g-singlestorey] tag = 'cv12' sampler = 'g' @@ -148,7 +154,7 @@ description = "Tailed `i`" dotlessi = 'tailed' [simple.v-i-hookybottom] -tag = "CVAA" +tag = "VXAA" sampler = 'i' description = "`i` with a straight tail" dotlessi = 'hookybottom' @@ -364,7 +370,7 @@ description = 'A more modern, beta-like Eszet' eszet = 'sulzbacher' [simple.v-eszet-longs-s-lig] -tag = 'CVAC' +tag = 'VXAC' sampler = 'ß' description = 'A more modern, beta-like Eszet' eszet = 'longsslig' @@ -406,7 +412,7 @@ description = 'Reverse-slashed `0`' zero = 'reverse-slashed' [simple.v-zero-long-dotted] -tag = 'CVAB' +tag = 'VXAB' sampler = '0' description = 'Long-dotted Zero `0` like Hack' zero = 'longDotted'