Enable glyph block filtering and dependency tracker.
This commit is contained in:
parent
183b02d652
commit
0a74f44f0f
10 changed files with 75 additions and 42 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue