On Tue, 2009-07-21 at 18:43 +0100, Chris Young wrote:
> On Tue, 21 Jul 2009 16:55:35 -0000,  wrote:
> 
> > - OT_PointHeight,(ysize<<16),
> > + OT_PointHeight,(ysize<<16)/FONT_SIZE_SCALE,
> 
> Should this not be (ysize/FONT_SIZE_SCALE)<<16?
> I'm trying to work out whether doing the division before or after the
> shift makes a difference, but I'm struggling.

Doing it before the shift loses precision.

By performing the division first, you've effectively got:

floor(ysize/FONT_SIZE_SCALE)<<16

As written, it does:

floor((ysize<<16)/FONT_SIZE_SCALE)

That said, as it's currently written, font sizes larger than 64pt will
overflow. Therefore, it may well be better to express it as:

ysize * ((1<<16) / FONT_SIZE_SCALE)

which, assuming my maths are correct, will produce the same result
without the potential for overflow (unless font sizes are huge, of
course).


J.


Reply via email to