Fix glyph positioning in the 3D view
This commit is contained in:
parent
7d3afa0e74
commit
eae20eb7ca
|
@ -237,8 +237,8 @@ class ThreeDView extends PathfinderDemoView {
|
||||||
pathColors.set(TEXT_COLOR, startOffset);
|
pathColors.set(TEXT_COLOR, startOffset);
|
||||||
|
|
||||||
const textGlyph = textGlyphs[pathIndex];
|
const textGlyph = textGlyphs[pathIndex];
|
||||||
const glyphRect = textGlyph.pixelRect(hint, PIXELS_PER_UNIT);
|
const glyphOrigin = textGlyph.calculatePixelOrigin(hint, PIXELS_PER_UNIT);
|
||||||
pathTransforms.set([1, 1, glyphRect[0], glyphRect[1]], startOffset);
|
pathTransforms.set([1, 1, glyphOrigin[0], glyphOrigin[1]], startOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
const pathColorsBufferTexture = new PathfinderBufferTexture(this.gl, 'uPathColors');
|
const pathColorsBufferTexture = new PathfinderBufferTexture(this.gl, 'uPathColors');
|
||||||
|
|
|
@ -344,10 +344,15 @@ export abstract class PathfinderGlyph {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pixelRect(hint: Hint, pixelsPerUnit: number): glmatrix.vec4 {
|
calculatePixelOrigin(hint: Hint, pixelsPerUnit: number): glmatrix.vec2 {
|
||||||
const pixelMetrics = this.pixelMetrics(hint, pixelsPerUnit);
|
|
||||||
const textGlyphOrigin = glmatrix.vec2.clone(this.origin);
|
const textGlyphOrigin = glmatrix.vec2.clone(this.origin);
|
||||||
glmatrix.vec2.scale(textGlyphOrigin, textGlyphOrigin, pixelsPerUnit);
|
glmatrix.vec2.scale(textGlyphOrigin, textGlyphOrigin, pixelsPerUnit);
|
||||||
|
return textGlyphOrigin;
|
||||||
|
}
|
||||||
|
|
||||||
|
pixelRect(hint: Hint, pixelsPerUnit: number): glmatrix.vec4 {
|
||||||
|
const pixelMetrics = this.pixelMetrics(hint, pixelsPerUnit);
|
||||||
|
const textGlyphOrigin = this.calculatePixelOrigin(hint, pixelsPerUnit);
|
||||||
glmatrix.vec2.round(textGlyphOrigin, textGlyphOrigin);
|
glmatrix.vec2.round(textGlyphOrigin, textGlyphOrigin);
|
||||||
|
|
||||||
return glmatrix.vec4.fromValues(textGlyphOrigin[0],
|
return glmatrix.vec4.fromValues(textGlyphOrigin[0],
|
||||||
|
|
Loading…
Reference in New Issue