From 8b43badd98bf293cd5a4ad41aa76b6cdb9157d80 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 2 May 2024 12:03:57 +0100 Subject: [PATCH] updated font tools to adjust char widths --- bin/font_creator.js | 35 ++++++++++++++++++++++++++++++----- webtools | 2 +- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/bin/font_creator.js b/bin/font_creator.js index c6781aa49..352c7ea24 100755 --- a/bin/font_creator.js +++ b/bin/font_creator.js @@ -41,10 +41,35 @@ let font = fontconverter.load({ height : 16, // actual used height of font map range : charCodeRanges[charCodeRange].range }); +/*let font = fontconverter.load({ + fn : "fontname.bdf", +});*/ font.removeUnifontPlaceholders(); // quick hack as space looks too long -font.glyphs[32].width -= 3; -font.glyphs[32].xEnd -= 3; -font.glyphs[32].advance -= 3; -//font.debugChars(); -require("fs").writeFileSync(outputFile, Buffer.from(font.getPBF())); \ No newline at end of file +font.glyphs[32].width -= 4; +font.glyphs[32].xEnd -= 4; +font.glyphs[32].advance -= 4; + +/* Another hack - because these are centered in the image +they often don't start at the beginning of the char space. +Move them all back and add 1px at the end */ +font.glyphs.forEach(g => { + if (g.xStart>0) { + var shift = g.xStart; + g.xStart -= shift; + g.xEnd -= shift; + g.advance = g.xEnd+2; + g.oldGetPixel = g.getPixel; + g.getPixel = (x,y) => g.oldGetPixel(x+shift,y); + //g.debug(); + //console.log(g); + console.log(); + } +}); + +/*var g = font.glyphs[":".charCodeAt()]; +g.debug(); +console.log(g);*/ +font.debugChars(); +require("fs").writeFileSync(outputFile, Buffer.from(font.getPBF())); +//console.log(font.getJS()); diff --git a/webtools b/webtools index 386937b02..c961d41aa 160000 --- a/webtools +++ b/webtools @@ -1 +1 @@ -Subproject commit 386937b02505d22fef11c3d14ea3a7630645cb9b +Subproject commit c961d41aab34a072a5db744c1215cb851da5c4cc