Re: [AD] ALLEGRO_ALIGN_CENTRE and integer alignment

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Sun, 04 Nov 2012 00:50:20 -0400, SiegeLord <slabode@xxxxxxxxxx> wrote:
> On 04/11/12 00:07, Peter Wang wrote:
> > Hi,
> >
> > How should ALLEGRO_ALIGN_CENTRE behave now that we don't try to align
> > text drawing to integral offsets?  The user may pass in (x,y) which are
> > both integer-aligned, but because the text length is an odd value
> > (x - text_length*0.5) is no longer integer aligned.
> > You can see the effect in ex_audio_chain (the "Mixer" label).
> >
> > One solution is use an integer division, so that
> > (x - text_length/2) remains integral if x was integral.
> >
> > Any problem with that?
> >
> > Peter
> As far as I can tell the original motivation for disabling integer 
> alignment was that:
> - It produced jittering when the text was moved by fractional amounts
> - It was very difficult to work around
> Doing integer divide (I'd probably do proper rounding instead of 
> truncation though)

The text length is either an odd or even integer so I'm not sure where
the rounding fits?

> for the text width is neither of those, there'll be 
> no jittering due to movement and it's trivial to work around if need be.
> 
> Now the real doozy is al_draw_justified_text, I'm not too sure how that 
> function should work.

Good point.  al_draw_justified_text doesn't respect the lack of
ALLEGRO_ALIGN_INTEGER yet.  I think it should behave as if you had
calculated the spacing and drawn the words separately, passing
ALLEGRO_ALIGN_INTEGER.

Peter




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/