Text::Amuse::Compile::Fonts - class for fonts management
# hash to hold the fonts file, where $wd is the font directory my %fontfiles = map { $_ => File::Spec->catfile($wd, $_ . '.otf') } (qw/regular italic bold bolditalic/); my $fonts = Text::Amuse::Compile::Fonts->new([ { name => 'Example Serif', type => 'serif', desc => 'example font', regular => $fontfiles{regular}, italic => $fontfiles{italic}, bold => $fontfiles{bold}, bolditalic => $fontfiles{bolditalic}, }, # more fonts here ]); # or you can pass the same structure if you got it serialized to # json and saved to a file. my $fonts = Text::Amuse::Compile::Fonts->new($json_file); my @fonts = $fonts->all_fonts;
This class has the purpose to hold the list of available fonts, which has to be provided to the constructor via a json file or as an arrayref of Text::Amuse::Compile::Fonts::Family objects.
To build a json file with some default fonts, you may want to try "the muse-create-font-file.pl" script installed with this distribution.
The constructor accept either a file or an arrayref with fonts specifications.
Each font specification is used to construct a Text::Amuse::Compile::Fonts::Family object, which in turn may contain Text::Amuse::Compile::Fonts::File objects.
Keys of the hashref inside the arrayref:
The name of the font. This is the system name, something that fontconfig will understand. You can try with fc-list to see if you can find it. Mandatory.
The type of the file. Can be either serif, sans or mono. Mandatory.
serif
sans
mono
An optional free form description.
The path to the regular font file (.ttf or .otf or .woff)
The path to the italic font file (.ttf or .otf or .woff)
The path to the bold font file (.ttf or .otf or .woff)
The path to the bolditalic font file (.ttf or .otf or .woff)
Please note that the paths to the files are optional. They are used only for the EPUB generation, when the files are embedded in the final file.
Also note that the name of the fonts is not arbitrary. Fontconfig needs to recognize it for a successful LaTeX compilation.
The arrayref with the Text::Amuse::Compile::Fonts::Family objects.
Return the list of fonts, as a plain list
As above, but only the serif fonts
As above, but only the mono fonts
As above, but only the sans fonts
Return the list of fonts which have the paths to the font file.
Construct the font list from either the data structure or the file path.
To install Text::Amuse::Compile, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::Amuse::Compile
CPAN shell
perl -MCPAN -e shell install Text::Amuse::Compile
For more information on module installation, please visit the detailed CPAN module installation guide.