Tk: non-default font 16 x slower

W

Wybo Dekker

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.
 
H

Hidetoshi NAGAI

Hi,

From: Wybo Dekker <[email protected]>
Subject: Tk: non-default font 16 x slower
Date: Mon, 18 Aug 2003 19:52:35 +0900
Message-ID: said:
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.

Could you tell me your environment ( Ruby version, Tcl/Tk version, OS,
and so on ) and send me your script?

Maybe the problem depends on auto-creation of font objects.
If you use the same font for many widgets, please create a TkFont
object for the font and try to give the font object to the font option
of each widgets.
 
K

Kero van Gelder

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.

Use a font explicitely, not only string references (which causes the font
to be built over and over again), like:

font = TkFont.new('courier')
widget.font(font)

hth,
Kero.
 
R

Richard Zidlicky

Use a font explicitely, not only string references (which causes the font
to be built over and over again), like:

font = TkFont.new('courier')

very good tip, but why is font creation so exceedingly slow
anyway?
On a Pentium 100 it used to take a few seconds with a font
that was already cached by xfs.

Richard
 
H

Hidetoshi NAGAI

Hi,

From: Richard Zidlicky <[email protected]>
Subject: Re: Tk: non-default font 16 x slower
Date: Tue, 19 Aug 2003 20:40:55 +0900
Message-ID: said:
very good tip, but why is font creation so exceedingly slow
anyway?

Ruby/Tk recommends to distinguish between (1) widgets have the
*SAME* font, and (2) widgets coincidentally have the fonts with
same properties. That is the reason of creating a named font
when a font name is given to 'font' option. When properties of
a TkFont object are changed, displayed font images of all widgets
given the TkFont object are changed. However, it needs large cost
to create a new named font. So, Ruby/Tk is slow if you give the
'font' option with a font name to each of many widgets.
 
K

Kero van Gelder

When I use the default fonts in my Ruby-Tk application it takes
very good tip, but why is font creation so exceedingly slow
anyway?
On a Pentium 100 it used to take a few seconds with a font
that was already cached by xfs.

It is "created" in Tk. Probably some "extra" things happen.
The answer to what happens, would be in some Tk manual or newsgroup :)

Bye,
Kero.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top