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 <[email protected]> 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 <[email protected]> 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 <[email protected]>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 [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> 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 [email protected].
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>
>>
>> --
>> Romain Guy
>> Android framework engineer
>> [email protected]
>>
>> --
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> 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 [email protected].
>> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> 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 [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Romain Guy
Android framework engineer
[email protected]

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to