Font Manipulation Methods
Once you’ve created a font using fontCreate
,
you can use the following methods.
For a description of the font’s
attributes (some or all), use fontActual
to query
the font:
$mw->fontCreate('bigfont', -family => 'Arial', -size => 48); %big = $mw->fontActual('bigfont'); print %big; # prints: -size 48 -overstrike 0 -underline 0 -weight normal -slant roman -family Arial $size = $mw->fontActual('bigfont', -size); print $size; #prints: 48
To change (or query) a property of a font
once it has been created, use fontConfigure
:
if ($mw->fontConfigure('bigfont', -size) < 24) { $mw->fontConfigure('bigfont', -size => 48); } # same as $mw->fontActual('bigfont'); %bigfont = $mw->fontConfigure('bigfont');
If you’d like to delete a font
definition, use fontDelete
:
$mw->fontDelete('bigfont');
If you delete a font that is being used, the widgets using it won’t change what they display. They display whatever font they were last. If you try to manipulate the font programmatically after it’s been deleted, you will get an error.
To get a
list of all the font families available on your system, use
fontFamilies
:
@families = $mw->fontFamilies;
To get a list of the currently defined
named fonts on your system, use fontNames
:
@definedfonts = $mw->fontNames;
The fontNames
method returns a list of object
references to Font objects. The list will be empty if there
aren’t any fonts defined on your system. Keep in mind this list
contains only those fonts defined using the
fontCreate ...
Get Mastering Perl/Tk now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.