diff --git a/demo/client/src/3d-demo.ts b/demo/client/src/3d-demo.ts index 8ab26e33..cc980d00 100644 --- a/demo/client/src/3d-demo.ts +++ b/demo/client/src/3d-demo.ts @@ -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'); diff --git a/demo/client/src/text.ts b/demo/client/src/text.ts index 04d79bd9..3d69f83a 100644 --- a/demo/client/src/text.ts +++ b/demo/client/src/text.ts @@ -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],