Skip to content

Commit a365abe

Browse files
authored
Fixes bug in bounds detection
Fixes bug in bounds detection where offset to edge of leftmost glyph was not being deducted from width
1 parent 3fff3f6 commit a365abe

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/typography/p5.Font.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,11 @@ p5.Font.prototype.textBounds = function(str, x, y, fontSize, options) {
121121
this.font.forEachGlyph(str, x, y, fontSize, options,
122122
function(glyph, gX, gY, gFontSize) {
123123

124-
xCoords.push(gX);
125-
yCoords.push(gY);
126-
127124
var gm = glyph.getMetrics();
128125

129126
if (glyph.name !== 'space' && glyph.unicode !== 32) {
130127

128+
xCoords.push(gX + (gm.xMin * scale));
131129
xCoords.push(gX + (gm.xMax * scale));
132130
yCoords.push(gY + (-gm.yMin * scale));
133131
yCoords.push(gY + (-gm.yMax * scale));

0 commit comments

Comments
 (0)