Skip to Main Content
Learning Perl/Tk
book

Learning Perl/Tk

by Nancy Walsh
January 1999
Beginner content levelBeginner
373 pages
9h 43m
English
O'Reilly Media, Inc.
Content preview from Learning Perl/Tk

C.2. Font Methods

The following methods are available only with the newest version of Perl/Tk, which contains Tk8.0.

C.2.1. Create

The fontCreatemethod creates a new font.

$name = $widget->fontCreate();
$name = $widget->fontCreate(fontname);

You can either specify a font name or one will be generated in the format "fontX" where X is a number. You can specify options for the font:

$name = $widget->fontCreate(-size => 12);
$name = $widget->fontCreate(fontname, -size => 12);

The options you can use to create a font are as follows:

-family =>name

The family name can be "courier", "times", or "helvetica". If you specify one of these, the closest match on your system will be used. You can also specify the name of a font that is specific to your machine (for example, "Moon Runes"), but it might not show up on other systems.

-size =>amount

The amount specified for the font size indicates how big you want the font to be. If the amount is positive, the font will be sized in points. If the amount is negative, the font will be sized by using the absolute value of the amount in pixels.

-weight => "normal" | "bold"

The -weight option determines the thickness of the font.

-slant => "roman" | "italic"

The slant of the font is how far it tips over to one side. By default, "roman"means that the font is upright. Specifying "italic" as the value for -slant will tilt the font to the right slightly.

-underline => 0 | 1

If you want the characters to be underlined, specify 1 for the -underlineoption. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Perl/Tk

Mastering Perl/Tk

Stephen Lidie, Nancy Walsh

Publisher Resources

ISBN: 1565923146Supplemental ContentCatalog PageErrata