justified text align?

Monkey Forums/Monkey Programming/justified text align?

Winter Wolves(Posted 2012) [#1]
Was wondering if anyone implemented justified text alignment? It would be useful in games that make use of texts paragraph, I thought that function was built-in but it doesn't seem so.
For those who don't know what I'm talking about:
http://en.wikipedia.org/wiki/Justification_%28typesetting%29


therevills(Posted 2012) [#2]
The built in parameters for DrawText does do text alignment:
[monkeycode]DrawText:Void( text:String, x:Float, y:Float, xalign:Float=0.0, yalign:Float=0.0 )[/monkeycode]
Examples:
[monkeycode]DrawText("Top-Left Align", 10, 10, 0, 0)
DrawText("Top-Right Align", 10, 10, 1, 0)
DrawText("Bottom-Left Align", 10, 10, 0, 1)
DrawText("Bottom-Right Align", 10, 10, 1, 1)
DrawText("Center Align", 10, 10, 0.5, 0.5)[/monkeycode]

But it doesn't do Justified alignment, you wound have to write your own... You need to adjust the whitespace between the words... Good Luck ;)

http://www.rose-hulman.edu/class/csse/csse220/200830/web/Programs/Markov/justification.html


Winter Wolves(Posted 2012) [#3]
Yes that's what I meant. Well more work for my coder then ^_^ thanks


ziggy(Posted 2012) [#4]
angel font or fontmachine are better frameworks than the default built-in one to draw text.


therevills(Posted 2012) [#5]
angel font or fontmachine are better frameworks than the default built-in one to draw text.


True, but they both still dont do justified text...


Gerry Quinn(Posted 2012) [#6]
It wouldn't be that difficult to add to AngelFont or FontMachine if you want to code it. Just get the next line as a string, calculate the excess space, and offset each letter by the appropriate fraction.

Probably not as good as a sophisticated typesetting program would do, but adequate for most games.


Paul - Taiphoz(Posted 2012) [#7]
yes they do, angle font can align left, right or center or is that not what you mean by justified ?


Gerry Quinn(Posted 2012) [#8]
He's talking about combined left and right justification, with the text stretched out so it touches both left and right margins on every line (except the end of paragraphs I suppose).


Paul - Taiphoz(Posted 2012) [#9]
ah.. my bad.


Winter Wolves(Posted 2012) [#10]
Yes exactly as Gerry posted. I don't think is so trivial to make to be honest! Not impossible of course, but not so easy.


therevills(Posted 2012) [#11]
Sounds like a challenge and a great enhancement for FontMachine, eh Ziggy? ;)


Winter Wolves(Posted 2012) [#12]
I know about angel font, but what is FontMachine ?
edit: Nevermind followed Ziggy signature link and found it :)


ziggy(Posted 2012) [#13]
@therevills: Of course! It could be done easily. remember it's open source so if anyone adds this Ill gapilly add it to the official distro


Winter Wolves(Posted 2012) [#14]
So, the challenge is accepted? ;) hehe


Paul - Taiphoz(Posted 2012) [#15]
I'm still using Angle Font cos I started my current project with it, before getting Font Machine, but next project will be made with it, so yeah go for it therevills :)

PS.. do you like revills?