Reduce the need of creating pre-baked composites
This commit is contained in:
parent
7fc538f4f0
commit
99c8687812
2 changed files with 46 additions and 44 deletions
|
@ -133,14 +133,24 @@ glyph-block AutoBuild-Accents : begin
|
|||
set s_parts parts
|
||||
return : create-glyph goalName code construction
|
||||
|
||||
define [NeedBuildMesh glyphName part0Name] : begin
|
||||
define g : query-glyph glyphName
|
||||
define part0 : query-glyph part0Name
|
||||
if [not g] : return false
|
||||
if [not part0] : return false
|
||||
if [not : CvDecompose.get g] : return true
|
||||
if [DotlessOrNot.query part0] : return true
|
||||
return false
|
||||
|
||||
foreach [_id : items-of : Object.keys foundDecompositions] : do
|
||||
local { glyphName code parts } foundDecompositions.(_id)
|
||||
|
||||
local result : RootGlyphProc glyphName code parts
|
||||
if result : begin
|
||||
local saved : RootGlyphProc glyphName code parts
|
||||
if saved : begin
|
||||
define part0Name : glyphStore.queryNameOf parts.0
|
||||
if (parts.0 != [query-glyph part0Name]) : throw : new Error "Unreachable"
|
||||
|
||||
if [NeedBuildMesh glyphName part0Name] : begin
|
||||
local dstTree {}
|
||||
local targetNameMap {.}
|
||||
set targetNameMap.(part0Name) glyphName
|
||||
|
|
|
@ -85,18 +85,10 @@ module.exports = class Glyph {
|
|||
}
|
||||
}
|
||||
|
||||
const newContours = this.includeGeometry(g, shift.x, shift.y);
|
||||
this.includeGlyphImpl(g, shift.x, shift.y);
|
||||
if (copyAnchors || g.isMarkSet) this.copyAnchors(g);
|
||||
if (copyWidth && g.advanceWidth >= 0) this.advanceWidth = g.advanceWidth;
|
||||
this.dependsOn(g);
|
||||
if (g._m_identifier && newContours && newContours.length) {
|
||||
this.semanticInclusions.push({
|
||||
glyph: g,
|
||||
x: shift.x,
|
||||
y: shift.y,
|
||||
contours: newContours
|
||||
});
|
||||
}
|
||||
}
|
||||
cloneFromGlyph(g) {
|
||||
this.includeGlyph(g, true, true);
|
||||
|
@ -113,12 +105,6 @@ module.exports = class Glyph {
|
|||
this.avoidBeingComposite = g.avoidBeingComposite;
|
||||
}
|
||||
|
||||
includeGeometry(geom, shiftX, shiftY) {
|
||||
if (!geom || !geom.contours || !geom.contours.length) return null;
|
||||
if (this.includeGeometryAsTransparentReferences(geom, shiftX, shiftY)) return null;
|
||||
return this.includeContours(geom.contours, shiftX, shiftY);
|
||||
}
|
||||
|
||||
isPureComposite() {
|
||||
if (!this.semanticInclusions || !this.semanticInclusions.length) return false;
|
||||
const origContourSet = new Set(this.contours);
|
||||
|
@ -133,22 +119,28 @@ module.exports = class Glyph {
|
|||
return true;
|
||||
}
|
||||
|
||||
includeGeometryAsTransparentReferences(geom, shiftX, shiftY) {
|
||||
if (!(geom instanceof Glyph && !geom._m_identifier)) return false;
|
||||
if (!geom.isPureComposite()) return false;
|
||||
|
||||
for (const sr of geom.semanticInclusions) {
|
||||
const cs = this.includeContours(sr.glyph.contours, sr.x + shiftX, sr.y + shiftY);
|
||||
if (cs) {
|
||||
includeGlyphImpl(g, shiftX, shiftY) {
|
||||
if (g._m_identifier) {
|
||||
this.includeGlyphComponentImpl(g, shiftX, shiftY);
|
||||
} else {
|
||||
this.includeGeometry(g, shiftX, shiftY);
|
||||
}
|
||||
}
|
||||
includeGlyphComponentImpl(g, shiftX, shiftY) {
|
||||
const newContours = this.includeGeometry(g, shiftX, shiftY);
|
||||
if (newContours && newContours.length) {
|
||||
this.semanticInclusions.push({
|
||||
glyph: sr.glyph,
|
||||
x: sr.x + shiftX,
|
||||
y: sr.y + shiftY,
|
||||
contours: cs
|
||||
glyph: g,
|
||||
x: shiftX,
|
||||
y: shiftY,
|
||||
contours: newContours
|
||||
});
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
includeGeometry(geom, shiftX, shiftY) {
|
||||
if (!geom || !geom.contours || !geom.contours.length) return null;
|
||||
return this.includeContours(geom.contours, shiftX, shiftY);
|
||||
}
|
||||
includeContours(contours, shiftX, shiftY) {
|
||||
let newContours = [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue