Skip to content

Commit

Permalink
Fix baseline alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
frank-weindel committed Apr 15, 2024
1 parent 5a2495a commit 08ecffb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function generateBMFont (fontPath, opt, callback) {
}); // Remove duplicate & control chars

const os2 = font.tables.os2;
const baseline = os2.sTypoAscender * (fontSize / font.unitsPerEm) + (distanceRange >> 1);
const baseline = os2.sTypoAscender * (fontSize / font.unitsPerEm);

const fontface = typeof fontPath === 'string' ? path.basename(fontPath, path.extname(fontPath)) : filename;

Expand Down Expand Up @@ -380,8 +380,8 @@ function generateImage (opt, callback) {
char: String(char),
width: width,
height: height,
xoffset: Math.round(bBox.x1) - pad,
yoffset: Math.round(bBox.y1) + pad + baseline,
xoffset: bBox.x1 - pad,
yoffset: bBox.y1 - pad + baseline,
xadvance: glyph.advanceWidth * scale,
chnl: 15
}
Expand Down

0 comments on commit 08ecffb

Please sign in to comment.