freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ft] Off by one error in freetype (or in programmer?)


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

So, I may be about to embarrass myself, because fencepost errors are like that, but here goes.

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?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]