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 / Is there a way to turn off text line wrapping?

Author
Message
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 15th Jun 2017 08:23 Edited at: 15th Jun 2017 08:23
I've had a search through the commands and I can't find anything but as is often the case with AppGameKit there may well be a hidden, undocumented parameter that performs the function I need.
I need to use SetTextMaxWidth() to keep the text width constrained but a can't use SetTextScissor() to trim it because the text object is already scissored to a larger area.
So as things are now, many of my text objects span over two (or more lines) but I would prefer them to be trimmed to fit by SetTextMaxWidth() and not wrap onto the next line.

Any suggestions?
AGK V2 user - Tier 1 (mostly)
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 15th Jun 2017 09:49
without SetTextMaxWidth you can insert line breaks chr(10) by our own?
alternate you can use drawsprite in a simple text paint function where you set for each char the sprite image from a font atlas image.


AGK (Steam) V2017.05.15 : Windows 10 Pro 64 Bit : AMD (17.4.4) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 15th Jun 2017 09:57
Thanks Markus but I don't think you fully understand the issue.
It is line breaks that I've trying to avoid, I don't want them inserting automatically or manually.

SetTextScissor() would do the job I need but all text objects are already scissored to a larger area so scissoring them individually is not an option either.
AGK V2 user - Tier 1 (mostly)
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 15th Jun 2017 10:14
Quote: "SetTextScissor() would do the job I need but all text objects are already scissored to a larger area so scissoring them individually is not an option either."

can you explain it graphically?

i guess you will make a text scroll area and clipping a text similar a magnifier.
if you not want use SetTextMaxWidth the width is based on the font size or you need to scale the font size to fit the text into your fixed width.

AGK (Steam) V2017.05.15 : Windows 10 Pro 64 Bit : AMD (17.4.4) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
AjiMundi
8
Years of Service
User Offline
Joined: 28th Sep 2015
Location:
Posted: 15th Jun 2017 10:46
I had a project on different engine where I need to constrain text within a box. For example, the text "This is a line that is a bit too long." may be cut to "This is a line that..." depending on the fonts type/size used.
What I did was create the text full length, measure its pixel length and then use that to estimate the number of characters that need to be cut. For example if the text above was 200 pixel in length, and my constraint was 150 pixel, I would shorten the length to (150/200)x38 = 28 characters (rounded down), so I would have "This is a line that is a bit".
The actual calculation was a bit more lengthy process since it has to account for different character width, necessitating recalculation, and the fact that I would replace the last part of the text with "...", but that is the gist of it.
Naturally, if you plan on only using one font, you can pre-calculate the average width of characters and use that for calculation.
And of course the real text was not harmed in the process. I used two variables for the real text and the displayed one.
Hope that helps.
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 15th Jun 2017 10:52 Edited at: 15th Jun 2017 11:34
OK,

Here it is explained graphically.
It is a proof of concept file explorer. The text for each icon needs to be trimmed beneath the icon but not extended onto the next line and all text objects need to be constrained (scissored) within the explorer window.


My thoughts so far are that the best way would be to determine a 'box' that each text object should set within and check to see if that box is fully within the explorer window. If it is then scissor the text to the box. If it is fully outside the window then scissor it to the window. And if it overlaps that calculate the new scissor.

@AjiMundi Thanks, that seems like a viable option.

Of course, it would be much easier if SetTextMaxWidth() had a parameter that stopped the text overlapping onto the next line.

AGK V2 user - Tier 1 (mostly)

Attachments

Login to view attachments
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 15th Jun 2017 11:58 Edited at: 15th Jun 2017 12:04
i would say the outer scissor is just a min,max value.
so if you set the scissor for your icon text just limit the value in this range.
but that means if you scroll you need update the text icon scissor again.

function SetTextScissorEx(text,x1,y1,x2,y2,minx1,miny1,maxx2,maxy2 )
AGK (Steam) V2017.05.15 : Windows 10 Pro 64 Bit : AMD (17.4.4) Radeon R7 265 : Mac mini OS Sierra (10.12.2)

Attachments

Login to view attachments
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 15th Jun 2017 16:42
You can monitor the width of the text with GetTextTotalWidth() and crop with string manipulation or re-size to fit?
AjiMundi
8
Years of Service
User Offline
Joined: 28th Sep 2015
Location:
Posted: 16th Jun 2017 04:13
OK, so I made a quick and dirty test of text cutting in AGK2. It still have a few bug in it, but I have to leave quickly, so here it is. I might fix it later, maybe even adding a scrolling effect like that old project of mine.
Regarding scissoring the entire view, I have not yet experimented with it. My old way of doing it would be to use sprite masking, but I have not delve enough in AGK2 to see if that is possible.
Maybe you can just copy the picture under the view, hollow the center, and put it at the top?
Anyway, hope it helps.

Login to post a reply

Server time is: 2024-05-03 16:54:06
Your offset time is: 2024-05-03 16:54:06