diff --git a/index.js b/index.js index 5e512c9..f72b8bb 100644 --- a/index.js +++ b/index.js @@ -51,7 +51,7 @@ export default class TinySDF { // The integer/pixel part of the top alignment is encoded in metrics.glyphTop // The remainder is implicitly encoded in the rasterization - const glyphTop = Math.floor(actualBoundingBoxAscent); + const glyphTop = Math.ceil(actualBoundingBoxAscent); const glyphLeft = 0; // If the glyph overflows the canvas size, it will be clipped at the bottom/right @@ -68,7 +68,7 @@ export default class TinySDF { const {ctx, buffer, gridInner, gridOuter} = this; ctx.clearRect(buffer, buffer, glyphWidth, glyphHeight); - ctx.fillText(char, buffer, buffer + glyphTop + 1); + ctx.fillText(char, buffer, buffer + glyphTop); const imgData = ctx.getImageData(buffer, buffer, glyphWidth, glyphHeight); // Initialize grids outside the glyph range to alpha 0 diff --git a/test/fixtures/1-out.json b/test/fixtures/1-out.json index c2fcc48..97c1b3b 100644 --- a/test/fixtures/1-out.json +++ b/test/fixtures/1-out.json @@ -3,7 +3,7 @@ "height": 51, "glyphWidth": 48, "glyphHeight": 45, - "glyphTop": 39, + "glyphTop": 40, "glyphLeft": 0, "glyphAdvance": 48 } \ No newline at end of file