Add apparent translate mechanism to improve component sharing

This commit is contained in:
be5invis 2021-02-02 01:56:43 -08:00
parent 3fd1ebfec3
commit fdff7dbb60
18 changed files with 154 additions and 225 deletions

View file

@ -607,14 +607,9 @@ glyph-block CommonShapes : begin
include : Italify include : Italify
define ScaleAround FlipAround define ScaleAround FlipAround
define [Realign x y sx sy] : glyph-proc define [Realign x y sx sy] : ApparentTranslate (sx - x) (sy - y)
include : Upright
include : Translate (-x) (-y)
include : Translate sx sy
include : Italify
define [ForceUpright] : glyph-proc define [ForceUpright] : glyph-proc [set this.gizmo : Translate 0 0]
set this.gizmo : Translate 0 0
define [CreateWaveShape dist sw _phaesShift] : begin define [CreateWaveShape dist sw _phaesShift] : begin
define WaveResolution 64 define WaveResolution 64

View file

@ -16,7 +16,5 @@ glyph-block Letter-Latin-Bidental-Percussive : begin
include : VBarLeft SB (CAP * 0.1) (CAP * 0.4) include : VBarLeft SB (CAP * 0.1) (CAP * 0.4)
include : VBarRight RightSB (CAP * 0.1) (CAP * 0.4) include : VBarRight RightSB (CAP * 0.1) (CAP * 0.4)
include g include g
include : Upright include : ApparentTranslate 0 (CAP / 2)
include : Translate 0 (CAP / 2)
include : Italify
include g include g

View file

@ -107,10 +107,7 @@ glyph-block Letter-Latin-Lower-D : begin
create-glyph 'dhooktop.tailed' : glyph-proc create-glyph 'dhooktop.tailed' : glyph-proc
include : MarkSet.b include : MarkSet.b
include : OBarRightShape include : OBarRightShape
include : dispiro include : RightwardTailedBar RightSB 0 yDHookTopConnect
flat RightSB yDHookTopConnect [widths.rhs.heading Stroke Downward]
curl RightSB (Hook * 0.5 + Stroke + O * 2)
g4 (RightSB + Hook * 0.25) (Stroke * 0.75 + O * 2)
include : VerticalHook (RightSB - HalfStroke * HVContrast) yDHookTopConnect HookX (-Hook) include : VerticalHook (RightSB - HalfStroke * HVContrast) yDHookTopConnect HookX (-Hook)
if SLAB : include : tagged 'serifRB' : RightwardBottomSerif RightSB 0 SideJut if SLAB : include : tagged 'serifRB' : RightwardBottomSerif RightSB 0 SideJut

View file

@ -119,9 +119,7 @@ glyph-block Letter-Latin-Lower-H : begin
include : VBarLeft SB 0 CAP include : VBarLeft SB 0 CAP
include : new-glyph : glyph-proc include : new-glyph : glyph-proc
include : refer-glyph "rtailBR" include : refer-glyph "rtailBR"
include : Upright include : ApparentTranslate RightSB (Hook + HalfStroke)
include : Translate RightSB (Hook + HalfStroke)
include : Italify
include : FlipAround Middle (XH / 2) include : FlipAround Middle (XH / 2)
include : MarkSet.p include : MarkSet.p
if SLAB : begin if SLAB : begin
@ -136,15 +134,11 @@ glyph-block Letter-Latin-Lower-H : begin
include : VBarLeft SB 0 (XH - 1) include : VBarLeft SB 0 (XH - 1)
include : new-glyph : glyph-proc include : new-glyph : glyph-proc
include : refer-glyph "rtailBR" include : refer-glyph "rtailBR"
include : Upright include : ApparentTranslate RightSB (Hook + HalfStroke)
include : Translate RightSB (Hook + HalfStroke)
include : Italify
include : FlipAround Middle (XH / 2) include : FlipAround Middle (XH / 2)
include : new-glyph : glyph-proc include : new-glyph : glyph-proc
include : refer-glyph "rtailBR" include : refer-glyph "rtailBR"
include : Upright include : ApparentTranslate RightSB 0
include : Translate RightSB 0
include : Italify
include : MarkSet.p include : MarkSet.p
if SLAB : begin if SLAB : begin
include : LeftwardTopSerif (RightSB - Stroke * HVContrast) XH SideJut include : LeftwardTopSerif (RightSB - Stroke * HVContrast) XH SideJut

View file

@ -209,9 +209,7 @@ glyph-block Letter-Latin-Lower-L : begin
include [refer-glyph 'l.serifed'] AS_BASE ALSO_METRICS include [refer-glyph 'l.serifed'] AS_BASE ALSO_METRICS
include : new-glyph : glyph-proc include : new-glyph : glyph-proc
include : refer-glyph "tildeAboveOverlay" include : refer-glyph "tildeAboveOverlay"
include : Upright include : ApparentTranslate (df.middle - markMiddle) (CAP * 0.525 - [mix aboveMarkBot aboveMarkTop 0.5])
include : Translate (df.middle - markMiddle) (CAP * 0.525 - [mix aboveMarkBot aboveMarkTop 0.5])
include : Italify
define [Belt middle] : glyph-proc define [Belt middle] : glyph-proc
local fine : AdviceStroke 4.5 local fine : AdviceStroke 4.5

View file

@ -135,9 +135,7 @@ glyph-block Letter-Latin-Lower-Q : begin
include : VBarRight RightSB 0 CAP include : VBarRight RightSB 0 CAP
include : new-glyph : glyph-proc include : new-glyph : glyph-proc
include : refer-glyph "rtailBR" include : refer-glyph "rtailBR"
include : Upright include : ApparentTranslate RightSB 0
include : Translate RightSB 0
include : Italify
if SLAB : begin if SLAB : begin
include : tagged 'serifRT' : RightwardTopSerif RightSB CAP SideJut include : tagged 'serifRT' : RightwardTopSerif RightSB CAP SideJut
@ -147,9 +145,7 @@ glyph-block Letter-Latin-Lower-Q : begin
include : VBarRight RightSB 0 XH include : VBarRight RightSB 0 XH
include : new-glyph : glyph-proc include : new-glyph : glyph-proc
include : refer-glyph "rtailBR" include : refer-glyph "rtailBR"
include : Upright include : ApparentTranslate RightSB 0
include : Translate RightSB 0
include : Italify
if SLAB : begin if SLAB : begin
include : tagged 'serifRT' : RightwardTopSerif RightSB XH SideJut include : tagged 'serifRT' : RightwardTopSerif RightSB XH SideJut

View file

@ -211,9 +211,7 @@ glyph-block Letter-Latin-Lower-R : begin
eject-contour 'serifLB' eject-contour 'serifLB'
include : new-glyph : glyph-proc include : new-glyph : glyph-proc
include : refer-glyph "rtailBR" include : refer-glyph "rtailBR"
include : Upright include : ApparentTranslate rbar 0
include : Translate rbar 0
include : Italify
create-glyph 'rrtail.serifless' create-glyph 'rrtail.serifless'
SmallRRTailShape StandardLowerRShape dfN rStraight 0 SmallRRTailShape StandardLowerRShape dfN rStraight 0
create-glyph 'rrtail.topSerifed' create-glyph 'rrtail.topSerifed'
@ -242,9 +240,7 @@ glyph-block Letter-Latin-Lower-R : begin
include : FlipAround df.middle (XH / 2) include : FlipAround df.middle (XH / 2)
include : new-glyph : glyph-proc include : new-glyph : glyph-proc
include : refer-glyph "rtailBR" include : refer-glyph "rtailBR"
include : Upright include : ApparentTranslate (df.rightSB - rbar + df.leftSB + Stroke * HVContrast) 0
include : Translate (df.rightSB - rbar + df.leftSB + Stroke * HVContrast) 0
include : Italify
create-glyph 'turnrrtail.serifless' create-glyph 'turnrrtail.serifless'
TurnRRTailShape StandardLowerRShape dfN rStraight 0 TurnRRTailShape StandardLowerRShape dfN rStraight 0

View file

@ -250,9 +250,7 @@ glyph-block Letter-Latin-S : begin
include : new-glyph : glyph-proc include : new-glyph : glyph-proc
local sw : AdviceStroke2 2 3 XH local sw : AdviceStroke2 2 3 XH
include : refer-glyph "rtailBR" include : refer-glyph "rtailBR"
include : Upright include : ApparentTranslate (start.x + sw * HVContrast) 0
include : Translate (start.x + sw * HVContrast) 0
include : Italify
include : VBarLeft start.x 0 start.y include : VBarLeft start.x 0 start.y

View file

@ -67,9 +67,7 @@ glyph-block Letter-Latin-Upper-L : begin
include [refer-glyph src] AS_BASE ALSO_METRICS include [refer-glyph src] AS_BASE ALSO_METRICS
include : new-glyph : glyph-proc include : new-glyph : glyph-proc
include : refer-glyph "tildeAboveOverlay" include : refer-glyph "tildeAboveOverlay"
include : Upright include : ApparentTranslate (SB * 1.5 + Stroke * HVContrast / 2 - markMiddle) (CAP * 0.525 - [mix aboveMarkBot aboveMarkTop 0.5])
include : Translate (SB * 1.5 + Stroke * HVContrast / 2 - markMiddle) (CAP * 0.525 - [mix aboveMarkBot aboveMarkTop 0.5])
include : Italify
with-related-glyphs 'Ldot' 0x13F 'L' : lambda [src sel] : glyph-proc with-related-glyphs 'Ldot' 0x13F 'L' : lambda [src sel] : glyph-proc
include [refer-glyph src] AS_BASE include [refer-glyph src] AS_BASE

View file

@ -195,9 +195,7 @@ glyph-block Letter-Latin-W : begin
set-width df.width set-width df.width
include : df.markSet.capital include : df.markSet.capital
include : WshapeImpl df (CAP / 2) bodyType slabType include : WshapeImpl df (CAP / 2) bodyType slabType
include : Upright include : ApparentTranslate 0 (CAP / 2)
include : Translate 0 (CAP / 2)
include : Italify
include : WshapeImpl df (CAP / 2) bodyType slabType include : WshapeImpl df (CAP / 2) bodyType slabType
define [WHooktopShape df top bodyType] : glyph-proc define [WHooktopShape df top bodyType] : glyph-proc

View file

@ -25,9 +25,7 @@ glyph-block Letter-Shared : begin
define srcGlyph : query-glyph src define srcGlyph : query-glyph src
define commaOffset : (Width / 2) * [Math.pow (srcGlyph.advanceWidth / Width * 2) (2/3)] define commaOffset : (Width / 2) * [Math.pow (srcGlyph.advanceWidth / Width * 2) (2/3)]
include : refer-glyph "commaTR" include : refer-glyph "commaTR"
include : Upright include : ApparentTranslate commaOffset 0
include : Translate commaOffset 0
include : Italify
include srcGlyph AS_BASE ALSO_METRICS include srcGlyph AS_BASE ALSO_METRICS
glyph-block Letter-Blackboard : begin glyph-block Letter-Blackboard : begin

View file

@ -69,9 +69,7 @@ glyph-block Marks : begin
include : difference include : difference
DotAt markMiddle (XH + Accent) radiusOut DotAt markMiddle (XH + Accent) radiusOut
DotAt markMiddle (XH + Accent) radiusIn DotAt markMiddle (XH + Accent) radiusIn
include : Upright include : ApparentTranslate 0 (-markFine * 0.75)
include : Translate 0 (-markFine * 0.75)
include : Italify
create-glyph 'dblRingAbove' 0x1AB2 : glyph-proc create-glyph 'dblRingAbove' 0x1AB2 : glyph-proc
set-width 0 set-width 0
@ -314,14 +312,10 @@ glyph-block Marks : begin
local shift : (ttop - tbot) * 1.2 local shift : (ttop - tbot) * 1.2
include : addTilde include : addTilde
include : Upright include : ApparentTranslate 0 shift
include : Translate 0 shift
include : Italify
include : addTilde include : addTilde
include : Upright include : ApparentTranslate 0 (-0.5 * shift)
include : Translate 0 (-0.5 * shift)
include : Italify
create-glyph 'macronAbove' 0x304 : glyph-proc create-glyph 'macronAbove' 0x304 : glyph-proc
set-width 0 set-width 0
@ -468,9 +462,7 @@ glyph-block Marks : begin
straight.down.start (markMiddle + radius) (aboveMarkTop - radius + commaOvershoot) straight.down.start (markMiddle + radius) (aboveMarkTop - radius + commaOvershoot)
quadcontrols 0 0.6 quadcontrols 0 0.6
g4 [mix markMiddle (markMiddle - radius) 0.2] (aboveMarkBot - radius - commaOvershoot2) g4 [mix markMiddle (markMiddle - radius) 0.2] (aboveMarkBot - radius - commaOvershoot2)
include : Upright include : ApparentTranslate 0 (DotRadius * 0.3)
include : Translate 0 (DotRadius * 0.3)
include : Italify
create-glyph 'turnCommaAbove' 0x312 : glyph-proc create-glyph 'turnCommaAbove' 0x312 : glyph-proc
set-width 0 set-width 0
@ -493,9 +485,7 @@ glyph-block Marks : begin
straight.down.start (markMiddle - radius) (aboveMarkTop - radius + commaOvershoot) straight.down.start (markMiddle - radius) (aboveMarkTop - radius + commaOvershoot)
quadcontrols 0 0.6 quadcontrols 0 0.6
g4 [mix markMiddle (markMiddle + radius) 0.2] (aboveMarkBot - radius - commaOvershoot2) g4 [mix markMiddle (markMiddle + radius) 0.2] (aboveMarkBot - radius - commaOvershoot2)
include : Upright include : ApparentTranslate 0 (DotRadius * 0.3)
include : Translate 0 (DotRadius * 0.3)
include : Italify
create-glyph 'barAbove' 0x30D : glyph-proc create-glyph 'barAbove' 0x30D : glyph-proc
set-width 0 set-width 0
@ -552,9 +542,7 @@ glyph-block Marks : begin
archv archv
g4.up.end (markMiddle + radius) yc [heading Upward] g4.up.end (markMiddle + radius) yc [heading Upward]
include : DotAt markMiddle (XH + Accent) fine include : DotAt markMiddle (XH + Accent) fine
include : Upright include : ApparentTranslate 0 (fine * 0.5)
include : Translate 0 (fine * 0.5)
include : Italify
set-mark-anchor 'above' markMiddle XH markMiddle aboveMarkTop set-mark-anchor 'above' markMiddle XH markMiddle aboveMarkTop
set-base-anchor 'aboveBrace' markMiddle (XH + Accent) set-base-anchor 'aboveBrace' markMiddle (XH + Accent)
@ -1095,17 +1083,13 @@ glyph-block Marks : begin
create-glyph 'dotTR' 0x358 : glyph-proc create-glyph 'dotTR' 0x358 : glyph-proc
set-width 0 set-width 0
include : refer-glyph "dotAbove" include : refer-glyph "dotAbove"
include : Upright include : ApparentTranslate (RightSB - Middle + DotRadius) 0
include : Translate (RightSB - Middle + DotRadius) 0
include : Italify
set-mark-anchor 'topright' 0 XH 0 aboveMarkTop set-mark-anchor 'topright' 0 XH 0 aboveMarkTop
create-glyph 'commaTR' 0x315 : glyph-proc create-glyph 'commaTR' 0x315 : glyph-proc
set-width 0 set-width 0
include : refer-glyph "commaAbove" include : refer-glyph "commaAbove"
include : Upright include : ApparentTranslate (RightSB - Middle + DotRadius) 0
include : Translate (RightSB - Middle + DotRadius) 0
include : Italify
set-mark-anchor 'topright' 0 XH 0 aboveMarkTop set-mark-anchor 'topright' 0 XH 0 aboveMarkTop
create-glyph 'rtailBR' 0x322 : glyph-proc create-glyph 'rtailBR' 0x322 : glyph-proc
@ -1135,9 +1119,7 @@ glyph-block Marks : begin
set-width 0 set-width 0
set-mark-anchor 'overlay' markMiddle (XH / 2) markMiddle (XH / 2) set-mark-anchor 'overlay' markMiddle (XH / 2) markMiddle (XH / 2)
include : refer-glyph "tildeAbove" include : refer-glyph "tildeAbove"
include : Upright include : ApparentTranslate 0 (XH / 2 - [mix aboveMarkTop aboveMarkBot 0.5])
include : Translate 0 (XH / 2 - [mix aboveMarkTop aboveMarkBot 0.5])
include : Italify
create-glyph 'barOver' 0x335 : glyph-proc create-glyph 'barOver' 0x335 : glyph-proc
set-width 0 set-width 0

View file

@ -43,9 +43,7 @@ glyph-block Symbol-Math-Arith : begin
local sbSquash 0.5 local sbSquash 0.5
local delta : Math.max 0 : Width / 2 - DotRadius - SB * sbSquash local delta : Math.max 0 : Width / 2 - DotRadius - SB * sbSquash
include : Upright include : ApparentTranslate (+delta) (SymbolMid - XH / 2)
include : Translate (+delta) (SymbolMid - XH / 2)
include : Italify
include : HBar (SB * sbSquash) (RightSB - DotSize) SymbolMid OperatorStroke include : HBar (SB * sbSquash) (RightSB - DotSize) SymbolMid OperatorStroke

View file

@ -108,9 +108,7 @@ glyph-block Symbol-Math-Relation : begin
include : refer-glyph "xhDot" include : refer-glyph "xhDot"
local delta : Math.max 0 : Width / 2 - DotRadius - SB * ColonEqSbSquash local delta : Math.max 0 : Width / 2 - DotRadius - SB * ColonEqSbSquash
include : Upright include : ApparentTranslate (+delta) (SymbolMid - XH / 2)
include : Translate (+delta) (SymbolMid - XH / 2)
include : Italify
include : EqualShape (SB * ColonEqSbSquash) (RightSB - DotSize) include : EqualShape (SB * ColonEqSbSquash) (RightSB - DotSize)
@ -119,9 +117,7 @@ glyph-block Symbol-Math-Relation : begin
include : refer-glyph "xhDot" include : refer-glyph "xhDot"
local delta : Math.max 0 : Width / 2 - DotRadius - SB * ColonEqSbSquash local delta : Math.max 0 : Width / 2 - DotRadius - SB * ColonEqSbSquash
include : Upright include : ApparentTranslate (-delta) (SymbolMid - XH / 2)
include : Translate (-delta) (SymbolMid - XH / 2)
include : Italify
create-glyph 'colonEq' 0x2254 : glyph-proc create-glyph 'colonEq' 0x2254 : glyph-proc
include : ColonEqColonShape include : ColonEqColonShape
@ -467,24 +463,18 @@ glyph-block Symbol-Math-Relation : begin
create-glyph 'barSym' 0x2242 : glyph-proc create-glyph 'barSym' 0x2242 : glyph-proc
include [refer-glyph 'sym'] AS_BASE include [refer-glyph 'sym'] AS_BASE
include : Upright include : ApparentTranslate 0 (-approxDist / 2)
include : Translate 0 (-approxDist / 2)
include : Italify
include : HBar SB RightSB (SymbolMid + approxDist / 2) OperatorStroke include : HBar SB RightSB (SymbolMid + approxDist / 2) OperatorStroke
create-glyph 'symEq' 0x2243 : glyph-proc create-glyph 'symEq' 0x2243 : glyph-proc
include [refer-glyph 'sym'] AS_BASE include [refer-glyph 'sym'] AS_BASE
include : Upright include : ApparentTranslate 0 (approxDist / 2)
include : Translate 0 (approxDist / 2)
include : Italify
include : HBar SB RightSB (SymbolMid - approxDist / 2) OperatorStroke include : HBar SB RightSB (SymbolMid - approxDist / 2) OperatorStroke
create-glyph 'symEqEq' 0x2245 : glyph-proc create-glyph 'symEqEq' 0x2245 : glyph-proc
local sympShift : approxDist + EqualHalfSpace * 1.5 local sympShift : approxDist + EqualHalfSpace * 1.5
include [refer-glyph 'sym'] AS_BASE include [refer-glyph 'sym'] AS_BASE
include : Upright include : ApparentTranslate 0 (sympShift / 2)
include : Translate 0 (sympShift / 2)
include : Italify
include : HBar SB RightSB (SymbolMid - sympShift / 2 + EqualHalfSpace * 1.5) OperatorStroke include : HBar SB RightSB (SymbolMid - sympShift / 2 + EqualHalfSpace * 1.5) OperatorStroke
include : HBar SB RightSB (SymbolMid - sympShift / 2) OperatorStroke include : HBar SB RightSB (SymbolMid - sympShift / 2) OperatorStroke
@ -494,17 +484,13 @@ glyph-block Symbol-Math-Relation : begin
create-glyph 'flipSymEq' 0x22CD : glyph-proc create-glyph 'flipSymEq' 0x22CD : glyph-proc
include [refer-glyph 'flipSym'] AS_BASE include [refer-glyph 'flipSym'] AS_BASE
include : Upright include : ApparentTranslate 0 (approxDist / 2)
include : Translate 0 (approxDist / 2)
include : Italify
include : HBar SB RightSB (SymbolMid - approxDist / 2) OperatorStroke include : HBar SB RightSB (SymbolMid - approxDist / 2) OperatorStroke
create-glyph 'flipSymEqEq' 0x224C : glyph-proc create-glyph 'flipSymEqEq' 0x224C : glyph-proc
local sympShift : approxDist + EqualHalfSpace * 1.5 local sympShift : approxDist + EqualHalfSpace * 1.5
include [refer-glyph 'flipSym'] AS_BASE include [refer-glyph 'flipSym'] AS_BASE
include : Upright include : ApparentTranslate 0 (sympShift / 2)
include : Translate 0 (sympShift / 2)
include : Italify
include : HBar SB RightSB (SymbolMid - sympShift / 2 + EqualHalfSpace * 1.5) OperatorStroke include : HBar SB RightSB (SymbolMid - sympShift / 2 + EqualHalfSpace * 1.5) OperatorStroke
include : HBar SB RightSB (SymbolMid - sympShift / 2) OperatorStroke include : HBar SB RightSB (SymbolMid - sympShift / 2) OperatorStroke

View file

@ -376,9 +376,7 @@ glyph-block Symbol-Punctuation-Small : begin
include : refer-glyph "xhPeriod" include : refer-glyph "xhPeriod"
create-derived 'colon.mid' : glyph-proc create-derived 'colon.mid' : glyph-proc
include : Upright include : ApparentTranslate 0 (SymbolMid - XH / 2)
include : Translate 0 (SymbolMid - XH / 2)
include : Italify
create-glyph 'hollowColon' 0x2982 : glyph-proc create-glyph 'hollowColon' 0x2982 : glyph-proc
define sw : AdviceStroke 5 define sw : AdviceStroke 5
@ -1417,10 +1415,8 @@ glyph-block Symbol-Punctuation-Ellipsis : begin
include : DotAt (MosaicWidth / 2) radius (radius - O) include : DotAt (MosaicWidth / 2) radius (radius - O)
include : DotAt right radius (radius - O) include : DotAt right radius (radius - O)
create-derived [MangleName 'mathCDots'] [MangleUnicode 0x22EF] : glyph-proc create-derived [MangleName 'mathCDots'] [MangleUnicode 0x22EF]
include : Upright ApparentTranslate 0 (SymbolMid - radius)
include : Translate 0 (SymbolMid - radius)
include : Italify
create-glyph : glyph-proc create-glyph : glyph-proc
set-width MosaicWidth set-width MosaicWidth

View file

@ -39,6 +39,7 @@ export : define [calculateMetrics para] : begin
define [Upright angle shift] [Italify angle shift :.inverse] define [Upright angle shift] [Italify angle shift :.inverse]
define [Scale sx sy] : new Transform sx 0 0 [fallback sy sx] 0 0 define [Scale sx sy] : new Transform sx 0 0 [fallback sy sx] 0 0
define [Translate x y] : new Transform 1 0 0 1 x y define [Translate x y] : new Transform 1 0 0 1 x y
define [ApparentTranslate x y] : Translate (x + TanSlope * y) y
define [Rotate angle] : new Transform [Math.cos angle] (-[Math.sin angle]) [Math.sin angle] [Math.cos angle] 0 0 define [Rotate angle] : new Transform [Math.cos angle] (-[Math.sin angle]) [Math.sin angle] [Math.cos angle] 0 0
define GlobalTransform : Italify para.slopeAngle define GlobalTransform : Italify para.slopeAngle
@ -195,9 +196,9 @@ export : define [calculateMetrics para] : begin
return [object return [object
UPM HalfUPM Width SB CAP XH Descender Contrast SymbolMid ParenTop ParenBot OperTop OperBot UPM HalfUPM Width SB CAP XH Descender Contrast SymbolMid ParenTop ParenBot OperTop OperBot
TackTop TackBot PlusTop PlusBot PictTop PictBot BgOpTop BgOpBot Italify Upright Scale TackTop TackBot PlusTop PlusBot PictTop PictBot BgOpTop BgOpBot Italify Upright Scale
Translate Rotate GlobalTransform TanSlope HVContrast Upward Downward Rightward Leftward Translate ApparentTranslate Rotate GlobalTransform TanSlope HVContrast Upward Downward
UpwardT DownwardT LeftwardT RightwardT O OX OXHook Hook AHook SHook RHook JHook FHook HookX Rightward Leftward UpwardT DownwardT LeftwardT RightwardT O OX OXHook Hook AHook SHook RHook
Smooth SmallSmooth Stroke DotSize PeriodSize HBarPos OverlayPos JHook FHook HookX Smooth SmallSmooth Stroke DotSize PeriodSize HBarPos OverlayPos
LongJut Jut VJut Accent AccentX CThin CThinB SLAB TailAdjX TailAdjY LBalance LongJut Jut VJut Accent AccentX CThin CThinB SLAB TailAdjX TailAdjY LBalance
IBalance LBalance2 IBalance2 JBalance JBalance2 TBalance TBalance2 RBalance RBalance2 IBalance LBalance2 IBalance2 JBalance JBalance2 TBalance TBalance2 RBalance RBalance2
FBalance OneBalance WideWidth0 WideWidth1 WideWidth2 WideWidth3 WideWidth4 Ess EssQuestion FBalance OneBalance WideWidth0 WideWidth1 WideWidth2 WideWidth3 WideWidth4 Ess EssQuestion

View file

@ -205,7 +205,7 @@ define-macro glyph-block : syntax-rules
buildGlyphs tagged DivFrame fontMetrics $assignUnicodeImpl$] buildGlyphs tagged DivFrame fontMetrics $assignUnicodeImpl$]
define metricImports `[UPM HalfUPM Width SB CAP XH Descender Contrast SymbolMid ParenTop define metricImports `[UPM HalfUPM Width SB CAP XH Descender Contrast SymbolMid ParenTop
ParenBot OperTop OperBot TackTop TackBot PlusTop PlusBot PictTop PictBot BgOpTop BgOpBot ParenBot OperTop OperBot TackTop TackBot PlusTop PlusBot PictTop PictBot BgOpTop BgOpBot
Italify Upright Scale Translate Rotate GlobalTransform TanSlope Italify Upright Scale Translate ApparentTranslate Rotate GlobalTransform TanSlope
HVContrast Upward Downward Rightward Leftward UpwardT DownwardT LeftwardT RightwardT O OX HVContrast Upward Downward Rightward Leftward UpwardT DownwardT LeftwardT RightwardT O OX
OXHook Hook AHook SHook RHook JHook FHook HookX Smooth SmallSmooth Stroke DotSize OXHook Hook AHook SHook RHook JHook FHook HookX Smooth SmallSmooth Stroke DotSize
PeriodSize HBarPos OverlayPos LongJut Jut VJut PeriodSize HBarPos OverlayPos LongJut Jut VJut

View file

@ -4,102 +4,6 @@ const Transform = require("./transform");
const Point = require("./point"); const Point = require("./point");
const Anchor = require("./anchor"); const Anchor = require("./anchor");
class GeometryStore {
constructor() {
this.m_contours = [];
this.m_references = [];
}
addContour(c) {
this.m_contours.push(c);
}
addReference(glyph, x, y) {
this.m_references.push({ glyph, x, y });
}
asContours() {
let result = [];
for (const c of this.m_contours) {
const c1 = [...c];
if (c.tag) c1.tag = c.tag;
result.push(c1);
}
for (const r of this.m_references) {
for (const c of r.glyph.geometry.asContours()) {
let c1 = [];
for (const z of c) c1.push(Point.fromXY(z.type, z.x + r.x, z.y + r.y));
if (c.tag) c1.tag = c.tag;
result.push(c1);
}
}
return result;
}
asReferences() {
if (this.m_contours && this.m_contours.length) return null;
if (!this.m_references.length) return null;
return this.m_references;
}
applyTranslate(shiftX, shiftY) {
for (const c of this.m_contours) {
for (let k = 0; k < c.length; k++) {
c[k] = Point.translated(c[k], shiftX, shiftY);
}
}
for (const r of this.m_references) {
r.x += shiftX;
r.y += shiftY;
}
}
applyTransform(tfm) {
const cs = this.asContours();
for (const c of cs) {
for (let k = 0; k < c.length; k++) {
c[k] = Point.transformed(tfm, c[k]);
}
}
this.m_contours = cs;
this.m_references.length = 0;
}
reTagContour(oldTag, newTag) {
for (const c of this.m_contours) {
if (c.tag === oldTag) c.tag = newTag;
}
}
ejectContour(tag) {
const cs = this.asContours();
let i = 0,
j = 0;
for (; i < cs.length; i++) if (!cs[i].tag || cs[i].tag !== tag) cs[j++] = cs[i];
cs.length = j;
this.m_contours = cs;
this.m_references = [];
}
suppressNaN() {
let broken = false,
complexity = 0;
for (const c of this.m_contours) {
for (const z of c) {
complexity++;
if (!isFinite(z.x)) {
broken = true;
z.x = 0;
}
if (!isFinite(z.y)) {
broken = true;
z.y = 0;
}
}
}
return broken ? 0xffff : complexity;
}
isEmpty() {
return !this.m_contours.length && !this.m_references.length;
}
}
module.exports = class Glyph { module.exports = class Glyph {
constructor(_identifier) { constructor(_identifier) {
this._m_identifier = _identifier; this._m_identifier = _identifier;
@ -216,23 +120,6 @@ module.exports = class Glyph {
} }
} }
combineAnchor(shift, baseThis, markThat, basesThat) {
if (!baseThis || !markThat) return;
shift.x = baseThis.x - markThat.x;
shift.y = baseThis.y - markThat.y;
if (basesThat) {
for (const bk in basesThat) {
this.baseAnchors[bk] = new Anchor(
shift.x + basesThat[bk].x,
shift.y + basesThat[bk].y
);
}
}
}
copyAnchors(g) {
if (g.markAnchors) for (const k in g.markAnchors) this.markAnchors[k] = g.markAnchors[k];
if (g.baseAnchors) for (const k in g.baseAnchors) this.baseAnchors[k] = g.baseAnchors[k];
}
applyTransform(tfm, alsoAnchors) { applyTransform(tfm, alsoAnchors) {
if (Transform.isTranslate(tfm)) { if (Transform.isTranslate(tfm)) {
this.geometry.applyTranslate(tfm.x, tfm.y); this.geometry.applyTranslate(tfm.x, tfm.y);
@ -275,6 +162,23 @@ module.exports = class Glyph {
} }
// Anchors // Anchors
combineAnchor(shift, baseThis, markThat, basesThat) {
if (!baseThis || !markThat) return;
shift.x = baseThis.x - markThat.x;
shift.y = baseThis.y - markThat.y;
if (basesThat) {
for (const bk in basesThat) {
this.baseAnchors[bk] = new Anchor(
shift.x + basesThat[bk].x,
shift.y + basesThat[bk].y
);
}
}
}
copyAnchors(g) {
if (g.markAnchors) for (const k in g.markAnchors) this.markAnchors[k] = g.markAnchors[k];
if (g.baseAnchors) for (const k in g.baseAnchors) this.baseAnchors[k] = g.baseAnchors[k];
}
setBaseAnchor(id, x, y) { setBaseAnchor(id, x, y) {
this.baseAnchors[id] = new Anchor(x, y).transform(this.gizmo); this.baseAnchors[id] = new Anchor(x, y).transform(this.gizmo);
} }
@ -291,3 +195,99 @@ module.exports = class Glyph {
delete this.markAnchors[id]; delete this.markAnchors[id];
} }
}; };
class GeometryStore {
constructor() {
this.m_contours = [];
this.m_references = [];
}
addContour(c) {
this.m_contours.push(c);
}
addReference(glyph, x, y) {
this.m_references.push({ glyph, x, y });
}
asContours() {
let result = [];
for (const c of this.m_contours) {
const c1 = [...c];
if (c.tag) c1.tag = c.tag;
result.push(c1);
}
for (const r of this.m_references) {
for (const c of r.glyph.geometry.asContours()) {
let c1 = [];
for (const z of c) c1.push(Point.fromXY(z.type, z.x + r.x, z.y + r.y));
if (c.tag) c1.tag = c.tag;
result.push(c1);
}
}
return result;
}
asReferences() {
if (this.m_contours && this.m_contours.length) return null;
if (!this.m_references.length) return null;
return this.m_references;
}
applyTranslate(shiftX, shiftY) {
for (const c of this.m_contours) {
for (let k = 0; k < c.length; k++) {
c[k] = Point.translated(c[k], shiftX, shiftY);
}
}
for (const r of this.m_references) {
r.x += shiftX;
r.y += shiftY;
}
}
applyTransform(tfm) {
const cs = this.asContours();
for (const c of cs) {
for (let k = 0; k < c.length; k++) {
c[k] = Point.transformed(tfm, c[k]);
}
}
this.m_contours = cs;
this.m_references.length = 0;
}
reTagContour(oldTag, newTag) {
for (const c of this.m_contours) {
if (c.tag === oldTag) c.tag = newTag;
}
}
ejectContour(tag) {
const cs = this.asContours();
let i = 0,
j = 0;
for (; i < cs.length; i++) if (!cs[i].tag || cs[i].tag !== tag) cs[j++] = cs[i];
cs.length = j;
this.m_contours = cs;
this.m_references = [];
}
suppressNaN() {
let broken = false,
complexity = 0;
for (const c of this.m_contours) {
for (const z of c) {
complexity++;
if (!isFinite(z.x)) {
broken = true;
z.x = 0;
}
if (!isFinite(z.y)) {
broken = true;
z.y = 0;
}
}
}
return broken ? 0xffff : complexity;
}
isEmpty() {
return !this.m_contours.length && !this.m_references.length;
}
}