Add mechanism for including letter models
This commit is contained in:
parent
9d89f5ac7c
commit
41e1c99e37
2 changed files with 35 additions and 19 deletions
|
@ -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
|
||||
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)
|
||||
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
|
||||
|
||||
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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue