Fix glyph positioning in the 3D view

This commit is contained in:
Patrick Walton 2017-09-11 19:09:43 -07:00
parent 7d3afa0e74
commit eae20eb7ca
2 changed files with 9 additions and 4 deletions

View File

@ -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');

View File

@ -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],