building a font picker
Howard Bornstein
bornstein at designeq.com
Fri Jul 18 23:34:03 EDT 2003
>1) Is there a way that's faster than this? If the user had lots of
>fonts on their system, it would take a bit to grind through them all.
I set up a little test stack for this and used this script:
on mouseup
put empty into fld "List"
put the fontnames into fontlist
put the ticks into t1
lock screen
repeat with i = 1 to number of lines in fontlist
put line i of fontlist into fontName
set the textFont of fld "F1" to fontName -- contains the letter "i"
set the textFont of fld "F2" to fontName -- contains the letter "Z"
put the formattedWidth of fld "F1" into fwd1
put the formattedWidth of fld "F2" into fwd2
if (fwd1 = fwd2) then put fontName &return after fld "List"
end repeat
put the ticks into t2
put (t2-t1)/60&&"seconds"
end mouseup
On my system (iMac 500 Mz running OS 9.2.1 and Rev 2.01) it took .05
seconds to generate a list of 18 monospaced fonts out of a font list of
351 fonts. This is using my previous suggestion of comparing two letters
rather than the entire alphabet.
The key to this speed, btw, is the lock screen command. You could
probably get an additional significant increase on this by using the "for
each" repeat structure. But it seems plenty fast even without this.
Regards,
Howard Bornstein
____________________
D E S I G N E Q
www.designeq.com
More information about the use-livecode
mailing list