Fixed Width Fonts #2
mdswindell at cruzio.com
Mon Jan 28 11:08:35 EST 2008
On Jan 27, 2008, at 3:54 PM, Scott Rossi wrote:
> Recently, Mark Swindell wrote:
>> Is there for Rev to determine which system fonts are of fixed width?
>> If not directly, then indirectly? Comparing widths of "i" and "w" on
>> a font by font basis? How might this work?
> Tried your idea using the following: Created two 18pt text fields,
> put "W"
> into fld 1, "I" into field 2, ran the following function:
> return (formattedWidth of fld 1 = formattedWidth of fld 2)
> Results were false with Rev's default font, true with Monaco and
> Apple Mono
> (OS X).
> Seems like a valid direction.
> Scott Rossi
> Creative Director
> Tactile Media, Multimedia & Design
Thanks for your help. Curious thing, though. I created a script
( below) which works fine when I run it line by line in the debugger,
and _sometimes_ when I run it from a button, and then the next time
(s), from the same button, it just chugs along and and returns
nothing. Any ideas?
put empty into field "fixedWidth" of cd 1 of stack "FixedWidth"
put "iiiii" into field "skinnyLetter" of cd 1 of stack "FixedWidth"
put "wwwww" into field "fatLetter" of cd 1 stack "FixedWidth"
put the fontnames into vAvailableFonts
sort lines of vAvailableFonts
repeat with x = 1 to the number of lines of vAvailableFonts
set the textfont of field "skinnyLetter" to line x of
set the textfont of field "fatLetter" to line x of
wait .05 seconds -- needs time to evaluate, maybe? dunno
put the formattedwidth of fld "skinnyLetter" into vSkinny
put the formattedwidth of fld "fatLetter" into vFat
if vSkinny = vFat then
put line x of vAvailableFonts &return after field
"FixedWidth" of cd 1 of stack "FixedWidth"
put field "FixedWidth" into gFixedWidthFonts
More information about the use-livecode