[swfmill] ceil(int) in swft_import_ttf.cpp?

Icey Shard iceyshard at gmail.com
Tue Jul 15 09:35:49 PDT 2008


Greetings list!

I just managed to compile the program (swfmill-0.2.12.6) with MinGW under
Windows. I'm quite thrilled because it's my first time with a project this
big, so if my worry is about something harmless or unimportant, please blame
it on my temporary exhilaration.

Anyways, I noticed a suspicious bit of code in the swft_import_ttf.cpp
file-there are a couple of lines of code like this:
kern->setadjustment( (short)(floor(vec.x >> 6)) );
and this:
adv->setvalue( (short)(ceil(1+(face->glyph->advance.x >> 6))) );

Of course, I wouldn't notice it myself, but my compiler announced a warning
or an error, forcing me to look. And I looked, and I'm perplexed.
So vec.x is an integer, that is subjected to binary shift right.
The result will also be an integer, so what's the point of taking a ceil of
it? And why would one piece of code use floor and another use ceil, for
something that looks vaguely similar.

For now, I've just removed calls to ceil and floor, and as far as I can
tell, the code should have the same result.
But I can't help but think there might be something more to it... perhaps
the code for the later line was meant to be
ceil(1+((float)(face->glyph->advance.x) / 64))
Which would give a different result if .x is positive and not divisible by
64.
This could possibly cause slight differences in kerning and font alignement.

I can hardly tell left from right now, but I thought I'd bring it up so
someone more knowledgeable may check it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/swfmill_osflash.org/attachments/20080715/a97b3025/attachment.html 


More information about the swfmill mailing list