diff --git a/font-src/gen/finalize/glyphs.mjs b/font-src/gen/finalize/glyphs.mjs index 495a40b37..7b5ab3eeb 100644 --- a/font-src/gen/finalize/glyphs.mjs +++ b/font-src/gen/finalize/glyphs.mjs @@ -107,6 +107,9 @@ class SimplifyGeometry extends Geom.GeometryBase { asReferences() { return null; } + getDependencies() { + return this.m_geom.getDependencies(); + } filterTag(fn) { return this.m_geom.filterTag(fn); } diff --git a/font-src/glyphs/common/derivatives.ptl b/font-src/glyphs/common/derivatives.ptl index 58fbf1de8..675eb3ce7 100644 --- a/font-src/glyphs/common/derivatives.ptl +++ b/font-src/glyphs/common/derivatives.ptl @@ -65,12 +65,6 @@ glyph-block Common-Derivatives : begin if [not goal] : throw : new Error "Cannot find glyph '\(id)'" this.includeGlyph goal copyAnchors copyWidth - glyph-block-export add-glyph-dependency - define [add-glyph-dependency id] : lambda [copyAnchors copyWidth] : begin - local goal : query-glyph id - if [not goal] : throw : new Error "Cannot find glyph '\(id)'" - this.dependsOn goal - glyph-block-export DeriveMeshT define [DeriveMeshT gnSources Query Fn FnLink] : begin local linksGnMap : new Map diff --git a/font-src/glyphs/letter/latin-ext/upper-aa-ao.ptl b/font-src/glyphs/letter/latin-ext/upper-aa-ao.ptl index b8ff60cca..5f0f3c73d 100644 --- a/font-src/glyphs/letter/latin-ext/upper-aa-ao.ptl +++ b/font-src/glyphs/letter/latin-ext/upper-aa-ao.ptl @@ -82,11 +82,6 @@ glyph-block Letter-Latin-Upper-AA-AO : begin define topSerifGap : Math.max (0.1 * (df.rightSB - df.leftSB)) [AdviceStroke 6] define { left leftMask right rightMask } srcs - include : add-glyph-dependency left - include : add-glyph-dependency leftMask - include : add-glyph-dependency right - include : add-glyph-dependency rightMask - include [refer-glyph left] AS_BASE ALSO_METRICS include : difference refer-glyph right diff --git a/font-src/glyphs/letter/shared.ptl b/font-src/glyphs/letter/shared.ptl index 6b788dbcd..ee87fcaeb 100644 --- a/font-src/glyphs/letter/shared.ptl +++ b/font-src/glyphs/letter/shared.ptl @@ -471,7 +471,6 @@ glyph-block Letter-Shared-Shapes : begin glyph-block-export ConnectedCedilla define [ConnectedCedilla src sel] : glyph-proc include [refer-glyph src] AS_BASE ALSO_METRICS - include : add-glyph-dependency 'cedillaExtShapeBelow' local mk : currentGlyph.baseAnchors.leaningBelow || currentGlyph.baseAnchors.below local tfm : ApparentTranslate (mk.x - markMiddle) (mk.y - 0) include : difference diff --git a/font-src/glyphs/symbol/braille.ptl b/font-src/glyphs/symbol/braille.ptl index 172a0a184..531979f75 100644 --- a/font-src/glyphs/symbol/braille.ptl +++ b/font-src/glyphs/symbol/braille.ptl @@ -7,8 +7,6 @@ import [maskBit maskBits popCountByte] from"../../support/util/mask-bit.mjs" glyph-module glyph-block Symbol-Braille : begin - if recursive : return nothing - glyph-block-import CommonShapes glyph-block-import Common-Derivatives diff --git a/font-src/glyphs/symbol/mosaic.ptl b/font-src/glyphs/symbol/mosaic.ptl index 521c1abc3..d45046c55 100644 --- a/font-src/glyphs/symbol/mosaic.ptl +++ b/font-src/glyphs/symbol/mosaic.ptl @@ -6,8 +6,6 @@ import [mix linreg clamp fallback] from"../../support/utils.mjs" glyph-module glyph-block Symbol-Mosaic : begin - if recursive : return nothing - glyph-block-import CommonShapes glyph-block-import Common-Derivatives diff --git a/font-src/meta/macros.ptl b/font-src/meta/macros.ptl index 1caa047bd..bdcb3a010 100644 --- a/font-src/meta/macros.ptl +++ b/font-src/meta/macros.ptl @@ -165,7 +165,7 @@ define-macro glyph-block-import : syntax-rules Common-Derivatives `[select-variant orthographic-italic orthographic-slanted refer-glyph query-glyph alias turned HDual HCombine VDual VCombine derive-glyphs derive-composites link-reduced-variant alias-reduced-variant HalfAdvance TurnMarks - derive-multi-part-glyphs DeriveMeshT add-glyph-dependency] + derive-multi-part-glyphs DeriveMeshT] CommonShapes `[no-shape tagged KnotAdj Rect SquareAt Ring RingAt DotAt RingStroke RingStrokeAt DotStrokeAt CircleRing CircleRingAt CircleDotAt RoundStrokeTerminalAt diff --git a/font-src/support/geometry/index.mjs b/font-src/support/geometry/index.mjs index 9a35bae9f..d414fa004 100644 --- a/font-src/support/geometry/index.mjs +++ b/font-src/support/geometry/index.mjs @@ -17,6 +17,9 @@ export class GeometryBase { asReferences() { throw new Error("Unimplemented"); } + getDependencies() { + throw new Error("Unimplemented"); + } unlinkReferences() { return this; } @@ -51,6 +54,9 @@ export class ContourGeometry extends GeometryBase { asReferences() { return null; } + getDependencies() { + return null; + } filterTag(fn) { return this; } @@ -89,6 +95,9 @@ export class SpiroGeometry extends GeometryBase { asReferences() { return null; } + getDependencies() { + return null; + } filterTag(fn) { return this; } @@ -161,6 +170,9 @@ export class DiSpiroGeometry extends GeometryBase { asReferences() { return null; } + getDependencies() { + return null; + } filterTag(fn) { return this; } @@ -206,6 +218,9 @@ export class ReferenceGeometry extends GeometryBase { if (this.isEmpty()) return []; return [{ glyph: this.m_glyph, x: this.m_x, y: this.m_y }]; } + getDependencies() { + return [this.m_glyph]; + } filterTag(fn) { if (this.isEmpty()) return null; return this.unwrap().filterTag(fn); @@ -239,6 +254,9 @@ export class TaggedGeometry extends GeometryBase { asReferences() { return this.m_geom.asReferences(); } + getDependencies() { + return this.m_geom.getDependencies(); + } filterTag(fn) { if (!fn(this.m_tag)) return null; else return new TaggedGeometry(this.m_geom.filterTag(fn), this.m_tag); @@ -281,6 +299,9 @@ export class TransformedGeometry extends GeometryBase { result.push({ glyph, x: x + this.m_transform.x, y: y + this.m_transform.y }); return result; } + getDependencies() { + return this.m_geom.getDependencies(); + } filterTag(fn) { const e = this.m_geom.filterTag(fn); if (!e) return null; @@ -330,6 +351,9 @@ export class RadicalGeometry extends GeometryBase { asReferences() { return null; } + getDependencies() { + return this.m_geom.getDependencies(); + } filterTag(fn) { const e = this.m_geom.filterTag(fn); if (!e) return null; @@ -383,6 +407,15 @@ export class CombineGeometry extends GeometryBase { } return results; } + getDependencies() { + let results = []; + for (const part of this.m_parts) { + const rs = part.getDependencies(); + if (!rs) continue; + for (const c of rs) results.push(c); + } + return results; + } filterTag(fn) { let filtered = []; for (const part of this.m_parts) { @@ -454,6 +487,15 @@ export class BooleanGeometry extends GeometryBase { asReferences() { return null; } + getDependencies() { + let results = []; + for (const part of this.m_operands) { + const rs = part.getDependencies(); + if (!rs) continue; + for (const c of rs) results.push(c); + } + return results; + } filterTag(fn) { let filtered = []; for (const operand of this.m_operands) { diff --git a/font-src/support/glyph-block.mjs b/font-src/support/glyph-block.mjs index 74a691a09..1ca0f9217 100644 --- a/font-src/support/glyph-block.mjs +++ b/font-src/support/glyph-block.mjs @@ -19,12 +19,12 @@ export class GlyphBuildExecutor { } } executePendingBlocks() { - // if (!this.recursiveBuildFilter) { - for (const block of this.pendingGlyphBlocks) block.resolve(); - // } else { - // for (const block of this.pendingGlyphBlocks) - // if (this.recursiveBuildFilter.blockIsNeeded(block.id)) block.resolve(); - // } + if (!this.recursiveBuildFilter) { + for (const block of this.pendingGlyphBlocks) block.resolve(); + } else { + for (const block of this.pendingGlyphBlocks) + if (this.recursiveBuildFilter.blockIsNeeded(block.id)) block.resolve(); + } } defineGlyphBlock(capture, id, body) { const block = new GlyphBlock(capture, this, id, body); diff --git a/font-src/support/glyph/index.mjs b/font-src/support/glyph/index.mjs index 223796f63..da52941d8 100644 --- a/font-src/support/glyph/index.mjs +++ b/font-src/support/glyph/index.mjs @@ -6,8 +6,8 @@ import { Point, Vec2 } from "../geometry/point.mjs"; import { Transform } from "../geometry/transform.mjs"; export class Glyph { - constructor(_identifier) { - this._m_identifier = _identifier; + constructor(identifier) { + this._m_identifier = identifier; // Ranks this.glyphRank = 0; this.grRank = 0; @@ -65,6 +65,21 @@ export class Glyph { if (!this._m_dependencyManager) return; this._m_dependencyManager.addDependency(this, glyph); } + + // Copying + cloneFromGlyph(g) { + this.includeGlyph(g, true, true); + this.cloneRelationFromGlyph(g); + this.cloneRankFromGlyph(g); + } + cloneRelationFromGlyph(g) { + this.related = g.related; + } + cloneRankFromGlyph(g) { + this.glyphRank = g.glyphRank; + this.avoidBeingComposite = g.avoidBeingComposite; + } + // Inclusion include(component, copyAnchors, copyWidth) { if (!component) { @@ -92,23 +107,6 @@ export class Glyph { 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); - } - cloneFromGlyph(g) { - this.includeGlyph(g, true, true); - this.cloneRelationFromGlyph(g); - this.cloneRankFromGlyph(g); - } - cloneRelationFromGlyph(g) { - this.related = g.related; - } - cloneRankFromGlyph(g) { - this.glyphRank = g.glyphRank; - this.avoidBeingComposite = g.avoidBeingComposite; - } - includeGeometry(g) { - if (this.ctxTag) g = new Geom.TaggedGeometry(g, this.ctxTag); - this.geometry = Geom.combineWith(this.geometry, g); } includeGlyphImpl(g, shiftX, shiftY) { if (g._m_identifier) { @@ -119,6 +117,12 @@ export class Glyph { ); } } + includeGeometry(g) { + let deps = g.getDependencies(); + if (deps && deps.length) for (const dep of deps) this.dependsOn(dep); + if (this.ctxTag) g = new Geom.TaggedGeometry(g, this.ctxTag); + this.geometry = Geom.combineWith(this.geometry, g); + } includeContours(cs, shiftX, shiftY) { let parts = []; for (const contour of cs) {