1PDF::Builder::Resource:U:sFeorntC(o3n)tributed Perl DocuPmDeFn:t:aBtuiiolnder::Resource::Font(3)
2
3
4

NAME

6       PDF::Builder::Resource::Font - some common support routines for font
7       files. Inherits from PDF::Builder::Resource::BaseFont
8

METHODS

10       $font->automap()
11           This applies to core fonts ("$pdf->corefont()") and PostScript
12           fonts ("$pdf->psfont()"). These cannot use UTF-8 (or other
13           multibyte character) encoded text; only single byte characters.
14           This limits a font to a maximum of 256 glyphs (the "standard"
15           single-byte encoding being used). Any other glyphs supplied with
16           the font are inaccessible.
17
18           "automap" splits a font containing more than 256 glyphs into
19           "planes" of single byte fonts of up to 256 glyphs, so that all
20           glyphs may be accessed in separate "fonts". An array of new fonts
21           will be returned, with [0] being the standard code page (of the
22           selected encoding). If there are any glyphs beyond xFF on the
23           standard encoding page, they will be returned in one or more
24           additional fonts of 223 glyphs each. Why 223? The first 32 are
25           reserved as control characters (although they have no glyphs), and
26           number x20 is a space. This, plus 223, gives 256 in total (the last
27           plane may have fewer than 223 glyphs). These "fonts" are temporary
28           (dynamic), though as usable as any other font.
29
30           Note that a plane may be empty (only space at x20 and possibly an
31           unusable character at x21) if the previous plane was full. You
32           might want to check if any character in the plane has a Unicode
33           value (if not, it's empty).
34
35           The ordering of these 223 glyphs in each following plane does not
36           appear to follow any particular official scheme, so be sure to
37           reference something like "examples/020_corefonts" to see what is
38           available, and what code point a glyph is at (e.g., an 'A' in the
39           text stream will print something different if you're not on plane
40           0). For a given font file, they should be consistent. For instance,
41           in Times-Roman core font, an \x21 or ! in plane[1] should always
42           give an A+macron. Further note that new editions of font files
43           released in the future may have changes to the glyph list and the
44           ordering (affecting which plane a glyph appears on), so use
45           automap() with caution. It appears that glyphs are sorted by
46           Unicode number, but if a new glyph is inserted, it would bump other
47           glyphs to new positions, and even to the next plane.
48
49           An example:
50
51               $fnt = $pdf->corefont('Times-Roman', -encode => 'latin1');
52               @planes = ($fnt, $fnt->automap());  # two planes
53               $text->font($planes[0], 15);  # or just $fnt will work
54               $text->text('!');  # prints !
55               $text->font($planes[1], 15);
56               $text->text('!');  # prints A+macron
57
58           If you had used 'latin2' encoding, an \x21 on plane 1 will give an
59           inverted !  (¡ HTML entity).
60
61           Note that "$planes[$n]->fontname()" should always be the desired
62           base font (e.g., Times-Roman), while "$planes[$n]->name()" will be
63           the font ID (e.g., TiRoCBC) for plane 0, while for other planes
64           there will be a unique suffix added (e.g., TiRoCBCam0).
65
66           If you have just an occasional non-plane 0 character (or run of
67           characters), it may be tolerable to switch back and forth between
68           planes like this, just as typing an HTML entity once in a while
69           when you need a Greek letter on a web page is acceptable to most
70           people. However, if you're typing a lot of Greek text, a dedicated
71           keyboard may be better for you. Like that, switching to a TTF font
72           in order to be able to use UTF-8 may be easier.
73
74
75
76perl v5.32.1                      2021-03-29   PDF::Builder::Resource::Font(3)
Impressum