Key glyphs in the atlas off "glyph keys" rather than raw glyph IDs
This commit is contained in:
parent
37a88dfcd9
commit
7e4308d52e
|
@ -503,12 +503,13 @@ class TextDemoView extends MonochromePathfinderView {
|
||||||
if (glyphStoreIndex == null)
|
if (glyphStoreIndex == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
atlasGlyphs.push(new AtlasGlyph(glyphStoreIndex, glyphID));
|
const glyphKey = new GlyphKey(glyphID);
|
||||||
|
atlasGlyphs.push(new AtlasGlyph(glyphStoreIndex, glyphKey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
atlasGlyphs.sort((a, b) => a.glyphID - b.glyphID);
|
atlasGlyphs.sort((a, b) => a.glyphKey.sortKey - b.glyphKey.sortKey);
|
||||||
atlasGlyphs = _.sortedUniqBy(atlasGlyphs, glyph => glyph.glyphID);
|
atlasGlyphs = _.sortedUniqBy(atlasGlyphs, glyph => glyph.glyphKey.sortKey);
|
||||||
if (atlasGlyphs.length === 0)
|
if (atlasGlyphs.length === 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -554,7 +555,7 @@ class TextDemoView extends MonochromePathfinderView {
|
||||||
const hint = this.appController.createHint();
|
const hint = this.appController.createHint();
|
||||||
const pixelsPerUnit = this.appController.pixelsPerUnit;
|
const pixelsPerUnit = this.appController.pixelsPerUnit;
|
||||||
|
|
||||||
const atlasGlyphIDs = atlasGlyphs.map(atlasGlyph => atlasGlyph.glyphID);
|
const atlasGlyphIDs = atlasGlyphs.map(atlasGlyph => atlasGlyph.glyphKey.id);
|
||||||
|
|
||||||
const glyphTexCoords = new Float32Array(textFrame.totalGlyphCount * 8);
|
const glyphTexCoords = new Float32Array(textFrame.totalGlyphCount * 8);
|
||||||
|
|
||||||
|
@ -571,7 +572,7 @@ class TextDemoView extends MonochromePathfinderView {
|
||||||
|
|
||||||
// Set texture coordinates.
|
// Set texture coordinates.
|
||||||
const atlasGlyph = atlasGlyphs[atlasGlyphIndex];
|
const atlasGlyph = atlasGlyphs[atlasGlyphIndex];
|
||||||
const atlasGlyphMetrics = font.metricsForGlyph(atlasGlyph.glyphID);
|
const atlasGlyphMetrics = font.metricsForGlyph(atlasGlyph.glyphKey.id);
|
||||||
if (atlasGlyphMetrics == null)
|
if (atlasGlyphMetrics == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -668,7 +669,7 @@ class Atlas {
|
||||||
|
|
||||||
for (const glyph of glyphs) {
|
for (const glyph of glyphs) {
|
||||||
// Place the glyph, and advance the origin.
|
// Place the glyph, and advance the origin.
|
||||||
const metrics = font.metricsForGlyph(glyph.glyphID);
|
const metrics = font.metricsForGlyph(glyph.glyphKey.id);
|
||||||
if (metrics == null)
|
if (metrics == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -730,12 +731,12 @@ class Atlas {
|
||||||
|
|
||||||
class AtlasGlyph {
|
class AtlasGlyph {
|
||||||
readonly glyphStoreIndex: number;
|
readonly glyphStoreIndex: number;
|
||||||
readonly glyphID: number;
|
readonly glyphKey: GlyphKey;
|
||||||
readonly origin: glmatrix.vec2;
|
readonly origin: glmatrix.vec2;
|
||||||
|
|
||||||
constructor(glyphStoreIndex: number, glyphID: number) {
|
constructor(glyphStoreIndex: number, glyphKey: GlyphKey) {
|
||||||
this.glyphStoreIndex = glyphStoreIndex;
|
this.glyphStoreIndex = glyphStoreIndex;
|
||||||
this.glyphID = glyphID;
|
this.glyphKey = glyphKey;
|
||||||
this.origin = glmatrix.vec2.create();
|
this.origin = glmatrix.vec2.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -760,6 +761,18 @@ class AtlasGlyph {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class GlyphKey {
|
||||||
|
readonly id: number;
|
||||||
|
|
||||||
|
constructor(id: number) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
get sortKey(): number {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const ANTIALIASING_STRATEGIES: AntialiasingStrategyTable = {
|
const ANTIALIASING_STRATEGIES: AntialiasingStrategyTable = {
|
||||||
ecaa: ECAAMonochromeStrategy,
|
ecaa: ECAAMonochromeStrategy,
|
||||||
none: NoAAStrategy,
|
none: NoAAStrategy,
|
||||||
|
|
Loading…
Reference in New Issue