idunno
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2012
07:43 AM
roScreen drawText Line Break
I have a function for use with roImageCanvas that takes a sentence pulled from an xml file, cuts the length of the sentence to a certain pixel width, and prints it on the screen. I have been using the function with setlayer to print the words across two horizontal lines, since the setLayer text metadata automatically moves the rest of the sentence to the next line when printed. I am now converting my program to use roScreen instead, and I was wondering if there was a way to make the drawText function automatically go to the next line when the sentence reached a certain width, or if there is a way to force a line break in a string so that the text is spread over two lines?
4 REPLIES 4
kbenson
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2012
09:11 AM
Re: roScreen drawText Line Break
If you have to calculate the line length yourself, you may find hints and/or suitable pseudo-code here: viewtopic.php?f=34&t=35607&start=0&hilit=wrap
-- GandK Labs
Check out Reversi! in the channel store!
Check out Reversi! in the channel store!

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2012
10:02 AM
Re: roScreen drawText Line Break
For roScreen, you'll need to do the wrapping yourself. You can get the current width using the GetOneLineWidth() method of the roFont object. If you split the text into individual words, you can concatenate until GetOneLineWidth() exceeds the desired line width, then move to the next line. Using this method also gives you enough information to do right, center, and left alignment, and if you wanted to get really fancy, possibly even justification.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
idunno
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2012
09:26 AM
Re: roScreen drawText Line Break
If you split the text into individual words, you can concatenate until GetOneLineWidth() exceeds the desired line width, then move to the next line.
How do you move to the next line? Is there a command?

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2012
09:28 AM
Re: roScreen drawText Line Break
"idunno" wrote:If you split the text into individual words, you can concatenate until GetOneLineWidth() exceeds the desired line width, then move to the next line.
How do you move to the next line? Is there a command?
Use font.GetOneLineHeight() to determine how far to increase the Y value to move to the next line. You'd need to track the coordinates you're using with DrawText in your code.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)