Skip to content

Commit 0042541

Browse files
committed
Fix review comments
1 parent 0ec2ab5 commit 0042541

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/symbol/quads.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,15 @@ function getRotateOffset(textOffset: [number, number]) {
230230
}
231231
}
232232

233+
function getMidlineOffset(shaping, lineHeight, previousOffset, lineIndex) {
234+
const currentLineHeight = (lineHeight + shaping.positionedLines[lineIndex].lineOffset);
235+
if (lineIndex === 0) {
236+
return previousOffset + currentLineHeight / 2.0;
237+
}
238+
const aboveLineHeight = (lineHeight + shaping.positionedLines[lineIndex - 1].lineOffset);
239+
return previousOffset + (currentLineHeight + aboveLineHeight) / 2.0;
240+
}
241+
233242
/**
234243
* Create the quads used for rendering a text label.
235244
* @private
@@ -254,14 +263,6 @@ export function getGlyphQuads(anchor: Anchor,
254263
}
255264
const lineCounts = shaping.positionedLines.length;
256265
const lineHeight = shapingHeight / lineCounts;
257-
const getMidlineOffset = function(shaping, lineHeight, previousOffset, lineIndex) {
258-
const currentLineHeight = (lineHeight + shaping.positionedLines[lineIndex].lineOffset);
259-
if (lineIndex === 0) {
260-
return previousOffset + currentLineHeight / 2.0;
261-
}
262-
const aboveLineHeight = (lineHeight + shaping.positionedLines[lineIndex - 1].lineOffset);
263-
return previousOffset + (currentLineHeight + aboveLineHeight) / 2.0;
264-
};
265266
let currentOffset = shaping.top - textOffset[1];
266267
for (let lineIndex = 0; lineIndex < lineCounts; ++lineIndex) {
267268
const line = shaping.positionedLines[lineIndex];
@@ -368,8 +369,7 @@ export function getGlyphQuads(anchor: Anchor,
368369
// tl ----- bl
369370
// After rotation, glyph lies on the horizontal midline.
370371
// Shift back to tl's original x coordinate before rotation by applying 'xOffsetCorrection'.
371-
const offsetCorrection = new Point(-yShift + halfAdvance, 0);
372-
tl._add(offsetCorrection);
372+
tl.x += -yShift + halfAdvance;
373373

374374
// Add padding for y coordinate's justification
375375
tl.y -= (metrics.left - rectBuffer) * positionedGlyph.scale;
@@ -399,9 +399,9 @@ export function getGlyphQuads(anchor: Anchor,
399399
tl.x += delta / 2;
400400
}
401401
// Calculate other three points
402-
tr = tl.add(new Point(0, -paddedWidth));
403-
bl = tl.add(new Point(paddedHeight, 0));
404-
br = tl .add(new Point(paddedHeight, -paddedWidth));
402+
tr = new Point(tl.x, tl.y - paddedWidth);
403+
bl = new Point(tl.x + paddedHeight, tl.y);
404+
br = new Point(tl.x + paddedHeight, tl.y - paddedWidth);
405405
}
406406

407407
if (textRotate) {

0 commit comments

Comments
 (0)