Posted: 10th Jul 2021 21:20
I'm not sure if I posted this before as either a new thread or on the feature request thread. But yet again I'm working on a project that displays text and it frustrates me that I can only align left, centre and right.

Please, please, please AppGameKit devs, can you implement fully justified text?

Thanks!
Posted: 10th Jul 2021 21:42
ideally, suggestions are posted as an issue on the github but can you explain "fully justified text"?

do you want paragraph indentation and/or something else/more? are you open to work-arounds such as "markup" functionality (if you haven't already written your own and are seeking built-in handling)?
Posted: 10th Jul 2021 23:11
Please, please, please AppGameKit devs, can you implement fully justified text?

I am confused on the 'implement fully justified text' request too.

we have a ton of commands for text

What is it exactly that is giving you trouble? The alignment?

Can't you position the text using the X and Y coordinates to place it anywhere you want on the screen?

if you want specific columns for the text, then couldn't you just assign variables for the X coordinates of the column(s), and increment the Y coordinates based on the font size?

The width of the columns would require a little math on counting characters if your font sizes change (or oddball spaced fonts), but it seems it would be doable with the commands we already have.

You would also have to break long strings up to manage that width control as well, which adds a little bit of complexity, but if the text is predetermined then you wouldn't have to construct the text strings' lengths based on input, but even that shouldn't be too much trouble once you have determined how many characters each line should contain for said column width.

I have not had the need for this yet, but maybe an array for the columns' lines would be a simple way to organize the text strings whether predetermined or based on user input, where each element represents a line of text.

Then all you would have to do after constructing the text array is to do the math for the X and Y position of each element in a nested for loop that does the increments for the position of each line.

It would be nice to have something like that built in, but coding it to your own preferences really gives you better control for various display situations depending on your build.
Posted: 11th Jul 2021 9:57
Text justification is basically adjusting the space between each character so that your line of text takes the full width available. Makes for a generally more pleasing reading experience and looks more professional.

It's possible to achieve this in code, but it's gonna make a mess of text objects as you're going to have to break them up into smaller chunks. I would recommend going by line, using center alignment, then adjusting the spacing on each. If your app is text-heavy, you are going to hate managing that many text object pretty soon
Posted: 11th Jul 2021 17:08
you're going to have to break them up into smaller chunks


Maybe not, it is possible to achieve this in a single text object using SetTextCharPosition in a post-processing function, loop the string and build a word list array (type) and some heavy math on the result to calculate the word spacing for each line then reformat the string on a char by char basis ... a bit of work yea but it would make a handy reusable function.

To much for my brain on a Sunday though!
Posted: 11th Jul 2021 20:42
Oh, didn't know about that command. Then yeah, totally possible to code a justifying function. It would mean a fair bit of boilerplate code to make it "universal" no matter what font is loaded, but definitely possible.
Posted: 11th Jul 2021 20:52
i did start working on a parser to add spaces:


i avoided use of SetTextCharPosition since:
If any of the following commands are called the position of all characters will be reset to a straight line: SetTextPosition, SetTextX, SetTextY, SetTextSize, SetTextSpacing, SetTextAlignment.

but, since i'm currently adding spaces between words (actually, TO words) and those space widths are relative to text size, i might have to to be more precise.

ie, using text size of 24, a space is 5px wide with the default font.

btw, the # on the right SHOULD be the number of spaces inserted throughout each line. its a draft so not sure anything is really working ATM

otherwise, to do this right, does the width need to be PERFECT or is 4px off, for example, normally acceptable?
Posted: 12th Jul 2021 13:43
Sorry, have been away so didn't get to reply quickly.

Yes, justified text as in "text is aligned along the left margin, with letter-spacing and word-spacing adjusted so that the text falls flush with both margins, also known as fully justified or full justification"

While I'm sure I could write a lot of code to do this manually, the request is for support in-engine, for performance reasons. Plus, it's a pretty common feature in applications so I don't think it's a big ask. I'll post it on GitHub.
Posted: 12th Jul 2021 16:22
A common feature for text editor apps, Does the Edit box support this?

Maybe set it read only and use SetEditBoxMultiLine with SetEditBoxWrapMode ??
Posted: 12th Jul 2021 16:55
Does the Edit box support this?

i see no alignment options in that command set
Posted: 13th Jul 2021 16:47
Its a Windows edit control right? or GTX?, with either the functionally is there it just needs to be exposed
.

or Did TGC code a custom edit box ..., I'll look at the source later and see if I can hack the edit box, I only need a window hwnd.