
-----------------------------------
whaleye
Sat Dec 15, 2012 2:58 pm

How to use Font.Draw to draw a string longer than the width such that it will go to the next line
-----------------------------------
What is it you are trying to achieve?
I am trying to make a string draw onto the screen and if the string is too long it will go and do it on a lower line


What is the problem you are having?
I can't figure out how to do this with Font.Draw, the string will always just go off the edge of the screen instead of text wrapping


Describe what you have tried to solve this problem
I tried implementing something with the Font.Width function but couldn't figure out how to use it to solve the problem.



Please specify what version of Turing you are using

4.1

-----------------------------------
Insectoid
Sat Dec 15, 2012 3:18 pm

RE:How to use Font.Draw to draw a string longer than the width such that it will go to the next line
-----------------------------------
To wrap a string, you need to figure out how many characters you can fit on the screen, and any extra characters have to be drawn in a new line, with a new Font.Draw command. You can use Font.Width() to get the width of the string, and if it's too big, remove letters or words from the string until it fits. When you have to write the 2nd line, do the whole process again (otherwise, if the 2nd line is also too big, it won't wrap).

-----------------------------------
whaleye
Sat Dec 15, 2012 3:39 pm

Re: How to use Font.Draw to draw a string longer than the width such that it will go to the next line
-----------------------------------
So I do:
if Font.Width(string)>maxx


Where do I go from there?
How do I split the string and know where to split it?

-----------------------------------
Insectoid
Sat Dec 15, 2012 3:46 pm

RE:How to use Font.Draw to draw a string longer than the width such that it will go to the next line
-----------------------------------
You don't know where to split it. You have to try removing one letter or word at a time, depending on how you want it to wrap.

-----------------------------------
Panphobia
Sat Dec 15, 2012 3:47 pm

RE:How to use Font.Draw to draw a string longer than the width such that it will go to the next line
-----------------------------------
you basically wrote your code yourself, then make a substring of the old string length - maxx to old string length, and make it on the next line, keep doing that until there are no more characters or the length is 