[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ next ]
Many X applications that output a PostScript file and substitute X fonts for PostScript fonts for displaying want a list of PostScript fonts and substitute X fonts. x-postscript category will satisfy this demand. A font in this category is a name of PostScript font with `<X>/' prefix added, like <X>/Times-Roman, and each font has a XLFD as a hint. The XLFD is considered to have the most similar appearance to the PostScript font. If the script wants to make use of x-postscript category, its package must `Depends:' on psfontmgr.
The strategy of the Defoma-configuration script which accepts only x-postscript category is to ignore all commands except term, and generate a configuration file in term commands. To obtain available PostScript fonts and their substitutive XLFDs, the script calls defoma_font_get_fonts() function, which returns a list of fonts registered in the specified category, and defoma_font_get_hints() function, which returns hints of the specified font. All and only available (installed) x-postscript category fonts are obtained through these functions.
Following is an example of the header of the script. Note that there's declaration of using Defoma::Font module for defoma_font_get_fonts() and defoma_font_get_hints() functions.
@ACCEPT_CATEGORIES = ('x-postscript'); package example; use Debian::Defoma::Font; import Debian::Defoma::Font;
The main routine goes like this:
sub x_postscript { my $com = shift; return 0 if ($com ne 'term'); open(F, '>/var/lib/defoma/example.d/font.conf'); my @fonts = defoma_font_get_fonts('x-postscript'); foreach my $psfont (@fonts) { my @hints = defoma_font_get_hints('x-postscript', $psfont); $psfont =~ s/^\<X\<\///; my $xfont = $hints[0]; print F "$psfont $xfont\n"; } close F; }
This simple codes will generate a list of PostScript fonts and XLFDs like following.
Helvetica -adobe-helvetica-medium-r-normal--0-0-0-0-p-0-iso8859-1 Helvetica-Bold -adobe-helvetica-bold-r-normal--0-0-0-0-p-0-iso8859-1 Ryumin-Light-H -misc-mincho-medium-r-normal--0-0-0-0-c-0-jisx0208.1983-0
[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ next ]
A Tutorial on Writing Defoma Configuration Script
Yasuhiro Take