in reply to How can i add a font file in Perl Tk?

Hello Muskovitz,

I think the font file you downoladed is a system thing not a Tk one: I mean that, once you installed the font on your system you can use it in your Tk program.

The font name becomes the family in the Tk terminology. In the following example you can see a code named font ( single name that refers to a combination of family, size..) using the courier family already installed on the system.

my $code_font = $mw->fontCreate('code', -family => 'courier', -size => + 14);

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: How can i add a font file in Perl Tk?
by Muskovitz (Scribe) on Jul 27, 2017 at 10:05 UTC
    Hey, thanks for the reply! :)
    Yes. I actually thought of that installing the Font into the system but what i am trying to do is I'll pack my GUI program into standalone executable file 'BUT' if there's no way to do what i need. I guess I'll just follow your advice. Thanks again.
      Ah! this is another story..

      I think it can be accomplished too, even if more complicated. You can build your executable including the font file, then you can start your program (maybe a BEGIN block?) checking if the font is present.

      If the font is not already present you can automate the installation. In this case you must be aware of different font installation way depending on the OS the program is running on checking $^O variable.

      UPDATE if you do not want automate the font installation you can have a default one set at top of the program, before checking the existence of the font on the system, if not present or failed font installation your program will use the default one. This seems wise.

      So you'll have font options specified with  -font => [$font_name, 14]

      L*

      There are no rules, there are no thumbs..
      Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.