Tk: non-default font 16 x slower

Discussion in 'Ruby' started by Wybo Dekker, Aug 18, 2003.

  1. Wybo Dekker

    Wybo Dekker Guest

    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.
     
    Wybo Dekker, Aug 18, 2003
    #1
    1. Advertisements

  2. Hi,

    From: Wybo Dekker <>
    Subject: Tk: non-default font 16 x slower
    Date: Mon, 18 Aug 2003 19:52:35 +0900
    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.
     
    Hidetoshi NAGAI, Aug 18, 2003
    #2
    1. Advertisements

  3. 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.
     
    Kero van Gelder, Aug 18, 2003
    #3
  4. 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
     
    Richard Zidlicky, Aug 19, 2003
    #4
  5. Hi,

    From: Richard Zidlicky <>
    Subject: Re: Tk: non-default font 16 x slower
    Date: Tue, 19 Aug 2003 20:40:55 +0900
    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.
     
    Hidetoshi NAGAI, Aug 19, 2003
    #5
  6. When I use the default fonts in my Ruby-Tk application it takes
    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.
     
    Kero van Gelder, Aug 19, 2003
    #6
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.