full text justification

Something you want to see in a LiveCode product? Want a new forum set up for a specific topic? Talk about it here.

Moderator: Klaus

Post Reply
dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

full text justification

Post by dave.kilroy » Wed Apr 30, 2014 3:21 pm

Hello all LiveCode gurus, grand masters, big cheeses, little cheeses and total newbies

I need to be able to display fully justified text in a LiveCode field - I found some code that Brian Yennie wrote in 2007 (http://thread.gmane.org/gmane.comp.ide. ... cus=100322 thanks Brian!) that I've tweaked and have now got justified text that seems OK (if you don't look too closely). I'm including the stack here in the hope that others might find it of use - and that some of you will be able to suggest ways to improve what I've got and move us on towards something like 'proper' justified text which we can all benefit from.

Of course in the long-term LiveCode will have a 'full justify' options on its fields and the feature request for this is http://quality.runrev.com/show_bug.cgi?id=4714

So, please check out the hack code in my stack and let me have your suggestions on how to progress things

Kind regards

Dave

PS: new versions of the stack will always be attached to the first posting of this thread
Attachments
JustifyText3.livecode.zip
(4.36 KiB) Downloaded 270 times
Last edited by dave.kilroy on Wed Apr 30, 2014 8:25 pm, edited 1 time in total.
"...this is not the code you are looking for..."

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: full text justification

Post by Dixie » Wed Apr 30, 2014 3:28 pm

That's neat...:-) I like this !

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: full text justification

Post by dave.kilroy » Wed Apr 30, 2014 3:32 pm

Thanks Dixie :)

Like I say it's mostly copied from Brian's work and then tweaked - but it is most certainly a hack (in the not-yet-cooked sense) and could do with a lot of attention from coders here...

Dave
"...this is not the code you are looking for..."

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10057
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: full text justification

Post by FourthWorld » Wed Apr 30, 2014 3:51 pm

Nicely done, Dave - thanks for posting that!
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: full text justification

Post by dave.kilroy » Wed Apr 30, 2014 5:10 pm

Just tried this on Windows and it's a mess! Will figure out what is happening and upload a new version...
"...this is not the code you are looking for..."

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: full text justification

Post by dave.kilroy » Wed Apr 30, 2014 7:55 pm

Hi all

OK discovered the problem when on Windows 7 was that I was using LC 6.6.2(rc2) - when I changed to LC 6.6.1 everything calmed down (although I did have to prevent my tweakJustification handler running on Windows which means the right-hand margin is a bit less uniform). New version with these changes available here: [edit] actually in order to avoid confusion I've moved the new version to the first posting in this thread[\edit]

So, it appears there is a bug on LC 6.6.2(rc2) when on Windows - I'll file a bug report...

Kind regards

Dave
Last edited by dave.kilroy on Wed Apr 30, 2014 8:23 pm, edited 1 time in total.
"...this is not the code you are looking for..."

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: full text justification

Post by dave.kilroy » Wed Apr 30, 2014 8:21 pm

Bug report for difference in how LC 6.6.2(rc2) responds to formattedWidth filed at http://quality.runrev.com/show_bug.cgi?id=12332

...although maybe it isn't a bug at all but a foreshadowing of new field properties...

Dave
"...this is not the code you are looking for..."

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: full text justification

Post by dave.kilroy » Wed Apr 30, 2014 8:52 pm

I don't think this is a bug anymore - just a mystery...

I had been doing some testing and discovered it now runs in Windows with LC 6.6.2(rc2)!! I don't really know why ... but as long as you use the latest version it now appears to run fine :o
"...this is not the code you are looking for..."

Tonaras
Posts: 22
Joined: Mon Jul 03, 2017 1:25 am

Re: full text justification

Post by Tonaras » Wed Aug 27, 2025 9:34 am

Hello all,

it's been 18 years since this request has been posted on Bugzilla Bug 4714 and nothing has been done ever since. Not having support for fully justified text in LiveCode's text runs is a big issue for me (and I'm sure for many others).

The little pseudo-justification handlers posted by Dave are remarkably good for some simple use cases but not a solution for more serious text formatting projects that include printing etc.

@dave.kilroy
Hello, Dave, the pseudo-justified text produced by your handlers are problematic when one wants to copy the text and paste it somewhere else. Even a 'put the text of fld "lblText" into MyText' fails and the culprit are those NUL characters inserted by numToChar(0) in your handlers.

If instead of numToChar(0) we use numToCodepoint(8203), the pseudo-justified text from the field can be copied and processed normally as any other text. Just a little tip for anyone who wants to use these handlers. :wink:

Finally, I seriously hope we will FINALLY get real, fully justified text in the LiveCode engine asap!

Best regards,
Anton

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10127
Joined: Fri Feb 19, 2010 10:17 am

Re: full text justification

Post by richmond62 » Wed Aug 27, 2025 1:20 pm

viewtopic.php?t=20513

The FullJustificationLC7.livecode stack does NOT work with LC 963.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10127
Joined: Fri Feb 19, 2010 10:17 am

Re: full text justification

Post by richmond62 » Wed Aug 27, 2025 1:48 pm

Oddly enough MetaCard had the property justify . . . which does NOT seem to work in LiveCode like this:

Code: Select all

on mouseUp
   set the justify of fld "ff" to true
end mouseUp
although the scriptEditor does NOT object to the term.

https://tools.irvantaufik.me/tools/justify-text.html

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10127
Joined: Fri Feb 19, 2010 10:17 am

Re: full text justification

Post by richmond62 » Wed Aug 27, 2025 2:12 pm

Played "silly buggers" with ClaudeGPT and ended up with this:

Code: Select all

on mouseUp
   manualJustifyTextField "ff"
end mouseUp

on manualJustifyTextField pFieldName
   local tText, tLines, tJustifiedText, tFieldRef
   
   -- Build proper field reference
   if "field" is not in pFieldName then
      put "field" && quote & pFieldName & quote into tFieldRef
   else
      put pFieldName into tFieldRef
   end if
   
   -- Get the text
   do "put the text of" && tFieldRef && "into tText"
   
   -- Split into lines using proper LiveCode syntax
   put tText into tLines
   replace return with numToChar(3) in tLines
   split tLines by numToChar(3)
   
   repeat with i = 1 to the number of elements in tLines
      if tLines[i] is not empty and the number of words in tLines[i] > 1 then
         -- Replace single spaces with double spaces for basic justification
         replace space with "  " in tLines[i]
      end if
   end repeat
   
   -- Reconstruct the text
   put empty into tJustifiedText
   repeat with i = 1 to the number of elements in tLines
      if i > 1 then put return after tJustifiedText
      put tLines[i] after tJustifiedText
   end repeat
   
   -- Put it back
   do "put tJustifiedText into" && tFieldRef
end manualJustifyTextField
Which does a half-cock job:
-
Screenshot 2025-08-27 at 16.10.04.jpg
-
Here's what LibreOffice does, by way of comparison:
-
Screenshot 2025-08-27 at 16.11.27.png

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10127
Joined: Fri Feb 19, 2010 10:17 am

Re: full text justification

Post by richmond62 » Wed Aug 27, 2025 2:15 pm

Should I laugh, cry, or run naked through the streets tearing my beard out?
-
Screenshot 2025-08-27 at 16.14.18.png
-
marvin-the-paranoid-android.jpg
-
Screenshot 2025-08-27 at 16.16.55.png
-
Cripes, and some people are scared of A.I. . . . 8)

Post Reply