Add name suffix for marks (kovidgoyal/kitty#3716)

This commit is contained in:
be5invis 2021-06-12 22:44:28 -07:00
parent 6af9c2e29e
commit 554375808c
6 changed files with 46 additions and 23 deletions

View file

@ -2,7 +2,7 @@
$$include '../../meta/macros.ptl'
import [mix linreg clamp fallback] from '../../support/utils'
import [getGrMesh AnyCv CvDecompose] from "../../support/gr"
import [getGrMesh AnyCv CvDecompose Joining] from "../../support/gr"
extern Map
extern Set
@ -128,6 +128,7 @@ glyph-block AutoBuild-Enclosure : begin
enclosureInnerPartActualWidth.set gniPart (subGlyph.advanceWidth * dscale * xCompress)
create-glyph gniPart : glyph-proc
set-width 0
Joining.set currentGlyph Joining.Classes.Left
include subGlyph
include : subGlyph.gizmo.inverse
include : Scale (dscale * xCompress) (dscale * yCompress)
@ -535,6 +536,7 @@ glyph-block AutoBuild-Enclosure : begin
if [query-glyph gniPart] : return gniPart
create-glyph gniPart : glyph-proc
set-width 0
Joining.set currentGlyph Joining.Classes.Left
include : miniatureFont.queryByNameEnsured gidPart
include : Upright
include : Translate offset 0
@ -820,6 +822,7 @@ glyph-block Autobuild-Fractions : begin
define mfNumGlyph : miniatureFont.queryByNameEnsured numid
set-width 0
Joining.set currentGlyph Joining.Classes.Left
include mfNumGlyph
include : Upright
include : Translate (- mfNumGlyph.advanceWidth / 2) 0
@ -835,6 +838,7 @@ glyph-block Autobuild-Fractions : begin
define mfDenGlyph : miniatureFont.queryByNameEnsured denid
set-width 0
Joining.set currentGlyph Joining.Classes.Left
include mfDenGlyph
include : Upright
include : Translate offset 0
@ -929,6 +933,7 @@ glyph-block AutoBuild-Accented-Equal : begin
if [query-glyph gni] : return gni
create-glyph gni : glyph-proc
set-width 0
Joining.set currentGlyph Joining.Classes.Left
include : dFont.queryByNameEnsured gidPart
include : Upright
include : Translate (-totalWidth / 2 + offset) 0
@ -1215,13 +1220,14 @@ glyph-block Autobuild-Grouped-Digits : begin
define [createGroupedDigits shrink crowd numberGlyphIDs] : begin
create-glyph '.nd-shade' : glyph-proc
set-width 0
Joining.set currentGlyph Joining.Classes.Left
include : intersection
HBarBottom 0 Width (Descender * 0.75) [AdviceStroke 4]
glyph-proc
include : refer-glyph "denseShade.WWID"
include : Translate (-Width / 2) 0
include : Translate (-Width) 0
set-width 0
foreach [gid : items-of numberGlyphIDs] : foreach [nd : items-of {0 1 2 3 4 5 6}]
create-glyph (gid + ".nd" + nd) : glyph-proc

View file

@ -180,6 +180,7 @@ glyph-block Letter-Latin-C : begin
create-glyph "revC.\(suffix)" : glyph-proc
include : MarkSet.capital
set-base-anchor 'cvDecompose' 0 0
include : revCShape [DivFrame 1] CAP 0 SmoothA SmoothB Stroke
include : AutoStartSerifL [DivFrame 1] sty CAP
include : AutoStartSerifLB [DivFrame 1] styBot 0
@ -298,30 +299,32 @@ glyph-block Letter-Latin-C : begin
create-glyph 'currency/centSignBar.open' : glyph-proc
set-width 0
set-mark-anchor 'cvDecompose' 0 0
include : dispiro
widths.center
flat (Middle - Width) (XH - HalfStroke)
curl (Middle - Width) (XH - Descender / 2) [heading Upward]
flat Middle (XH - HalfStroke)
curl Middle (XH - Descender / 2) [heading Upward]
include : dispiro
widths.center
flat (Middle - Width) (Descender / 2) [heading Upward]
curl (Middle - Width) HalfStroke
flat Middle (Descender / 2) [heading Upward]
curl Middle HalfStroke
create-glyph 'currency/centSignBar.through' : glyph-proc
define fine : AdviceStroke 4
include [refer-glyph 'currency/centSignBar.open'] AS_BASE ALSO_METRICS
include : VBar (Middle - Width) (XH - HalfStroke) (0 + HalfStroke) fine
include : VBar Middle (XH - HalfStroke) (0 + HalfStroke) fine
create-glyph 'currency/centSignBar.barInterrupted' : glyph-proc
set-width 0
set-mark-anchor 'cvDecompose' 0 0
define fine : AdviceStroke 4
define gap : Math.max (XH / 8) [AdviceStroke2 6 6 XH]
include : dispiro
flat (Middle - Width) (XH - Descender / 2) [widths.center.heading Stroke Downward]
curl (Middle - Width) (XH / 2 + gap / 2) [widths.center.heading fine Downward]
flat Middle (XH - Descender / 2) [widths.center.heading Stroke Downward]
curl Middle (XH / 2 + gap / 2) [widths.center.heading fine Downward]
include : dispiro
flat (Middle - Width) (Descender / 2) [widths.center.heading Stroke Upward]
curl (Middle - Width) (XH / 2 - gap / 2) [widths.center.heading fine Upward]
flat Middle (Descender / 2) [widths.center.heading Stroke Upward]
curl Middle (XH / 2 - gap / 2) [widths.center.heading fine Upward]
select-variant 'currency/centSignBar' (follow -- 'cent')

View file

@ -235,6 +235,7 @@ glyph-block Letter-Latin-S : begin
define top : CAP * 0.95
define bot : CAP * 0.05
include : MarkSet.capital
set-base-anchor 'cvDecompose' 0 0
include : SStrokeImpl top bot doTS doBS [AdviceStroke2 3 3 (top - bot)] Ess
include : SAutoSlabStart doTS top Stroke Hook
include : SAutoSlabEnd doBS bot Stroke Hook
@ -244,6 +245,7 @@ glyph-block Letter-Latin-S : begin
define top : CAP * 0.88
define bot : CAP * 0.12
include : MarkSet.capital
set-base-anchor 'cvDecompose' 0 0
include : SStrokeImpl top bot doTS doBS [AdviceStroke2 3 3 (top - bot)] Ess
include : SAutoSlabStart doTS top Stroke Hook
include : SAutoSlabEnd doBS bot Stroke Hook
@ -434,22 +436,22 @@ glyph-block Letter-Latin-S : begin
foreach { suffix { kTop kBot overflow fillType fShort } } [Object.entries DollarConfig] : do
create-glyph "dollar/bar.\(suffix)" : glyph-proc
set-width 0
set-mark-anchor 'cvDecompose' 0 0
define top : CAP * kTop
define bot : CAP * kBot
define w : AdviceStroke 3
define fine : AdviceStroke 4
define barMid : Middle - Width
if (fillType === 1) : include : VBar barMid (bot + HalfStroke) (top - HalfStroke) fine
if (fillType === 1) : include : VBar Middle (bot + HalfStroke) (top - HalfStroke) fine
if (fillType === 0 || fillType === 1) : begin
include : dispiro
widths.center w
flat barMid (top - HalfStroke)
curl barMid (CAP - overflow) [heading Upward]
flat Middle (top - HalfStroke)
curl Middle (CAP - overflow) [heading Upward]
include : dispiro
widths.center w
flat barMid overflow [heading Upward]
curl barMid (bot + HalfStroke)
flat Middle overflow [heading Upward]
curl Middle (bot + HalfStroke)
if (fillType === 2) : begin
local gap : (w / Stroke * Ess) + [Math.max ((top - bot) / 6) [AdviceStroke2 3 3 (top - bot)]]
local yMid : mix bot top 0.5
@ -458,13 +460,13 @@ glyph-block Letter-Latin-S : begin
include : difference
union
dispiro
flat barMid (CAP - overflow) [widths.center.heading w Downward]
curl barMid [mix bot top 0.5] [widths.center.heading fine Downward]
flat Middle (CAP - overflow) [widths.center.heading w Downward]
curl Middle [mix bot top 0.5] [widths.center.heading fine Downward]
dispiro
flat barMid overflow [widths.center.heading w Upward]
curl barMid [mix bot top 0.5] [widths.center.heading fine Upward]
flat Middle overflow [widths.center.heading w Upward]
curl Middle [mix bot top 0.5] [widths.center.heading fine Upward]
dispiro [corner (-Width) yTermLeft : widths.center gap] [corner 0 yTermRight]
dispiro [corner 0 yTermLeft : widths.center gap] [corner Width yTermRight]
if fShort : DollarShorterBar.set currentGlyph 'trigger'

View file

@ -1,6 +1,7 @@
$$include '../../meta/macros.ptl'
import [mix linreg clamp fallback] from '../../support/utils'
import [Joining] from '../../support/gr'
glyph-module
@ -38,9 +39,12 @@ glyph-block Symbol-Mosaic-NotDef : begin
set-width 0
alias 'nonmarkingreturn' 0x000D 'zwsp'
alias 'cgj' 0x34F 'zwsp'
alias 'nbsp' 0xA0 'space'
create-glyph 'cgj' 0x34F : glyph-proc
set-width 0
Joining.set currentGlyph Joining.Classes.Mid
alias 'enquad' 0x2000 'sp1'
alias 'ensp' 0x2002 'sp1'
alias 'brailleBlank' 0x2800 'sp1'

View file

@ -81,6 +81,10 @@ export : define [buildOtl para glyphStore] : begin
local GDEF : buildGDEF para glyphStore markGlyphs
local GSUB : buildGSUB para glyphStore markGlyphs
# Make all diacritics join-l (Kitty #3716)
foreach gnMark [items-of markGlyphs.all] : begin
Gr.Joining.or [glyphStore.queryByName gnMark] Gr.Joining.Classes.Left
# Build compatibility ligatures
if (para.enableLigation && para.compLig) : begin
BuildCompatLigatures para glyphStore GSUB GDEF para.compLig

View file

@ -91,6 +91,7 @@ const TieGlyph = {
set(glyph) {
if (!glyph.related) glyph.related = {};
glyph.related.TieGlyph = true;
Joining.or(glyph, Joining.Classes.Mid);
}
};
@ -125,6 +126,9 @@ const Joining = {
if (!glyph.related) glyph.related = {};
glyph.related.joining = cls;
},
or(glyph, cls) {
Joining.set(glyph, cls | Joining.get(cls));
},
amendOtName(baseName, cl) {
switch (cl) {
case Joining.Classes.Left: