The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

FLTK::Font - Font selection code for the Fast Light Tool Kit

Description

Identifies a font. You can create these with font(name) or with list_fonts(). Do not attempt to create your instances or modify it.

Functions

bold

my $bfont = $font->bold( );

Same as plus(BOLD), returns a bold version of this font.

encodings

my @encodings = $font->encodings( );

Return all the encodings for this font. These strings may be sent to set_encoding() before using the font.

font

my $font = $font->font( $name, $attributes );

Find a font with the given "nice" name. You can get bold and italic by adding a space and "bold" or "italic" (or both) to the name, or by passing them as the attributes. Case is ignored and fltk will accept some variations in the font name.

The current implementation calls list_fonts() and then does a binary search of the returned list. This can make the first call pretty slow, especially on X. Directly calling the system has a problem in that we want the same structure returned for any call that names the same font. This is sufficiently painful that I have not done this yet.

Import this function with the :font tag.

my $font = $font->font( $id );

Find a Font from an fltk1 integer font id.

Import this function with the :font tag.

italic

my $ifont = $font->italic( );

Same as plus(ITALIC), returns an italic version of this font.

list_fonts

my @fonts = $font->list_fonts( );

Returns an array containing every font on the server. Each element is a "base" font, there may be bold, italic, and bold+italic version of each font pointed to by bold() or italic().

Subsequent calls will usually return the same array quickly, but if a signal comes in indicating a change it will probably delete the old array and return a new one.

Import this function with the :font tag.

name

my $str = $font->name( );

Return a single string that names this font. Passing this string and zero for the attributes to find() will return the same font.

If the font's attributes are non-zero, this is done by appending a space and "Bold" and/or "Italic" to the name. This allows a single string rather than a string+attribute pair to identify a font, which is really useful for saving them in a file.

$font->name( $attributes );

Returns a string name for this font with any attributes (BOLD, ITALIC). Using the returned string and attributes as arguments to find() will return the same font.

plus

my $similar = $font->plus( $attributes );

Return a font from the same family with the extra attributes turned on. This may return the same font if the attributes are already on or there is no font with those attributes.

sizes

my @list = $font->sizes( );

Returns list of sizes. The sizes are sorted from smallest to largest and indicate what sizes can be given to setfont() that will be matched exactly (setfont() will pick the closest size for other sizes). A zero in the first location of the array indicates a scalable font, where any size works, although the array may still list sizes that work "better" than others. The returned array points at a static buffer that is overwritten each call, so you want to copy it if you plan to keep it.

system_name

my $name = $font->system_name( );

Returns the string actually passed to the operating system, which may be different than name().

For Xlib, this is a pattern sent to XListFonts to find all the sizes. For most other systems this is the same as name() without any attributes.

Author

Sanko Robinson <sanko@cpan.org> - http://sankorobinson.com/

License and Legal

Copyright (C) 2008-2010 by Sanko Robinson <sanko@cpan.org>

This program is free software; you can redistribute it and/or modify it under the terms of The Artistic License 2.0. See the LICENSE file included with this distribution or notes on the Artistic License 2.0 for clarification.

When separated from the distribution, all original POD documentation is covered by the Creative Commons Attribution-Share Alike 3.0 License. See the clarification of the CCA-SA3.0.