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);
|
||||
|
||||
const textGlyph = textGlyphs[pathIndex];
|
||||
const glyphRect = textGlyph.pixelRect(hint, PIXELS_PER_UNIT);
|
||||
pathTransforms.set([1, 1, glyphRect[0], glyphRect[1]], startOffset);
|
||||
const glyphOrigin = textGlyph.calculatePixelOrigin(hint, PIXELS_PER_UNIT);
|
||||
pathTransforms.set([1, 1, glyphOrigin[0], glyphOrigin[1]], startOffset);
|
||||
}
|
||||
|
||||
const pathColorsBufferTexture = new PathfinderBufferTexture(this.gl, 'uPathColors');
|
||||
|
|
|
@ -344,10 +344,15 @@ export abstract class PathfinderGlyph {
|
|||
};
|
||||
}
|
||||
|
||||
pixelRect(hint: Hint, pixelsPerUnit: number): glmatrix.vec4 {
|
||||
const pixelMetrics = this.pixelMetrics(hint, pixelsPerUnit);
|
||||
calculatePixelOrigin(hint: Hint, pixelsPerUnit: number): glmatrix.vec2 {
|
||||
const textGlyphOrigin = glmatrix.vec2.clone(this.origin);
|
||||
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);
|
||||
|
||||
return glmatrix.vec4.fromValues(textGlyphOrigin[0],
|
||||
|
|
Loading…
Reference in New Issue