littlejsengine 1.18.25 → 1.18.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/engineDraw.js CHANGED
@@ -1463,9 +1463,15 @@ class ImageFont
1463
1463
  tileInfo.pos.x = x*sizePaddedX + padding;
1464
1464
  tileInfo.pos.y = y*sizePaddedY + padding;
1465
1465
 
1466
- // draw the tile
1467
- drawPos.x = pos.x + i * size.x - centerOffset |0;
1468
- drawPos.y = pos.y + j * size.y |0;
1466
+ // snap the glyph edges to whole pixels
1467
+ // tiles are drawn from their center, so snapping the center
1468
+ // to a whole pixel puts the edges on half pixels when the
1469
+ // size is even, and a row or column of the glyph then has
1470
+ // no pixel center inside it and is not rasterized at all
1471
+ // ceil picks the nearest aligned position, breaking ties
1472
+ // downward to match how this used to truncate
1473
+ drawPos.x = ceil(pos.x + i * size.x - centerOffset - size.x/2) + size.x/2 - .5;
1474
+ drawPos.y = ceil(pos.y + j * size.y - size.y/2) + size.y/2 - .5;
1469
1475
  drawTile(drawPos, size, tileInfo, color, 0, false, undefined, useWebGL, true, context);
1470
1476
  }
1471
1477
  });