O'Reilly logo

Learning Perl/Tk by Nancy Walsh

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

C.1. The Font String

When there is a -font option for a widget, you need to pass a string that indicates which font to use. There are several ways to specify a font string:

  • Specify the name of a font with the fontCreate method (fontCreateis explained later in this chapter in "Font Methods").

  • Use a string that describes the font and follows a predefined format (see Appendix B); for example, "Times 12 Normal."

  • Use the name of a font that can be interpreted by the graphics display (typically a Unix system running X Windows). These strings usually have asterisks in them and are very hard for humans to comprehend.

To specify a font in a string, you first have to know which fonts are available on your system.

C.1.1. Determining Available Fonts

In Unix, you must specify fonts by using a long, drawn-out syntax with a lot of asterisks that represent families, size, type, and so on. In the X Window System, you can get a list of Unix fonts by running the command

xlsfonts > font_file

The filenamed font_file will now contain a huge list of fonts that you can use on your system. Be careful when picking fonts from this huge list. If you are going to be running your application from more than one system, the font you pick might not be available on all systems.

If you use Microsoft Windows, you'll have a different way of seeing what fonts are available. Click on the Start menu and select Settings → Control Panel. Once the Control Panel appears, double-click Fonts and a window similar to the one ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required