On Tue, Jan 29, 2008 at 04:17:44PM +0100, Denis Oliver Kropp wrote: > Sven Luther wrote: > > On Mon, Jan 28, 2008 at 02:27:40PM +0000, Andre DRASZIK wrote: > >> Hi, > >> > >> it's not hard to implement everything you want using > >> IDirectFBFont::GetStringWidth() and then draw one line at a time. > >> Justification can be done using DSTF_TOPLEFT et al. > >> Why do you think you can't implement this on top of DirectFB? > > > > It would seem to me that it is suboptimal to implement it on top, > > because you don't know in advance the size of the text. > > > > So, basically, you would make a guess, see if getstringwidth is bigger > > or smaller than the desired width, and then use dichotomy to reach that > > size. > > You don't know GetStringBreak() :) > > http://www.directfb.org/docs/DirectFB_Reference_1_1/IDirectFBFont_GetStringBreak.html > > It seems ideal to me, though I had some more ideas, but I'm not remembering > them at the moment.
He, neat. This doesn't solve string justification though. > > While doing it internally, you could add the chars one by one, until the > > size is reached, and even have code for adding justification and stuff > > like that. > > Argh, adding the chars one by one would be even worse than using > GetGlyphExtents() for > each character (once). Well, i suppose that the GetSting* thingies do calcluation on the char width only. > > You could also have another mode to crop the text after a certain width, > > altough it is probably possible to do that by cropping surfaces while > > blitting. > > Just use SetClip(). :) > >> For more advanced text rendering you should consider using pango. > > > > How big a dependency set does pango pull in ? Is this an option for > > small-storage applications ? > > I don't know, but I hope that the string will be prepared as a DFBRectangle > and DFBPoint array and drawn using BatchBlit(). That's quite near to the > integrated DrawString(). > > I think pango via cairo uses BatchBlit() for glyphs... > > If the arrays are stored to render the excact string later again, you might > be even faster than DrawString() :) > > >> You should also remember that the length in bytes may legally be != > >> length in characters, since this is UTF-8 encoded text. > > > > Exact, so one more reason to do it internally, since directfb > > getstringwidth knows about the size of the text as it will be ? > > Yeah, or GetStringBreak(). > > -- > Best regards, > Denis Oliver Kropp > > .------------------------------------------. > | DirectFB - Hardware accelerated graphics | > | http://www.directfb.org/ | > "------------------------------------------" > > _______________________________________________ > directfb-dev mailing list > directfb-dev@directfb.org > http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev _______________________________________________ directfb-dev mailing list directfb-dev@directfb.org http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev