Further cleanup

This commit is contained in:
be5invis 2020-07-28 20:23:01 -07:00
parent ba8422c4ee
commit daa0e79845
5 changed files with 144 additions and 151 deletions

View file

@ -100,22 +100,8 @@ export all : define [buildGlyphs para recursive recursiveCodes] : begin
g.assignUnicode unicode
set unicodeGlyphs.(g.unicode.((g.unicode.length - 1))) g
define [$save$ t _name unicode] : begin
define name : if [not _name] ('--autoname-' + [newtemp]) _name
local g : create-glyph name [lambda]
if g : begin
g.include t AS_BASE
if (t <@ Glyph) : begin
set g.advanceWidth t.advanceWidth
set g.shortName t.shortName
set g.autoRefPriority t.autoRefPriority
set g.glyphRank t.glyphRank
set g.avoidBeingComposite t.avoidBeingComposite
set g.related t.related
if name : set dependencyProfile.(name) : getDependencyProfile g
warnAboutBrokenGlyph g name
if (g && unicode) : $assignUnicodeImpl$ g unicode
return g
define [$save$ t name unicode] : begin
return : create-glyph name unicode : glyph-proc [currentGlyph.cloneFromGlyph t]
### Spiro constructions
# Basic knots

View file

@ -74,7 +74,7 @@ glyph-block CommonShapes : begin
lambda [src sel] : glyph-proc
if (unicode && !sel) : assign-unicode unicode
include [refer-glyph src] AS_BASE ALSO_METRICS
set currentGlyph.autoRefPriority [query-glyph src].autoRefPriority
currentGlyph.cloneRankFromGlyph [query-glyph src]
define [turned newid unicode id _x _y mark] : WithDerivatives id [fallback newid ('turn' + id)]
lambda [src sel] : glyph-proc

View file

@ -6,16 +6,16 @@ import [AnyCv getGrMesh] from "../support/gr"
glyph-module
glyph-block Numbers : begin
glyph-block-import CommonShapes
glyph-block-import Letter-Latin-Ezh : EzhShape
glyph-block Digits-Shared : begin
glyph-block-export ShiftDown
define [ShiftDown] : glyph-proc
include : Upright
include : Translate 0 Descender
include : Italify
glyph-block Digits-Zero : begin
glyph-block-import CommonShapes
define [ZeroSlashShape top] : begin
local fine : 0.5 * OverlayStroke
return : intersection
@ -56,67 +56,60 @@ glyph-block Numbers : begin
SmoothAOf halfDotWidth (halfDotWidth * 2)
SmoothBOf halfDotWidth (halfDotWidth * 2)
create-glyph : glyph-proc # zero.lnum.unslashed
create-glyph 'zero.lnum.unslashed' : glyph-proc
include MarkSet.capital
include : OShape CAP 0 SB RightSB
save-as 'zero.lnum.unslashed'
create-glyph : glyph-proc # zero.lnum.slashed
create-glyph 'zero.lnum.slashed' : glyph-proc
include MarkSet.capital
include : refer-glyph "zero.lnum.unslashed"
include : ZeroSlashShape CAP
save-as 'zero.lnum.slashed'
create-glyph : glyph-proc # zero.lnum.reverse-slashed
create-glyph 'zero.lnum.reverse-slashed' : glyph-proc
include MarkSet.capital
include : refer-glyph "zero.lnum.unslashed"
include : ZeroReverseSlashShape CAP
save-as 'zero.lnum.reverse-slashed'
create-glyph : glyph-proc # zero.lnum.dotted
create-glyph 'zero.lnum.dotted' : glyph-proc
include MarkSet.capital
include : refer-glyph "zero.lnum.unslashed"
include : ZeroDotShape CAP
save-as 'zero.lnum.dotted'
create-glyph : glyph-proc # zero.lnum.longDotted
create-glyph 'zero.lnum.longDotted' : glyph-proc
include MarkSet.capital
include : refer-glyph "zero.lnum.unslashed"
include : ZeroLongDotShape CAP
save-as 'zero.lnum.longDotted'
create-glyph : glyph-proc # zero.onum.unslashed
create-glyph 'zero.onum.unslashed' : glyph-proc
include MarkSet.e
include : OShape XH 0 SB RightSB
save-as 'zero.onum.unslashed'
create-glyph : glyph-proc # zero.onum.slashed
create-glyph 'zero.onum.slashed' : glyph-proc
include MarkSet.e
include : refer-glyph "zero.onum.unslashed"
include : ZeroSlashShape XH
save-as 'zero.onum.slashed'
create-glyph : glyph-proc # zero.onum.reverse-slashed
create-glyph 'zero.onum.reverse-slashed' : glyph-proc
include MarkSet.e
include : refer-glyph "zero.onum.unslashed"
include : ZeroReverseSlashShape XH
save-as 'zero.onum.reverse-slashed'
create-glyph : glyph-proc # zero.onum.dotted
create-glyph 'zero.onum.dotted' : glyph-proc
include MarkSet.e
include : refer-glyph "zero.onum.unslashed"
include : ZeroDotShape XH
save-as 'zero.onum.dotted'
create-glyph : glyph-proc # zero.onum.longDotted
create-glyph 'zero.onum.longDotted' : glyph-proc
include MarkSet.e
include : refer-glyph "zero.onum.unslashed"
include : ZeroLongDotShape XH
save-as 'zero.onum.longDotted'
select-variant 'zero.lnum' '0' (follow -- 'zero')
select-variant 'zero.onum' (follow -- 'zero')
glyph-block Digits-One : begin
glyph-block-import CommonShapes
define [OneShape top balance] : glyph-proc
define topSW : adviceBlackness 3.5
include : VBar (Middle + balance) 0 top
@ -124,44 +117,39 @@ glyph-block Numbers : begin
flat (Middle - HalfStroke * HVContrast + balance) top [widths topSW 0]
curl (Middle - Stroke / 8 * HVContrast - HookX * 1.25 + balance) (top - Stroke / 8 - Hook * 0.75 * (top / CAP))
create-glyph : glyph-proc # one.lnum.nobase
create-glyph 'one.lnum.nobase' : glyph-proc
include MarkSet.capital
include : OneShape CAP OneBalance
save-as 'one.lnum.nobase'
create-glyph : glyph-proc # one.lnum.base
create-glyph 'one.lnum.base' : glyph-proc
include MarkSet.capital
include : OneShape CAP (OneBalance / 4)
include : CenterBottomSerif Middle 0 LongJut
save-as 'one.lnum.base'
create-glyph : glyph-proc # one.lnum.line
create-glyph 'one.lnum.line' : glyph-proc
include MarkSet.capital
include : VBar Middle 0 CAP
set currentGlyph.autoRefPriority (-2)
save-as 'one.lnum.line'
create-glyph : glyph-proc # one.onum.nobase
create-glyph 'one.onum.nobase' : glyph-proc
include MarkSet.e
include : OneShape XH OneBalance
save-as 'one.onum.nobase'
create-glyph : glyph-proc # one.onum.base
create-glyph 'one.onum.base' : glyph-proc
include MarkSet.capital
include : OneShape XH (OneBalance / 4)
include : CenterBottomSerif Middle 0 LongJut
save-as 'one.onum.base'
create-glyph : glyph-proc # one.lnum.line
create-glyph 'one.onum.line' : glyph-proc
include MarkSet.capital
include : VBar Middle 0 XH
set currentGlyph.autoRefPriority (-2)
save-as 'one.onum.line'
select-variant 'one.lnum' '1' (follow -- 'one')
select-variant 'one.onum' (follow -- 'one')
glyph-block Digits-Two : begin
glyph-block-import CommonShapes
define [TwoShape top] : glyph-proc
define smooth : [adviceGlottalStopSmooth top 1] * 0.95
@ -178,18 +166,21 @@ glyph-block Numbers : begin
if SLAB : begin
include : UpwardRightSerif RightSB 0 VJut
create-glyph : glyph-proc # two.lnum
create-glyph 'two.lnum' '2' : glyph-proc
include MarkSet.capital
include : TwoShape CAP
save-as 'two.lnum' '2'
create-glyph : glyph-proc # two.onum
create-glyph 'two.onum' : glyph-proc
include MarkSet.e
include : TwoShape XH
save-as 'two.onum'
turned nothing 0x218A 'two.lnum' Middle (CAP / 2)
glyph-block Digits-Three : begin
glyph-block-import CommonShapes
glyph-block-import Digits-Shared : ShiftDown
glyph-block-import Letter-Latin-Ezh : EzhShape
define [ThreeShape top] : glyph-proc
local barcenter : top * HBarPos
local threeRadius : ((top / 2) + HalfStroke - Smooth) * 1.25
@ -210,30 +201,30 @@ glyph-block Numbers : begin
flat (RightSB - threeRadius + 0.01) (barcenter + (fine - HalfStroke)) [widths.heading fine 0 Leftward]
curl (RightSB - threeRadius) (barcenter + (fine - HalfStroke)) [heading Leftward]
create-glyph : glyph-proc # three.lnum
create-glyph 'three.lnum.twoarcs' : glyph-proc
include MarkSet.capital
include : ThreeShape CAP
save-as 'three.lnum.twoarcs'
create-glyph : glyph-proc
create-glyph 'three.lnum.flattop' : glyph-proc
include MarkSet.capital
include : EzhShape CAP 0 0.25 0.975
save-as 'three.lnum.flattop'
create-glyph : glyph-proc # three.lnum
create-glyph 'three.onum.twoarcs' : glyph-proc
include MarkSet.p
include : ThreeShape (XH - Descender)
include : ShiftDown
save-as 'three.onum.twoarcs'
create-glyph : glyph-proc
create-glyph 'three.onum.flattop' : glyph-proc
include MarkSet.p
include : EzhShape (XH - Descender) 0 0.25 0.975
include : ShiftDown
save-as 'three.onum.flattop'
select-variant 'three.lnum' '3' (follow -- 'three')
select-variant 'three.onum' (follow -- 'three')
turned nothing 0x218B 'three.lnum' Middle (CAP / 2)
glyph-block Digits-Four : begin
glyph-block-import CommonShapes
glyph-block-import Digits-Shared : ShiftDown
define [FourStdShape top open crossing] : glyph-proc
local yBar (top * 0.4)
local fine : adviceBlackness 3
@ -325,6 +316,10 @@ glyph-block Numbers : begin
select-variant 'four.lnum' '4' (follow -- 'four')
select-variant 'four.onum' (follow -- 'four')
glyph-block Digits-Five : begin
glyph-block-import CommonShapes
glyph-block-import Digits-Shared : ShiftDown
define [FiveShape top bp] : glyph-proc
local t1 : top * bp * 0.8
local t2 : top * bp
@ -349,26 +344,27 @@ glyph-block Numbers : begin
include : DownwardRightSerif xright top VJut
Rect (t2 / 2 + top * 0.015) (t2 / 2 - top * 0.015) 0 Middle
create-glyph : glyph-proc # five.lnum
create-glyph 'five.lnum' '5' : glyph-proc
include MarkSet.capital
include : FiveShape CAP designParameters.fiveBarPos
save-as 'five.lnum' '5'
create-glyph : glyph-proc # five.onum
create-glyph 'five.onum' : glyph-proc
include MarkSet.p
include : FiveShape (XH - Descender) designParameters.fiveBarPos
include : ShiftDown
save-as 'five.onum'
create-glyph : glyph-proc # zhuangToneFive
create-glyph 'zhuangToneFive' 0x1BC : glyph-proc
include MarkSet.capital
include : FiveShape CAP designParameters.fiveBarPos
save-as 'zhuangToneFive' 0x1BC
create-glyph : glyph-proc # zhuangtonefive
create-glyph 'zhuangtonefive' 0x1BD : glyph-proc
include MarkSet.e
include : FiveShape XH designParameters.fiveBarPos
save-as 'zhuangtonefive' 0x1BD
glyph-block Digits-Six : begin
glyph-block-import CommonShapes
glyph-block-export OpenContourSixShape
define [OpenContourSixShape charTop] : glyph-proc
local oTop : charTop * 0.55 + Stroke / 2
local ymiddlea : (oTop - SmallSmoothA + SmallSmoothB) / 2
@ -391,6 +387,7 @@ glyph-block Numbers : begin
quadcontrols 0 0.85
g4 ([mix SB RightSB 0.85] - 0.25 * Stroke * HVContrast) (charTop - O) [widths.rhs]
glyph-block-export ClosedContourNineShape
define [ClosedContourNineShape top] : glyph-proc
local u top
local d : Math.min (u - SmallSmoothA - SmallSmoothB - 0.1) (top * 0.45 - HalfStroke)
@ -414,6 +411,7 @@ glyph-block Numbers : begin
hookend O
g4 SB Hook
glyph-block-export StraightBarSixShape
define [StraightBarSixShape charTop] : begin
local oTop : charTop * 0.55 + Stroke / 2
local ymiddlea : (oTop - SmallSmoothA + SmallSmoothB) / 2
@ -429,9 +427,9 @@ glyph-block Numbers : begin
Rect charTop (-charTop) (-Width) (2 * Width)
dispiro
widths.rhs fine
g4.left.start (Middle + CorrectionOMidS - TanSlope * (Stroke - fine)) (O + Stroke - fine + 0.1)
g4.left.start (Middle + CorrectionOMidS - TanSlope * (Stroke - fine)) (O + Stroke - fine + 1/16)
archv
g4.up.mid (SB + OX + (Stroke - fine) * HVContrast + 0.1) ymiddlea
g4.up.mid (SB + OX + (Stroke - fine) * HVContrast + 1/16) ymiddlea
arcvh
g4 (Middle - CorrectionOMidS) (oTop - O) [widths.rhs]
archv
@ -443,29 +441,30 @@ glyph-block Numbers : begin
flat [mix xMockBarStart xTerminal pStraightBarStart] [mix yMockBarStart charTop pStraightBarStart] [widths.rhs]
curl [mix xMockBarStart xTerminal 2] [mix yMockBarStart charTop 2]
create-glyph : glyph-proc # six
create-glyph 'six.lnum.openContour' : glyph-proc
include MarkSet.capital
include : OpenContourSixShape CAP
save-as 'six.lnum.openContour'
save-as 'six.onum.openContour'
create-glyph : glyph-proc # six
create-glyph 'six.lnum.closedContour' : glyph-proc
include MarkSet.capital
include : ClosedContourNineShape CAP
include : FlipAround (Middle) (CAP / 2)
save-as 'six.lnum.closedContour'
save-as 'six.onum.closedContour'
create-glyph : glyph-proc # six
create-glyph 'six.lnum.straightBar' : glyph-proc
include MarkSet.capital
include : StraightBarSixShape CAP
save-as 'six.lnum.straightBar'
save-as 'six.onum.straightBar'
select-variant 'six.lnum' '6' (follow -- 'six')
select-variant 'six.onum' (follow -- 'six')
glyph-block Digits-Seven : begin
glyph-block-import CommonShapes
glyph-block-import Digits-Shared : ShiftDown
define SevenXLeft : mix SB RightSB 0.28
define [SevenSwCor top] : [Math.hypot 1 ((RightSB - SevenXLeft - HalfStroke) / (top - Stroke))] * HVContrast
define [SevenShape top] : glyph-proc
@ -485,44 +484,39 @@ glyph-block Numbers : begin
m + Stroke * cor * 0.25 + LongJut * 0.7
mix 0 (top - Stroke * 0.25) 0.5
create-glyph : glyph-proc # seven.lnum
create-glyph : glyph-proc
include MarkSet.capital
include : SevenShape CAP
create-derived : glyph-proc
save-as 'seven.lnum.noserif'
create-derived : glyph-proc
create-derived 'seven.lnum.noserif' : glyph-proc
create-derived 'seven.lnum.crossbar' : glyph-proc
include : SevenCrossbarShape CAP
save-as 'seven.lnum.crossbar'
create-derived : glyph-proc
create-derived 'seven.lnum.serifed' : glyph-proc
include : DownwardLeftSerif (SB + (OX - O)) CAP VJut
save-as 'seven.lnum.serifed'
create-derived : glyph-proc
create-derived 'seven.lnum.crossbarSerifed' : glyph-proc
include : SevenCrossbarShape CAP
include : DownwardLeftSerif (SB + (OX - O)) CAP VJut
save-as 'seven.lnum.crossbarSerifed'
create-glyph : glyph-proc # seven.onum
create-glyph : glyph-proc
include MarkSet.p
include : SevenShape (XH - Descender)
create-derived : glyph-proc
create-derived 'seven.onum.noserif' : glyph-proc
include : ShiftDown
save-as 'seven.onum.noserif'
create-derived : glyph-proc
create-derived 'seven.onum.crossbar' : glyph-proc
include : SevenCrossbarShape (XH - Descender)
include : ShiftDown
save-as 'seven.onum.crossbar'
create-derived : glyph-proc
create-derived 'seven.onum.serifed' : glyph-proc
include : DownwardLeftSerif (SB + (OX - O)) (XH - Descender) VJut
include : ShiftDown
save-as 'seven.onum.serifed'
create-derived : glyph-proc
create-derived 'seven.onum.crossbarSerifed' : glyph-proc
include : SevenCrossbarShape (XH - Descender)
include : DownwardLeftSerif (SB + (OX - O)) (XH - Descender) VJut
include : ShiftDown
save-as 'seven.onum.crossbarSerifed'
select-variant 'seven.lnum' '7' (follow -- 'seven')
select-variant 'seven.onum' (follow -- 'seven')
glyph-block Digits-Eight : begin
glyph-block-import CommonShapes
local EightPr : StrokeWidthBlend 0.85 0.925
define [EightShape top] : begin
@ -546,15 +540,13 @@ glyph-block Numbers : begin
arcvh
close
create-glyph : glyph-proc # eight
create-glyph 'eight.lnum' '8' : glyph-proc
include MarkSet.capital
include : EightShape CAP
save-as 'eight.lnum' '8'
save-as 'eight.onum'
# There is an "eight without lower contour" shape used for /propto
create-glyph : glyph-proc # rotetedpropto
create-glyph 'rotetedpropto' : glyph-proc # rotetedpropto
local p 0.96
local py 0.4
local l (SB + OX)
@ -570,49 +562,47 @@ glyph-block Numbers : begin
g4 [mix l r p] (CAP - SmoothB * p * EightPr)
alsoThru 0.5 py [widths (Stroke * py) (Stroke * (1 - py))]
straight.down.end l 0 [widths.heading Stroke 0 Downward]
save-as 'rotetedpropto'
glyph-block Digits-Nine : begin
glyph-block-import CommonShapes
glyph-block-import Digits-Shared : ShiftDown
glyph-block-import Digits-Six : ClosedContourNineShape OpenContourSixShape StraightBarSixShape
create-glyph : glyph-proc
create-glyph 'nine.lnum.closedContour' : glyph-proc
include MarkSet.capital
include : ClosedContourNineShape CAP
save-as 'nine.lnum.closedContour'
create-glyph : glyph-proc
create-glyph 'nine.onum.closedContour' : glyph-proc
include MarkSet.p
include : ClosedContourNineShape (XH - Descender)
include : ShiftDown
save-as 'nine.onum.closedContour'
create-glyph : glyph-proc
create-glyph 'nine.lnum.openContour' : glyph-proc
include MarkSet.capital
include : OpenContourSixShape CAP
include : FlipAround (Middle) (CAP / 2)
save-as 'nine.lnum.openContour'
create-glyph : glyph-proc
create-glyph 'nine.onum.openContour' : glyph-proc
include MarkSet.p
include : OpenContourSixShape CAP
include : FlipAround (Middle) (XH / 2)
save-as 'nine.onum.openContour'
create-glyph : glyph-proc
create-glyph 'nine.lnum.straightBar' : glyph-proc
include MarkSet.capital
include : StraightBarSixShape CAP
include : FlipAround (Middle) (CAP / 2)
save-as 'nine.lnum.straightBar'
create-glyph : glyph-proc
create-glyph 'nine.onum.straightBar' : glyph-proc
include MarkSet.p
include : StraightBarSixShape CAP
include : FlipAround (Middle) (XH / 2)
save-as 'nine.onum.straightBar'
select-variant 'nine.lnum' '9' (follow -- 'nine')
select-variant 'nine.onum' (follow -- 'nine')
do "Ten"
glyph-block Digits-Ten : begin
glyph-block-import CommonShapes
define GnOne 'one.lnum'
define GnZero 'zero.lnum'

View file

@ -105,11 +105,14 @@ define-macro create-derived : syntax-rules
inc externEnv.$nWFGlyphs$
local f0 : '.' + [[env.macros.get 'input-path']].1 + '.'
local tcn {".quote" (".WF" + f0 + externEnv.$nWFGlyphs$)}
dirty `[$createAndSaveGlyphImpl$ @tcn null [lambda : begin [this.include currentGlyph true true] [this.include @[formOf body]]]]
dirty `[create-derived @tcn null @[formOf body]]
`[create-derived @name @body] : begin
dirty `[$createAndSaveGlyphImpl$ @[formOf name] null [lambda : begin [this.include currentGlyph true true] [this.include @[formOf body]]]]
dirty `[create-derived @[formOf name] null @[formOf body]]
`[create-derived @name @code @body] : begin
dirty `[$createAndSaveGlyphImpl$ @[formOf name] @[formOf code] [lambda : begin [this.include currentGlyph true true] [this.include @[formOf body]]]]
dirty `[$createAndSaveGlyphImpl$ @[formOf name] @[formOf code] [lambda : begin
[this.include currentGlyph true true]
[this.cloneRankFromGlyph currentGlyph]
[this.include @[formOf body]] ]]
define-macro save-as : syntax-rules
`[save-as @name] : dirty `[$save$ currentGlyph @[formOf name] null]

View file

@ -81,6 +81,20 @@ module.exports = class Glyph {
if (copyWidth && g.advanceWidth >= 0) this.advanceWidth = g.advanceWidth;
this.dependsOn(g);
}
cloneFromGlyph(g) {
this.includeGlyph(g, true, true);
this.cloneRelationFromGlyph(g);
this.cloneRankFromGlyph(g);
}
cloneRelationFromGlyph(g) {
this.shortName = g.shortName;
this.related = g.related;
}
cloneRankFromGlyph(g) {
this.autoRefPriority = g.autoRefPriority;
this.glyphRank = g.glyphRank;
this.avoidBeingComposite = g.avoidBeingComposite;
}
includeGeometry(geom, shiftX, shiftY) {
if (!geom || !geom.contours) return;
for (const contour of geom.contours) {