Display paragraph

BlitzMax Forums/BlitzMax Beginners Area/Display paragraph

hub(Posted 2010) [#1]
Hi !
i'm searching an idea to oode a function to display a text paragraph. Something very basic using drawtext, setimagefont.

Function DrawParagraph (Text$, posX, PosY, pWidth)

Width is the paragraph width in pixels. PosX, PosY the text location.

(note that i need to save the paragraph inside a single string variable as i save it later into a file using a writeline hFile, Text$ command.)

What the best method for the function ?

My idea
- Put words inside an array from the string text$
- calculate textwidth for each word + one space. Cumulate the width (w) and go to the next line when w > pWidth then drawtext and PosY = PosY + 15 and w=0 for the next line ?

(sorry i've not bmax on this computer, i'm not at home !)

Thanks for your help !

Last edited 2010


Jesse(Posted 2010) [#2]
There is a recent example in the code archives:
http://www.blitzmax.com/codearcs/codearcs.php?code=2776#comments


hub(Posted 2010) [#3]
This is blitzbasic code but easy to convert. Thanks to point this (i've used the .bmx filter on my last code archive search).


hub(Posted 2010) [#4]
seems to work now.


Last edited 2010


Jesse(Posted 2010) [#5]
That code doesn't work as is. I think you left some code that was there before the edit. anyway I had a go at it and made a one to one port:



hub(Posted 2010) [#6]
More basic.



Jesse(Posted 2010) [#7]
usable!

Do you, or anybody know how to change image font in a mac? I mean find the font and set it.

never mind figured it out:

/library/fonts/fontname



Last edited 2010