Hi, 

From: Wybo Dekker <wybo / servalys.nl>
Subject: Tk: non-default font 16 x slower
Date: Mon, 18 Aug 2003 19:52:35 +0900
Message-ID: <Pine.LNX.4.44.0308181227580.1504-100000 / servalys.nl>
> When I use the default fonts in my Ruby-Tk application it takes
> 400 milliseconds to start up. When I use Helvetica or other fonts it takes
> 6400 seconds. Is there something I can do about that? Perl does not have
> that problem.

I improved font control of Ruby/Tk on CVS. Probably, it has better 
performance at setting the font option by a font name string. 

On the operation of old version, Ruby/Tk creates automatically a 
TkFont object which depends on the font parameters. To create a 
TkFont object, Ruby/Tk creates named fonts on the Tk interpreter. 
The Tk interpreter search a font which matchs to the font parameters. 
The search needs large cost. 

On the operation of new version, Ruby/Tk does *NOT* creates 
automatically a TkFont object. Only requests the Tk interpreter to 
set the font of the widget to the font based on the font parameters. 

However, if the font option of the widget is refered, Ruby/Tk creates 
a new TkFont object for current font of the widget and replaces the 
font of the widget to the TkFont object. The purpose of this operation 
is to allow such like as the following method call. 
-----------------------------------------
b = TkButton.new(:text=>'aaaAAAaaa', :font=>'courier').pack
b.font.size(20)
-----------------------------------------
Without replacing the font, b.font returns a font name string. 
So, b.font.size(20) will raise an exception.

If you can, please get the newest version of Ruby/Tk from CVS and try it.
-- 
                                  Hidetoshi NAGAI (nagai / ai.kyutech.ac.jp)