Skip to content

Commit b8912e4

Browse files
committed
vertical textAnchor is now set properly for multiline text
Signed-off-by: Tim Deubler <tim.deubler@here.com>
1 parent 05b67ba commit b8912e4

File tree

1 file changed

+10
-10
lines changed
  • packages/display/src/displays/webgl/buffer

1 file changed

+10
-10
lines changed

packages/display/src/displays/webgl/buffer/addText.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ import {TextStyle} from '@here/xyz-maps-core';
2525
const EXTENT_SCALE = 64;
2626

2727
const ANCHOR_OFFSET: Record<TextStyle['textAnchor'], { x: number, y: number }> = {
28-
Center: {x: .5, y: 0},
29-
Left: {x: 0, y: 0},
30-
Right: {x: 1, y: 0},
31-
Top: {x: .5, y: -1},
32-
TopLeft: {x: 0, y: -1},
33-
TopRight: {x: 1, y: -1},
34-
Bottom: {x: .5, y: 1},
35-
BottomLeft: {x: 0, y: 1},
36-
BottomRight: {x: 1, y: 1}
28+
Center: {x: .5, y: 1},
29+
Left: {x: 0, y: 1},
30+
Right: {x: 1, y: 1},
31+
Top: {x: .5, y: 0},
32+
TopLeft: {x: 0, y: 0},
33+
TopRight: {x: 1, y: 0},
34+
Bottom: {x: .5, y: 2},
35+
BottomLeft: {x: 0, y: 2},
36+
BottomRight: {x: 1, y: 2}
3737
};
3838

3939
const addText = (
@@ -52,7 +52,7 @@ const addText = (
5252
const lineOffset = lines.length - 1;
5353
const lineHeight = glyphAtlas.lineHeight;
5454
const anchorOffset = ANCHOR_OFFSET[textAnchor] || ANCHOR_OFFSET.Center;
55-
let ty = (glyphAtlas.baselineOffset + lineHeight * (lineOffset * .5 + anchorOffset.y * (lineOffset || 1))) * OFFSET_SCALE;
55+
let ty = (glyphAtlas.baselineOffset + lineHeight * lineOffset * .5) * OFFSET_SCALE * anchorOffset.y;
5656

5757
// LSB defines visibility, visible by default
5858
cx = cx * EXTENT_SCALE << 1 | 1;

0 commit comments

Comments
 (0)