Skip to content

Commit c961d41

Browse files
committed
more tweaks for font width
1 parent ffc5138 commit c961d41

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

fontconverter.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,13 @@ FontGlyph.prototype.appendBits = function(bits, info) {
214214
} else {
215215
xStart = this.fmWidth;
216216
xEnd = 0;
217-
for (var x=0;x<this.fmWidth;x++) {
218-
for (var y=0;y<this.fmHeight;y++) {
217+
for (var y=0;y<this.fmHeight;y++) {
218+
for (var x=0;x<this.fmWidth;x++) {
219219
var set = glyph.getPixel(x,y);
220220
if (set) {
221221
// check X max value
222222
if (x<xStart) xStart = x;
223-
xEnd = x;
223+
if (x>xEnd) xEnd = x;
224224
// check Y max/min
225225
if (y<yStart) yStart = y;
226226
if (y>yEnd) yEnd = y;
@@ -236,9 +236,8 @@ FontGlyph.prototype.appendBits = function(bits, info) {
236236
glyph.width = xEnd+1-xStart;
237237
glyph.xStart = xStart;
238238
glyph.xEnd = xEnd;
239-
glyph.advance = glyph.width;
240-
if (xEnd<this.fmWidth-1)
241-
glyph.advance += this.glyphPadX; // if not full width, add a space after
239+
glyph.advance = glyph.xEnd+1;
240+
glyph.advance += this.glyphPadX; // if not full width, add a space after
242241
if (!this.glyphPadX) glyph.advance++; // hack - add once space of padding
243242

244243
if (this.fullHeight) {
@@ -253,6 +252,12 @@ FontGlyph.prototype.appendBits = function(bits, info) {
253252
glyph.yEnd = yEnd;
254253
glyph.height = yEnd+1-yStart;
255254

255+
/* if (ch == 41) {
256+
glyph.debug();
257+
console.log(glyph);
258+
process.exit(1);
259+
}*/
260+
256261
return glyph;
257262
};
258263

0 commit comments

Comments
 (0)