| 1 | package Font::TTF::PCLT; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | Font::TTF::PCLT - PCLT TrueType font table | ||
| 6 | |||
| 7 | =head1 DESCRIPTION | ||
| 8 | |||
| 9 | The PCLT table holds various pieces HP-PCL specific information. Information | ||
| 10 | here is generally not used by other software, except for the xHeight and | ||
| 11 | CapHeight which are stored here (if the table exists in a font). | ||
| 12 | |||
| 13 | =head1 INSTANCE VARIABLES | ||
| 14 | |||
| 15 | Only from table and the standard: | ||
| 16 | |||
| 17 | version | ||
| 18 | FontNumber | ||
| 19 | Pitch | ||
| 20 | xHeight | ||
| 21 | Style | ||
| 22 | TypeFamily | ||
| 23 | CapHeight | ||
| 24 | SymbolSet | ||
| 25 | Typeface | ||
| 26 | CharacterComplement | ||
| 27 | FileName | ||
| 28 | StrokeWeight | ||
| 29 | WidthType | ||
| 30 | SerifStyle | ||
| 31 | |||
| 32 | Notice that C<Typeface>, C<CharacterComplement> and C<FileName> return arrays | ||
| 33 | of unsigned characters of the appropriate length | ||
| 34 | |||
| 35 | =head1 METHODS | ||
| 36 | |||
| 37 | =cut | ||
| 38 | |||
| 39 | use strict; | ||
| 40 | use vars qw(@ISA %fields @field_info); | ||
| 41 | |||
| 42 | require Font::TTF::Table; | ||
| 43 | use Font::TTF::Utils; | ||
| 44 | |||
| 45 | @ISA = qw(Font::TTF::Table); | ||
| 46 | @field_info = ( | ||
| 47 | 'version' => 'v', | ||
| 48 | 'FontNumber' => 'L', | ||
| 49 | 'Pitch' => 'S', | ||
| 50 | 'xHeight' => 'S', | ||
| 51 | 'Style' => 'S', | ||
| 52 | 'TypeFamily' => 'S', | ||
| 53 | 'CapHeight' => 'S', | ||
| 54 | 'SymbolSet' => 'S', | ||
| 55 | 'Typeface' => 'C16', | ||
| 56 | 'CharacterComplement' => 'C8', | ||
| 57 | 'FileName' => 'C6', | ||
| 58 | 'StrokeWeight' => 'C', | ||
| 59 | 'WidthType' => 'C', | ||
| 60 | 'SerifStyle' => 'c'); | ||
| 61 | |||
| 62 | sub init | ||
| 63 | { | ||
| 64 | my ($k, $v, $c, $i); | ||
| 65 | for ($i = 0; $i < $#field_info; $i += 2) | ||
| 66 | { | ||
| 67 | ($k, $v, $c) = TTF_Init_Fields($field_info[$i], $c, $field_info[$i + 1]); | ||
| 68 | next unless defined $k && $k ne ""; | ||
| 69 | $fields{$k} = $v; | ||
| 70 | } | ||
| 71 | } | ||
| 72 | |||
| 73 | |||
| 74 | =head2 $t->read | ||
| 75 | |||
| 76 | Reads the table into memory thanks to some utility functions | ||
| 77 | |||
| 78 | =cut | ||
| 79 | |||
| 80 | sub read | ||
| 81 | { | ||
| 82 | my ($self) = @_; | ||
| 83 | my ($dat); | ||
| 84 | |||
| 85 | $self->SUPER::read || return $self; | ||
| 86 | |||
| 87 | init unless defined $fields{'xHeight'}; | ||
| 88 | $self->{' INFILE'}->read($dat, 54); | ||
| 89 | |||
| 90 | TTF_Read_Fields($self, $dat, \%fields); | ||
| 91 | $self; | ||
| 92 | } | ||
| 93 | |||
| 94 | |||
| 95 | =head2 $t->out($fh) | ||
| 96 | |||
| 97 | Writes the table to a file either from memory or by copying. | ||
| 98 | |||
| 99 | =cut | ||
| 100 | |||
| 101 | sub out | ||
| 102 | { | ||
| 103 | my ($self, $fh) = @_; | ||
| 104 | |||
| 105 | return $self->SUPER::out($fh) unless $self->{' read'}; | ||
| 106 | $fh->print(TTF_Out_Fields($self, \%fields, 54)); | ||
| 107 | } | ||
| 108 | |||
| 109 | =head2 $t->minsize() | ||
| 110 | |||
| 111 | Returns the minimum size this table can be. If it is smaller than this, then the table | ||
| 112 | must be bad and should be deleted or whatever. | ||
| 113 | |||
| 114 | =cut | ||
| 115 | |||
| 116 | sub minsize | ||
| 117 | { | ||
| 118 | return 54; | ||
| 119 | } | ||
| 120 | |||
| 121 | 1; | ||
| 122 | |||
| 123 | =head1 BUGS | ||
| 124 | |||
| 125 | None known | ||
| 126 | |||
| 127 | =head1 AUTHOR | ||
| 128 | |||
| 129 | Martin Hosken L<http://scripts.sil.org/FontUtils>. | ||
| 130 | |||
| 131 | |||
| 132 | =head1 LICENSING | ||
| 133 | |||
| 134 | Copyright (c) 1998-2016, SIL International (http://www.sil.org) | ||
| 135 | |||
| 136 | This module is released under the terms of the Artistic License 2.0. | ||
| 137 | For details, see the full text of the license in the file LICENSE. | ||
| 138 | |||
| 139 | |||
| 140 | |||
| 141 | =cut | ||
| 142 | |||
| 143 |