full text justification
Moderator: Klaus
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Contact:
full text justification
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
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..."
Re: full text justification
That's neat...
I like this !

-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Contact:
Re: full text justification
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

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..."
-
- VIP Livecode Opensource Backer
- Posts: 10057
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: full text justification
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Contact:
Re: full text justification
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..."
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Contact:
Re: full text justification
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
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..."
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Contact:
Re: full text justification
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
...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..."
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Contact:
Re: full text justification
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
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

"...this is not the code you are looking for..."
Re: full text justification
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
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
-
- Livecode Opensource Backer
- Posts: 10127
- Joined: Fri Feb 19, 2010 10:17 am
-
- Livecode Opensource Backer
- Posts: 10127
- Joined: Fri Feb 19, 2010 10:17 am
Re: full text justification
Oddly enough MetaCard had the property justify . . . which does NOT seem to work in LiveCode like this:
although the scriptEditor does NOT object to the term.
https://tools.irvantaufik.me/tools/justify-text.html
Code: Select all
on mouseUp
set the justify of fld "ff" to true
end mouseUp
https://tools.irvantaufik.me/tools/justify-text.html
-
- Livecode Opensource Backer
- Posts: 10127
- Joined: Fri Feb 19, 2010 10:17 am
Re: full text justification
Played "silly buggers" with ClaudeGPT and ended up with this:
Which does a half-cock job:
- -
Here's what LibreOffice does, by way of comparison:
-
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
- -
Here's what LibreOffice does, by way of comparison:
-
-
- Livecode Opensource Backer
- Posts: 10127
- Joined: Fri Feb 19, 2010 10:17 am
Re: full text justification
Should I laugh, cry, or run naked through the streets tearing my beard out?
- - - -
Cripes, and some people are scared of A.I. . . .
- - - -
Cripes, and some people are scared of A.I. . . .
