character to justify text

Viktoras Didziulis viktoras at ekoinf.net
Wed Jun 27 04:02:56 EDT 2007


Hi, 
 
you can try adjusting the size of space characters like this: 
 
repeat with i=1 to the number of chars in fld "fText" 
set the textSize of char x of "fText" to y 
end repeat 
 
where char x is space character and y is a number between 4 and whatever the
upper limit is... If the fixedLineHeight of field is set to true, then the
only thing that changes would be the width of space character. 
 
The hard point here is to get a length of a text line in pixels so you could
calculate the necessary size of space character for each line. As I imagine
first you would need to find the longest line in the field and then justify
the remaining lines in relation to this maximum. 
 
Of course you may try creating an index of all possible characters and their
widths for different fonts and sizes, then get the length of line in
characters and use the index to sum up the length in pixels... Then find a
difference subtracting length of current string from maximum length,
counting number of spaces in a line and then calculate what size all space
characters should be set to compensate for the difference. 
 
In principle not so hard once you know a way to measure absolute length of
text string in pixels. 
 
All the best! 
Viktoras 
 
-------Original Message------- 
 
From: Kay C Lan 
Date: 27/06/2007 05:43:10 
To: How to use Revolution 
Subject: Re: character to justify text 
 
On 6/27/07, -= JB =- <sundown at nwrain.net> wrote: 
> 
> 
> The problem with making a font and 
> then using my own character it would change the character count. 
> Of course I could easily add the character and then subtract it but 
> who knows what other weird things I might find. 
 
 
One thought, if you're going to go to all the trouble of making your own 
font, is to include several versions of the space character, ie a 3 pixel 
space, a 4 pixel space, etc etc. Maybe accessible via spacebar = 3px, 
option+spacebar = 4px, shift+option+spacebar = 5px. Then I assume a simple 
'repeat for each' replacing each standard 3px space with a 4px space until 
you get to the required width, and if you replaced all in a line and it 
still wasn't wide enough you go on to 5px, 6px etc etc. 
 
That way the char count wouldn't change. 
 
Just a thought, but then again, the thought of creating a font from scratch 
seems pretty daunting to me ;-) 
_______________________________________________ 
use-revolution mailing list 
use-revolution at lists.runrev.com 
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences: 
http://lists.runrev.com/mailman/listinfo/use-revolution



More information about the use-livecode mailing list