diff --git a/font-src/meta/aesthetics.ptl b/font-src/meta/aesthetics.ptl index 4b9631591..d6b47fb11 100644 --- a/font-src/meta/aesthetics.ptl +++ b/font-src/meta/aesthetics.ptl @@ -289,11 +289,18 @@ export : define [copyFontMetrics fm1 fm2] : begin set fm2.post.underlineThickness fm1.post.underlineThickness +class CMarkSet + public [new markAnchors baseAnchors] : begin + set this.markAnchors markAnchors + set this.baseAnchors baseAnchors + public [applyToGlyph g] : begin + g.copyAnchors this + export : define [compositeBaseAnchors] : begin - local h {.} + local baseAnchorSink {.} foreach a [items-of arguments] : foreach k [items-of [Object.keys a.baseAnchors]] : begin - set h.(k) : new Anchor a.baseAnchors.(k).x a.baseAnchors.(k).y a.baseAnchors.(k).type a.baseAnchors.(k).mbx a.baseAnchors.(k).mby - return {.baseAnchors h .isMarkSet true} + set baseAnchorSink.(k) : new Anchor a.baseAnchors.(k).x a.baseAnchors.(k).y a.baseAnchors.(k).type a.baseAnchors.(k).mbx a.baseAnchors.(k).mby + return : new CMarkSet null baseAnchorSink export : define [MarksetDiv p sbMul me] : begin define width : p * me.Width @@ -388,16 +395,24 @@ export : define DesignParameters : object # Square dot squareDotScalar 0.95 -export : define [GenDivFrame metrics] : lambda [_div _hPack _sbMul] : begin - local div : fallback _div 1 - local hPack : Math.max 2 [fallback _hPack 0] - local sbMul : fallback _sbMul : Math.min 1 : (metrics.Width * div - hPack * [metrics.AdviceStroke hPack div]) / (2 * hPack * metrics.SB) - return : object - div div - width : metrics.Width * div - middle : metrics.Middle * div - sb : metrics.SB * sbMul - leftSB : metrics.SB * sbMul - rightSB : metrics.Width * div - metrics.SB * sbMul - mvs : metrics.AdviceStroke hPack div - markSet : MarksetDiv div sbMul metrics +export : define [GenDivFrame metrics] : begin + class CDivFrame + public [new _div _hPack _sbMul] : begin + local div : fallback _div 1 + local hPack : Math.max 2 [fallback _hPack 0] + local sbMul : fallback _sbMul : Math.min 1 : (metrics.Width * div - hPack * [metrics.AdviceStroke hPack div]) / (2 * hPack * metrics.SB) + + set this.div div + set this.width : metrics.Width * div + set this.middle : metrics.Middle * div + set this.sb : metrics.SB * sbMul + set this.leftSB : metrics.SB * sbMul + set this.rightSB : metrics.Width * div - metrics.SB * sbMul + set this.mvs : metrics.AdviceStroke hPack div + set this.markSet : MarksetDiv div sbMul metrics + + public [applyToGlyph g] : begin + g.setWidth this.width + return this + + return : lambda [_div _hPack _sbMul] : new CDivFrame _div _hPack _sbMul diff --git a/font-src/support/glyph/index.js b/font-src/support/glyph/index.js index 3363ad37c..b4dcae09b 100644 --- a/font-src/support/glyph/index.js +++ b/font-src/support/glyph/index.js @@ -65,10 +65,10 @@ exports.Glyph = class Glyph { throw new Error("Unreachable: Attempt to include a Null or Undefined"); } else if (component instanceof Function) { return component.call(this, copyAnchors, copyWidth); + } else if (component.applyToGlyph instanceof Function) { + return component.applyToGlyph(this, copyAnchors, copyWidth); } else if (component instanceof Transform) { return this.applyTransform(component, copyAnchors); - } else if (component.isMarkSet) { - return this.copyAnchors(component); } else if (component instanceof Glyph) { return this.includeGlyph(component, copyAnchors, copyWidth); } else { @@ -83,7 +83,8 @@ exports.Glyph = class Glyph { this.combineMarks(g, shift); this.includeGlyphImpl(g, shift.x, shift.y); - if (copyAnchors || g.isMarkSet) this.copyAnchors(g); + if (g.isMarkSet) throw new Error("Invalid component to be introduced."); + if (copyAnchors) this.copyAnchors(g); if (copyWidth && g.advanceWidth >= 0) this.advanceWidth = g.advanceWidth; this.dependsOn(g); }