Page 1 of 1
full text justification
Posted: Wed Apr 30, 2014 3:21 pm
by dave.kilroy
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
Re: full text justification
Posted: Wed Apr 30, 2014 3:28 pm
by Dixie
That's neat...

I like this !
Re: full text justification
Posted: Wed Apr 30, 2014 3:32 pm
by dave.kilroy
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
Re: full text justification
Posted: Wed Apr 30, 2014 3:51 pm
by FourthWorld
Nicely done, Dave - thanks for posting that!
Re: full text justification
Posted: Wed Apr 30, 2014 5:10 pm
by dave.kilroy
Just tried this on Windows and it's a mess! Will figure out what is happening and upload a new version...
Re: full text justification
Posted: Wed Apr 30, 2014 7:55 pm
by dave.kilroy
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
Re: full text justification
Posted: Wed Apr 30, 2014 8:21 pm
by dave.kilroy
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
Re: full text justification
Posted: Wed Apr 30, 2014 8:52 pm
by dave.kilroy
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

Re: full text justification
Posted: Wed Aug 27, 2025 9:34 am
by Tonaras
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.
Finally, I seriously hope we will FINALLY get real, fully justified text in the LiveCode engine asap!
Best regards,
Anton
Re: full text justification
Posted: Wed Aug 27, 2025 1:20 pm
by richmond62
viewtopic.php?t=20513
The
FullJustificationLC7.livecode stack does NOT work with
LC 963.
Re: full text justification
Posted: Wed Aug 27, 2025 1:48 pm
by richmond62
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
Re: full text justification
Posted: Wed Aug 27, 2025 2:12 pm
by richmond62
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:
-
-
Here's what LibreOffice does, by way of comparison:
-
Re: full text justification
Posted: Wed Aug 27, 2025 2:15 pm
by richmond62
Should I laugh, cry, or run naked through the streets tearing my beard out?
-
-
-
-
Cripes, and some people are scared of A.I. . . .
