Re: [AD] Proposal: Wordwrapped justified text drawing

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


On Mon, Dec 20, 2010 at 4:57 PM, Sebastian Steinhauer <s.steinhauer@xxxxxxxxxx> wrote:

Hi there!

I just started out to use Allegro 5 for my little game project. Since I need a
lot of text output, I was happy to see a function like al_draw_justified_ustr
and used it. But i was very unhappy with the results. This function actually
only justifies to one line, ignores any newline character and does no word wrap.

Hm, yes. al_draw_justified_text is a bit low level - basically you can't use it without having a way to obtain the lines. And since we provide al_draw_justified text, might as well make it easier to obtain those lines.  
 

So I began to hack my own little function doing word wrap on the given
ALLEGRO_USTR and uses the al_draw_justified_ustr function to render the text.
I'll send you my piece of code (including some demo) and perhaps you guys can
include it into the font addon. At the moment there are still some issues with
my code.
1) it could be faster, because I'll split the string already into words and
calling al_draw_justified_ustr does the same again
2) there's only a ALLEGRO_USTR function
3) a new ALLEGRO_USTR is allocated every call to buffer the lines (malloc
pressure if it's used often for texts...)

Only looked at the prototype. What is "hdiff" and "vdiff"?


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