justified text align?
Monkey Forums/Monkey Programming/justified text align?
| ||
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 |
| ||
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 |
| ||
Yes that's what I meant. Well more work for my coder then ^_^ thanks |
| ||
angel font or fontmachine are better frameworks than the default built-in one to draw text. |
| ||
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... |
| ||
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. |
| ||
yes they do, angle font can align left, right or center or is that not what you mean by justified ? |
| ||
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). |
| ||
ah.. my bad. |
| ||
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. |
| ||
Sounds like a challenge and a great enhancement for FontMachine, eh Ziggy? ;) |
| ||
I know about angel font, but what is FontMachine ? edit: Nevermind followed Ziggy signature link and found it :) |
| ||
@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 |
| ||
So, the challenge is accepted? ;) hehe |
| ||
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? |