Fixed Width Fonts #2
BNig
niggemann at uni-wh.de
Mon Jan 28 18:24:16 EST 2008
Ken,
somehow it doesnt filter for monospaced fonts. You probably meant
if w1 = w2 then
in the code
but still, when debugging, w1 and w2 are always 0, so w1 and w2 are always
equal and the names of all fonts are returned.
maybe the formattedWidth doesnt work on templatefield?
the timing is roughly the same with Scotts version and your version on 169
fonts macbook pro 700 ms for cold start
regards
Bernd
Ken Ray wrote:
>
> On Mon, 28 Jan 2008 12:13:50 -0800, Scott Rossi wrote:
>
>> Here's what I ran from a button on a card (I removed your object/global
>> references to simplify the test):
>
> Scott, I modified the code to not need to use fields at all (I'm using
> the templateField), and I discovered a speed increase (at least on my
> machine). When I ran your code I got about 5 seconds (initially), and
> then it was almost instantaneous the next time I ran it (I changed your
> code to track milliseconds instead of seconds and it was 9ms).
>
> When I changed the code to use the templateField (see below), it took
> 786ms after a cold start of Rev, and then also only 9ms afterwards. I
> have two versions below - one that doesn't assume that the
> templateField is being used later on by Rev for some other purpose, and
> one that resets it back to its prior state - the second one only took a
> couple of ms longer on the first pass (
>
> -- Resets templateField to the "factory version" when done:
> on mouseUp
> put the fontnames into vAvailableFonts
> sort lines of vAvailableFonts
>
> put the milliseconds into S
>
> repeat with x = 1 to the number of lines of vAvailableFonts
> set the text of the templateField to "iiiii"
> set the textfont of the templateField to line x of vAvailableFonts
> put the formattedWidth of the templateField into w1
> set the text of the templateField to "wwwww"
> set the textfont of the templateField to line x of vAvailableFonts
> put the formattedWidth of the templateField into w2
>
> if w1 = w1 then
> put line x of vAvailableFonts &return after temp
> end if
>
> end repeat
> reset the templateField
> put the milliseconds - S & cr & cr & temp
> end mouseUp
>
> -- Carefully restores the templateField to its previous state when done:
> on mouseUp
> put the fontnames into vAvailableFonts
> sort lines of vAvailableFonts
>
> put the milliseconds into S
>
> put the text of the templateField into tOldText
> put the textFont of the templateField into tOldFont
> repeat with x = 1 to the number of lines of vAvailableFonts
> set the text of the templateField to "iiiii"
> set the textfont of the templateField to line x of vAvailableFonts
> put the formattedWidth of the templateField into w1
> set the text of the templateField to "wwwww"
> set the textfont of the templateField to line x of vAvailableFonts
> put the formattedWidth of the templateField into w2
>
> if w1 = w1 then
> put line x of vAvailableFonts &return after temp
> end if
>
> end repeat
> set the text of the templateField to tOldText
> set the textFont of the templateField to tOldFont
>
> put the milliseconds - S & cr & cr & temp
> end mouseUp
>
>
> Best thing is - it doesn't use an actual field object, so it could be
> wrapped up in a library function...
>
> :-)
>
>
> Ken Ray
> Sons of Thunder Software, Inc.
> Email: kray at sonsothunder.com
> Web Site: http://www.sonsothunder.com/
> _______________________________________________
> 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
>
>
--
View this message in context: http://www.nabble.com/Fixed-Width-Fonts--2-tp15125474p15148474.html
Sent from the Revolution - User mailing list archive at Nabble.com.
More information about the use-livecode
mailing list