NAME
SIRTX::Font - module for working with SIRTX font files
VERSION
version v0.01
SYNOPSIS
use SIRTX::Font;
my SIRTX::Font $font = SIRTX::Font->new;
$font->read('cool-font.sf');
$font->write('cool-font.sf');
if ($font->has_codepoint(0x1234)) { ... }
printf("%ux%u\@%u\n", $font->width, $font->height, $font->bits);
$font->glyph_for(0x1234, $font->import_glyph('U+1234.png'));
This module implements an interface to SIRTX font files.
All methods in this module die
on error unless documented otherwise.
METHODS
new
my SIRTX::Font $font = SIRTX::Font->new;
Creates a new font object. No parameters are supported.
gc
$font->gc;
(experimental)
Takes the trash out. This will remove unused glyphs and deduplicate glyphs that are still in use.
Note: After a call to this all glyph numbers become invalid.
width
$font->width($width);
my $width = $font->width;
Sets or gets the width of character cells.
height
$font->height($height);
my $height = $font->height;
Sets or gets the height of character cells.
bits
$font->bits($bits);
my $bits = $font->bits;
Sets or gets the bits per pixel of character cells.
has_codepoint
my $bool = $font->has_codepoint($codepoint);
Returns a true value if the code point is knowm, otherwise return a false value.
remove_codepoint
$font->remove_codepoint(0x1234);
Removes a code point from the font. This will not remove the glyph.
If the code point is not known this method will do nothing.
glyph_for
my $glyph = $font->glyph_for($codepoint); # $codepoint is 0x1234 or 'U+1234'
$font->glyph_for($codepoint => $glyph);
Sets or gets the glyph for a given code point.
default_glyph_for
$glyph = $font->default_glyph_for($codepoint => $glyph);
Sets the glyph for the code point if it has no glyph set so far. Returns the new glyph (if the code point was modified) or the old (if it was already set).
alias_glyph
$font->alias_glyph($from, $to);
Aliases the glyph for code point $from
to the same as code point $to
.
See also "glyph_for".
default_alias_glyph
$font->default_alias_glyph($from, $to);
Aliases the glyph for code point $from
to the same as code point $to
if $from
has no glyph set.
read
$font->read($handle);
Reads a font file into memory. If any data is already loaded the data is merged.
write
$font->write($handle);
Writes the current font in the SIRTX format to the given handle.
import_glyph
my $glyph = $font->import_glyph($filename);
Imports a glyph from a file. The glyph index is returned.
The supported formats depend on the installed modules. See also Image::Magick.
export_glyph_as_image_magick
my Image::Magick $image = $font->export_glyph_as_image_magick($glyph);
(experimental)
Exports a single glyph as a image object.
AUTHOR
Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2025 by Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)