Anchor cleanup
This commit is contained in:
parent
344d001217
commit
4f87c3b066
7 changed files with 50 additions and 58 deletions
|
@ -101,8 +101,7 @@ glyph-block AutoBuild-Accents : begin
|
|||
local s_parts nothing
|
||||
define construction : glyph-construction
|
||||
if s_code : assign-unicode s_code
|
||||
include s_parts.0 AS_BASE
|
||||
set-width s_parts.0.advanceWidth
|
||||
include s_parts.0 AS_BASE ALSO_METRICS
|
||||
|
||||
foreach part [items-of : s_parts.slice 1] : if part : begin
|
||||
include part
|
||||
|
|
|
@ -45,7 +45,7 @@ glyph-block AutoBuild-Enclosure : begin
|
|||
define gniPart : '.ci.' + gidPart + '@' + [{parts.length dscale width xCompress bal baly}.join '/']
|
||||
if [not : query-glyph gniPart] : begin
|
||||
create-glyph gniPart : glyph-construction
|
||||
include miniatureFont.(gidPart) AS_BASE ALSO_METRICS
|
||||
include miniatureFont.(gidPart) nothing ALSO_METRICS # Don't copy anchors
|
||||
apply-transform : Upright
|
||||
apply-transform : Scale (dscale * xCompress) dscale
|
||||
apply-transform : Translate 0 (dscale * (-CAP / 2 + shift))
|
||||
|
|
|
@ -220,8 +220,7 @@ glyph-block Letter-Cyrillic-Tse : begin
|
|||
save 'cyrtse.upright'
|
||||
|
||||
sketch # cyrtse.italic
|
||||
include MarkSet.e
|
||||
include : refer-glyph "u"
|
||||
include [refer-glyph "u"] AS_BASE
|
||||
eject-contour 'serifLT'
|
||||
include : CyrDescender RightSB (shift -- 0.05)
|
||||
save 'cyrtse.italic'
|
||||
|
@ -582,8 +581,7 @@ glyph-block Letter-Cyrillic-Sha : begin
|
|||
sketch # cyrshcha.italic
|
||||
local df : DivFrame para.diversityM 3
|
||||
set-width df.width
|
||||
include df.markSet.e
|
||||
include : refer-glyph "cyrsha.italic"
|
||||
include [refer-glyph "cyrsha.italic"] AS_BASE
|
||||
include : CyrDescender df.rightSB (shift -- 0.05)
|
||||
save 'cyrshcha.italic'
|
||||
|
||||
|
|
|
@ -2963,33 +2963,25 @@ glyph-block Letter-Latin-C : begin
|
|||
save 'ccurlytail' 0x255
|
||||
|
||||
sketch # cyrE
|
||||
include MarkSet.capital
|
||||
include : refer-glyph "C"
|
||||
include [refer-glyph "C"] AS_BASE
|
||||
include : FlipAround Middle (CAP / 2)
|
||||
include : HBar [mix SB RightSB 0.25] RightSB (CAP / 2)
|
||||
|
||||
save 'cyrE' 0x42D
|
||||
|
||||
sketch # cyre
|
||||
include MarkSet.e
|
||||
include : refer-glyph "c"
|
||||
include [refer-glyph "c"] AS_BASE
|
||||
include : FlipAround Middle (XH / 2)
|
||||
include : HBar [mix SB RightSB 0.25] RightSB (XH / 2)
|
||||
|
||||
save 'cyre' 0x44D
|
||||
|
||||
sketch # cyrYe
|
||||
include MarkSet.capital
|
||||
include : refer-glyph "C"
|
||||
include [refer-glyph "C"] AS_BASE
|
||||
include : HBar SB [mix RightSB SB 0.25] (CAP / 2) [adviceBlackness2 4 2 CAP]
|
||||
|
||||
save 'cyrYe' 0x404
|
||||
|
||||
sketch # cyrye
|
||||
include MarkSet.e
|
||||
include : refer-glyph "c"
|
||||
include [refer-glyph "c"] AS_BASE
|
||||
include : HBar SB [mix RightSB SB 0.25] (XH / 2) [adviceBlackness2 4 2 XH]
|
||||
|
||||
save 'cyrye' 0x454
|
||||
|
||||
sketch # sigma
|
||||
|
@ -3427,8 +3419,7 @@ glyph-block Letter-Latin-Lower-Q : begin
|
|||
save 'qrtail' 0x24B
|
||||
|
||||
sketch # qhooktop
|
||||
include MarkSet.p
|
||||
include : refer-glyph "q"
|
||||
include [refer-glyph "q"] AS_BASE
|
||||
eject-contour 'serifRT'
|
||||
include : VerticalHook (RightSB - HalfStroke * HVContrast) XH HookX (-Hook)
|
||||
save 'qhooktop' 0x2A0
|
||||
|
@ -5625,7 +5616,6 @@ glyph-block Letter-Latin-Thorn : begin
|
|||
include MarkSet.if
|
||||
save 'sho' 0x3F8
|
||||
|
||||
|
||||
glyph-block Letter-Latin-Hwair : begin
|
||||
glyph-block-import CommonShapes
|
||||
glyph-block-import Overmarks
|
||||
|
|
|
@ -224,7 +224,7 @@ export : define [compsiteMarkSet] : begin
|
|||
local h {.}
|
||||
foreach a [items-of arguments] : foreach k [items-of [Object.keys a.anchors]] : begin
|
||||
set h.(k) : new Anchor a.anchors.(k).x a.anchors.(k).y a.anchors.(k).type a.anchors.(k).mbx a.anchors.(k).mby
|
||||
return {.anchors h}
|
||||
return {.anchors h .isMarkSet true}
|
||||
|
||||
export : define [MarksetDiv p me] : begin
|
||||
define [object MARK BASE] Anchor
|
||||
|
|
|
@ -50,44 +50,49 @@ export all : class Glyph
|
|||
glyph.dependencies : this.dependencies = [this.dependencies.concat glyph.dependencies]
|
||||
return this
|
||||
|
||||
public [includeGeometry geom shiftx shifty] : begin
|
||||
if (!geom || !geom.contours) : return nothing
|
||||
foreach [contour : items-of geom.contours] : begin
|
||||
local c {}
|
||||
set c.tag : contour.tag || geom.tag || this.defaultTag
|
||||
foreach [point : items-of contour] : begin
|
||||
c.push : new Point (point.x + shiftx) (point.y + shifty) point.on point.cubic point.subdivided
|
||||
this.contours.push c
|
||||
|
||||
public [combineAnchor markid shift anchorThis anchorThat] : begin
|
||||
if (!anchorThis || !anchorThat || anchorThat.type !== Anchor.MARK) : return nothing
|
||||
if (anchorThis.type === Anchor.BASE) : begin
|
||||
set shift.x : anchorThis.x - anchorThat.x
|
||||
set shift.y : anchorThis.y - anchorThat.y
|
||||
if (anchorThat.mbx !== nothing && anchorThat.mby !== nothing)
|
||||
set this.anchors.(markid) : new Anchor
|
||||
* (anchorThis.x + anchorThat.mbx - anchorThat.x)
|
||||
* (anchorThis.y + anchorThat.mby - anchorThat.y)
|
||||
* Anchor.BASE
|
||||
: else : if (anchorThis.mbx !== nothing && anchorThis.mby !== nothing) : begin
|
||||
set shift.x : anchorThis.mbx - anchorThat.x
|
||||
set shift.y : anchorThis.mby - anchorThat.y
|
||||
if (anchorThat.mbx !== nothing && anchorThat.mby !== nothing)
|
||||
set this.anchors.(markid) : new Anchor
|
||||
* anchorThis.x
|
||||
* anchorThis.y
|
||||
* anchorThis.type
|
||||
* (anchorThis.mbx + anchorThat.mbx - anchorThat.x)
|
||||
* (anchorThis.mby + anchorThat.mby - anchorThat.y)
|
||||
|
||||
public [includeGlyph glyph copyAnchors copyWidth] : begin
|
||||
if (glyph <@ Function) : begin
|
||||
throw "\(this.name): Cannot include a function using includeGlyph. Use include instead."
|
||||
|
||||
local contours glyph.contours
|
||||
local shiftx 0
|
||||
local shifty 0
|
||||
local t this
|
||||
if (this.anchors && glyph.anchors) : foreach markid [items-of [Object.keys this.anchors]] : begin
|
||||
local anchorThis this.anchors.(markid)
|
||||
local shift {.x 0 .y 0}
|
||||
if glyph.anchors : foreach { markid anchorThis } [pairs-of this.anchors] : begin
|
||||
local anchorThat glyph.anchors.(markid)
|
||||
if ( anchorThis && (anchorThis.type === Anchor.BASE || anchorThis.mbx !== nothing && anchorThis.mby !== nothing)
|
||||
&& anchorThat && anchorThat.type === Anchor.MARK) : begin
|
||||
set shiftx : [fallback anchorThis.mbx anchorThis.x] - anchorThat.x
|
||||
set shifty : [fallback anchorThis.mby anchorThis.y] - anchorThat.y
|
||||
# we have a mark-to-mark position
|
||||
if (anchorThat.mbx !== nothing && anchorThat.mby !== nothing) : if (anchorThis.type === Anchor.BASE)
|
||||
then : set this.anchors.(markid) : new Anchor
|
||||
* (anchorThis.x + anchorThat.mbx - anchorThat.x)
|
||||
* (anchorThis.y + anchorThat.mby - anchorThat.y)
|
||||
* Anchor.BASE
|
||||
else : set this.anchors.(markid) : new Anchor
|
||||
* anchorThis.x
|
||||
* anchorThis.y
|
||||
* anchorThis.type
|
||||
* (anchorThis.mbx + anchorThat.mbx - anchorThat.x)
|
||||
* (anchorThis.mby + anchorThat.mby - anchorThat.y)
|
||||
if contours : begin
|
||||
local newcontours {}
|
||||
foreach [contour : items-of contours] : begin
|
||||
local c {}
|
||||
set c.tag : contour.tag || glyph.tag || t.defaultTag
|
||||
foreach [point : items-of contour] : begin
|
||||
c.push : new Point (point.x + shiftx) (point.y + shifty) point.on point.cubic point.subdivided
|
||||
newcontours.push c
|
||||
set this.contours : this.contours.concat newcontours
|
||||
if (([not contours] || copyAnchors) && glyph.anchors) : begin
|
||||
foreach [k : items-of : Object.keys glyph.anchors] : set this.anchors.(k) glyph.anchors.(k)
|
||||
this.combineAnchor markid shift anchorThis anchorThat
|
||||
|
||||
this.includeGeometry glyph shift.x shift.y
|
||||
if ((copyAnchors || glyph.isMarkSet) && glyph.anchors) : begin
|
||||
foreach [k : items-of : Object.keys glyph.anchors] : begin
|
||||
set this.anchors.(k) glyph.anchors.(k)
|
||||
if (glyph.advanceWidth >= 0 && copyWidth) : set this.advanceWidth glyph.advanceWidth
|
||||
if glyph.name : this.dependencies.push glyph.name
|
||||
if glyph.dependencies : this.dependencies = [this.dependencies.concat glyph.dependencies]
|
||||
|
|
|
@ -186,7 +186,7 @@ export : define [SetupBuilders args] : begin
|
|||
set g.knots knots
|
||||
set g.lhsKnots lhs
|
||||
set g.rhsKnots rhs
|
||||
this.includeGlyph g
|
||||
this.includeGeometry g 0 0
|
||||
return g
|
||||
|
||||
define [spiro-outline] : let [k : {}.slice.call arguments 0] : lambda [dontinc] : begin
|
||||
|
@ -194,7 +194,7 @@ export : define [SetupBuilders args] : begin
|
|||
local {.knots knots .closed closed .lastafs lastafs} : prepareSpiroKnots k g
|
||||
SpiroJs.spiroToBezierOnContext knots closed g QUAD PRECISION
|
||||
foreach af [items-of lastafs] : if af : af.call g
|
||||
this.includeGlyph g
|
||||
this.includeGeometry g 0 0
|
||||
return g
|
||||
|
||||
return [object
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue