From 74f868524ebf1764a3179a117b836a93f77a89a7 Mon Sep 17 00:00:00 2001 From: Leo Bergman Date: Mon, 2 Sep 2019 14:29:43 +0200 Subject: [PATCH] Use hhea instead of os2 to calc lineHeight --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 4a0e784..5df2630 100644 --- a/index.js +++ b/index.js @@ -130,6 +130,7 @@ function generateBMFont (fontPath, opt, callback) { }); // Remove duplicate & control chars const os2 = font.tables.os2; + const hhea = font.tables.hhea; const baseline = os2.sTypoAscender * (fontSize / font.unitsPerEm) + (distanceRange >> 1); const fontface = path.basename(fontPath, path.extname(fontPath)); if(!filename) { @@ -257,7 +258,7 @@ function generateBMFont (fontPath, opt, callback) { spacing: fontSpacing }, common: { - lineHeight: (os2.sTypoAscender - os2.sTypoDescender + os2.sTypoLineGap) * (fontSize / font.unitsPerEm), + lineHeight: (hhea.ascender - hhea.descender + hhea.lineGap) * (fontSize / font.unitsPerEm), base: baseline, scaleW: packer.bins[0].width, scaleH: packer.bins[0].height,