aboutsummaryrefslogtreecommitdiffstats
path: root/libparsepcf_preparse_font.3
blob: 0fce1667df3cb1cf2080f613e635f064930e8d17 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
.TH LIBPARSEPCF_PREPARSE_FONT 3 LIBPARSEPCF
.SH NAME
libparsepcf_preprase_font \- Get font data tables and metadata

.SH SYNOPSIS
.nf
#include <libparsepcf.h>

struct libparsepcf_font {
	const struct libparsepcf_table *\fIprob_table\fP;
	struct libparsepcf_properties \fIprops\fP;
	const struct libparsepcf_table *\fIaccel_table\fP;
	struct libparsepcf_accelerators \fIaccels\fP;
	const struct libparsepcf_table *\fImtx_table\fP;
	size_t \fImetrics\fP;
	const struct libparsepcf_table *\fIinkmtx_table\fP;
	size_t \fIink_metrics\fP;
	const struct libparsepcf_table *\fIenc_table\fP;
	struct libparsepcf_encoding \fIencoding\fP;
	const struct libparsepcf_table *\fIbitmap_table\fP;
	struct libparsepcf_bitmaps \fIbitmaps\fP;
	const struct libparsepcf_table *\fIswidth_table\fP;
	size_t \fIswidths\fP;
	const struct libparsepcf_table *\fIname_table\fP;
	struct libparsepcf_glyph_names \fInames\fP;
	size_t \fIglyph_count\fP;
	/* fields intended for internal use omitted */
};

int libparsepcf_preparse_font(const void *\fIdata\fP, size_t \fIsize\fP,
                              struct libparsepcf_font *\fIfont_out\fP);

int libparsepcf_destroy_preparsed_font(struct libparsepcf_font *\fIfont\fP);
.fi
.PP
Link with
.IR -lparsepcf .

.SH DESCRIPTION
PCF font files contain a set of tables for containing
different information about the font or its glyphs.
The
.BR libparsepcf_preparse_font ()
function can be used, as an alternative to the
.BR libparsepcf_get_tables (3)
function, the to locate and load the tables, making
it easy to use other functions to read the table's
subtables.
.PP
The
.I data
argument shall the font file content and the
.I size
argument shall be the size of the file in bytes.
.PP
If the font file contains a property table
.RI ( LIBPARSEPCF_PROPERTIES )
it will be stored in
.I font_out->prob_table
and the data retrieved by the
.BR libparsepcf_get_properties (3)
function for the
.BR libparsepcf_get_property_subtable (3)
function will be stored in
.IR font_out->probs ,
otherwise
.I font_out->prob_table
will be set to
.IR NULL .
.PP
If the font file contains an \(dqaccelerators\(dq
table
.RI ( LIBPARSEPCF_BDF_ACCELERATORS
(preferred) or
.I LIBPARSEPCF_ACCELERATORS
(fallback)) it will be stored in
.I font_out->accel_table
and the table will be loaded into
.IR font_out->accels ,
otherwise
.I font_out->accel_table
will be set to
.IR NULL .
Be sure to check that
.I font_out->accel_table
is
.RI non- NULL
before reading
.IR font_out->accels .
.PP
The glyph layout metrics table
.RI ( LIBPARSEPCF_METRICS ),
which can be parsed using the
.BR libparsepcf_get_metrics (3)
function, will be stored in
.I font_out->mtx_table
and the number of glyph in the table
will be stored in
.IR font_out->metrics .
.PP
If the font file contains a glyph ink metrics table
.RI ( LIBPARSEPCF_INK_METRICS ),
which can be parsed using the
.BR libparsepcf_get_metrics (3)
function, will be stored in
.I font_out->inkmtx_table
and the number of glyph in the table
will be stored in
.IR font_out->ink_metrics ,
otherwise
.I font_out->inkmtx_table
will be set to
.IR NULL .
.PP
The character-to-glyph table
.RI ( LIBPARSEPCF_BDF_ENCODINGS ),
which can be parsed using the
.BR libparsepcf_get_glyph_indices (3)
function, will be stored in
.I font_out->enc_table
and the data retrieved by the
.BR libparsepcf_get_encoding (3)
function for the
.BR libparsepcf_get_glyph_indices (3)
function will be stored in
.IR font_out->encoding .
.PP
If the font contains a bitmap talbe
.RI ( LIBPARSEPCF_BITMAPS ),
it will be stored in
.IR font_out->bitmap_table
and data load from the table, using the
.BR libparsepcf_get_bitmaps (3)
function will be stored
.IR font_out->bitmaps ,
otherwise
.I font_out->bitmap_table
will be set to
.IR NULL .
Unless
.I font_out->bitmaps
is set to
.IR NULL ,
the
.BR libparsepcf_get_bitmap_offsets (3)
function can be used to get the individual
bitmaps for each glyph.
.PP
If the font file contains a \(dqscaleable\(dq
width table
.RI ( LIBPARSEPCF_SWIDTHS ),
which can be parsed using the
.BR libparsepcf_get_swidths (3)
function, will be stored in
.I font_out->swidth_table
and the number of glyph in the table
will be stored in
.IR font_out->swidths ,
otherwise
.I font_out->swidth_table
will be set to
.IR NULL .
.PP
If the font file contains a PostScript
glyph name table
.RI ( LIBPARSEPCF_GLYPH_NAMES ),
which can be parsed using the
.BR libparsepcf_get_glyph_name_subtable (3)
function, will be stored in
.I font_out->name_table
and the data retrieved by the
.BR libparsepcf_get_glyph_names (3)
function for the
.BR libparsepcf_get_glyph_name_subtable (3)
function will be stored in
.IR font_out->names .
otherwise
.I font_out->name_table
will be set to
.IR NULL .
.PP
The function will ensure that all tables report the
same number of glyphs, and the number of glyphs will
be stored in
.IR font_out->glyph_count ,
but it may (if the corresponding table is found)
also be stored in
.IR font_out->metrics ,
.IR font_out->ink_metrics ,
.IR font_out->bitmaps.glyph_count ,
.IR font_out->names.glyph_count ,
and
.IR font_out->swidths .
.PP
If the font contains a property table, 
.PP
Once the font is not needed anymore, the
.BR libparsepcf_destroy_preparsed_font ()
function shall be used to deallocate the memory
stored in
.IR *font ,
it will also reset the contents of
.IR *font .

.SH RETURN VALUE
The
.BR libparsepcf_preparse_font ()
and
.BR libparsepcf_destroy_preparsed_font ()
functions return 0 upon successful completion.
On failure, -1 is returned and
.I errno
is set appropriately to indicate the error.

.SH ERRORS
The
.BR libparsepcf_preparse_font ()
and
.BR libparsepcf_destroy_preparsed_font ()
functions fail if:
.TP
.B EBFONT
The font file is corrupt or unsupported.

.SH NOTES
As the layout metrics shall be used if the
font file is missing the ink metrics table,
it may be a good idea, for the application
to set
.I font_out->inkmtx_table
to
.I font_out->mtx_table
and
.I font_out->ink_metrics
to
.I font_out->metrics
if
.I font_out->inkmtx_table
is
.IR NULL .
The
.BR libparsepcf_preparse_font ()
function does not automatically because
it may be useful for the application to
know whether the ink metrics and layout
metrics are identical.

.SH SEE ALSO
.BR libparsepcf (7)