And if you ever need a fancier font rendering system you can take a look at FontRenderer.cpp (and the associated classes in the font/ directory) here: https://github.com/android/platform_frameworks_base/blob/master/libs/hwui/FontRenderer.cpp
It's the font renderer used by the UI toolkit when running on top of OpenGL. It's all dynamic and doesn't need to generate a separate texture per string. On Mon, May 20, 2013 at 9:10 AM, Latimerius <l4t1m3r...@gmail.com> wrote: > Thanks for using your sixth sense to find out what exactly I was > struggling with. ;-) Now everything works what I need for the initial > batch of tests! > > Come to think about it, one of the collateral benefits of using TextView > for the job seems to be the consistency with the rest of the platform. I > mean, if TextView can render it well, so can our app. If TextView fails to > render it correctly in some way, our app fails in the same way so the > result should at least follow the principle of least surprise. > > Again, thanks a *lot* for your help Romain! > > > On Mon, May 20, 2013 at 2:13 AM, Romain Guy <romain...@android.com> wrote: > >> It's pretty easy. If you want the text to break, use the MeasureSpec >> AT_MOST X px for the width (where X is the maximum width in pixels you want >> your texture to be) and UNSPECIFIED 0 px for the height. >> >> >> On Sun, May 19, 2013 at 3:39 PM, Latimerius <l4t1m3r...@gmail.com> wrote: >> >>> Thanks a lot Romain. I hoped there would be a way to >>> leverage somehow the standard View machinery. I couldn't find it as >>> admittedly, I'm not very experienced with the standard UI toolkit. >>> >>> >>> On Sun, May 19, 2013 at 9:27 PM, Romain Guy <romain...@android.com>wrote: >>> >>>> One way to do this is to create a TextView, call measure() then >>>> layout() on it and then call its draw() method to draw into a Bitmap. This >>>> will take care of all the breaking, BiDi, etc. Note that TextView uses the >>>> Paint APIs under the hood to measure text. >>>> >>>> >>>> On Sun, May 19, 2013 at 10:55 AM, Latimerius <l4t1m3r...@gmail.com>wrote: >>>> >>>>> Hello, >>>>> >>>>> I'm looking into localising an OpenGL app into several languages. I'm >>>>> not too worried about short strings like button labels, however the >>>>> welcome >>>>> screen contains a paragraph or two of text and the tutorial has a couple >>>>> of >>>>> 2-3 lines text strings. Currently, they are pre-rendered and distributed >>>>> as PNGs but ideally, they should be rendered on-the-fly to save texture >>>>> space and avoid scaled text. >>>>> >>>>> To achieve that, it seems necessary to handle line breaking properly. >>>>> However, I couldn't find an API in Android to help with that. I'm aware >>>>> of Paint.breakText() but it seems too primitive for the task - it actually >>>>> doesn't seem to handle proper line breaking at all. For Western >>>>> languages, >>>>> it should be mostly fine just to back off to the first space from what >>>>> breakText() returns and break the line there. The problem is how to deal >>>>> with Asian languages (Chinese, Japanese and Korean - also Thai would be >>>>> nice), and later on with RTL languages, too. >>>>> >>>>> Some googling gave me the impression that in general, people like me >>>>> shouldn't try to tackle the problem themselves - it's too complex and >>>>> belongs into an operating system/application framework anyway. >>>>> >>>>> Is there something in Android platform to help turn a paragraph of >>>>> text into a decent PNG of specified dimensions? >>>>> >>>>> Thanks in advance! >>>>> >>>>> -- >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Android Developers" group. >>>>> To post to this group, send email to >>>>> android-developers@googlegroups.com >>>>> To unsubscribe from this group, send email to >>>>> android-developers+unsubscr...@googlegroups.com >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/android-developers?hl=en >>>>> --- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Android Developers" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to android-developers+unsubscr...@googlegroups.com. >>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>> >>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> Romain Guy >>>> Android framework engineer >>>> romain...@android.com >>>> >>>> -- >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Android Developers" group. >>>> To post to this group, send email to >>>> android-developers@googlegroups.com >>>> To unsubscribe from this group, send email to >>>> android-developers+unsubscr...@googlegroups.com >>>> For more options, visit this group at >>>> http://groups.google.com/group/android-developers?hl=en >>>> --- >>>> You received this message because you are subscribed to the Google >>>> Groups "Android Developers" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to android-developers+unsubscr...@googlegroups.com. >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>>> >>>> >>> >>> -- >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Android Developers" group. >>> To post to this group, send email to android-developers@googlegroups.com >>> To unsubscribe from this group, send email to >>> android-developers+unsubscr...@googlegroups.com >>> For more options, visit this group at >>> http://groups.google.com/group/android-developers?hl=en >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "Android Developers" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to android-developers+unsubscr...@googlegroups.com. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> >> >> -- >> Romain Guy >> Android framework engineer >> romain...@android.com >> >> -- >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to android-developers@googlegroups.com >> To unsubscribe from this group, send email to >> android-developers+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> --- >> You received this message because you are subscribed to the Google Groups >> "Android Developers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to android-developers+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Android Developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to android-developers+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- Romain Guy Android framework engineer romain...@android.com -- -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.