Got OpenGLContext 3D text rendering working with numpy (Finally sit down to fix my FontTools fixes...)
Last update on .
I did some patches months and months ago to make FontTools use numpy to extract font data (outlines and metrics) from TTF font files. However, I messed something up in the patch. The system would render characters, but they seemed to be random characters and they were way too widely spaced.
Yesterday when I sat down to look a the problem I realised something neat: they were not random characters, they were the characters I was rendering but in reverse, that is, the first character was rendered last and the last first (visually). That made me suspect that it was just the metrics (rather than the glyph lookup, which I'd previously been unable to find fault with) that were messed up.
Sure enough, a bit of testing revealed that the metrics were coming out saying that the characters should have a large-ish negative advance, rather than a somewhat smaller positive one.
More poking and what do you know, I'd messed up by thinking there were only Numeric arrays (I never really read the code, you see, I just ran through replacing code that looked to be dealing with arrays). Turns out there were also array.array arrays that have a different behaviour for their "byteswap" method than the numpy arrays (in-place versus new-object). I'd changed all of those calls as I was changing the Numeric ones and wound up messing up the logic to not byteswap in certain cases.
Anyway, the end result is that the new patch to FontTools lets me render TTF fonts in OpenGLContext with only numpy installed (i.e. that removes the last Numeric module dependency for OpenGLContext).
Pingbacks are closed.
Comments are closed.