|
From: | Simon Cozens |
Subject: | [ft] Off by one error in freetype (or in programmer?) |
Date: | Thu, 5 Apr 2018 19:14:10 +1000 |
User-agent: | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.0 |
If I look at the glyph /H in Source Sans Pro in a font editor, the top right bound is a point at (562,656) and the bottom left point is at (90,0). If I were to think about this as a bitmap, I can address row 0 and row 656, so there are 657 addressable rows.
But when I render it to a bitmap in freetype, I get bitmap.rows == 656, bitmap.width == 472 (562 minus the LSB of 90 is 472).
I seem to have lost a row somewhere - I can only address from rows 0 to 655. For example, this bitmap is an array with bitmap.rows * bitmap.width = 309632 elements. If I wanted to address the top right point, I would set:
y = 656 x = 472 and then address: bitmap[ y * bitmap.width + x ] bitmap[ 310104 ] and oops, I'm off the end of the array. Is this a problem with freetype, or in my assumptions?
[Prev in Thread] | Current Thread | [Next in Thread] |