Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Fully justified text

Author
Message
JohnStabler
AGK Bronze Backer
11
Years of Service
User Offline
Joined: 16th Aug 2013
Location: Cardiff, Wales, UK
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!
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 10th Jul 2021 21:42 Edited at: 10th Jul 2021 21:43
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)?
[My Itch.io Home] [Community Apps on Itch.io]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 10th Jul 2021 23:11 Edited at: 10th Jul 2021 23:33
Quote: "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.

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
n00bstar
20
Years of Service
User Offline
Joined: 9th Feb 2004
Location: Montreal, Canada.
Posted: 11th Jul 2021 09: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

-----------------------------------------------------------------------------
We all got a chicken duck woman thing waiting for us
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 11th Jul 2021 17:08
Quote: "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!

n00bstar
20
Years of Service
User Offline
Joined: 9th Feb 2004
Location: Montreal, Canada.
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.
-----------------------------------------------------------------------------
We all got a chicken duck woman thing waiting for us
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 11th Jul 2021 20:52 Edited at: 11th Jul 2021 21:08
i did start working on a parser to add spaces:


i avoided use of SetTextCharPosition since:
Help File wrote: "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?
[My Itch.io Home] [Community Apps on Itch.io]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]

Attachments

Login to view attachments
JohnStabler
AGK Bronze Backer
11
Years of Service
User Offline
Joined: 16th Aug 2013
Location: Cardiff, Wales, UK
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.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
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 ??
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 12th Jul 2021 16:55
Quote: " Does the Edit box support this?"

i see no alignment options in that command set
[My Itch.io Home] [Community Apps on Itch.io]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
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.

Login to post a reply

Server time is: 2024-11-23 12:42:35
Your offset time is: 2024-11-23 12:42:35