aboutsummaryrefslogtreecommitdiffstats
path: root/libparsepcf_get_metrics.3
blob: 70bd6239d504cec49145761c220d36b9e208dcfb (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
.TH LIBPARSEPCF_GET_METRICS 3 LIBPARSEPCF
.SH NAME
libparsepcf_get_metrics \- Get glyph metrics

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

#define LIBPARSEPCF_METRICS     /* value omitted */
#define LIBPARSEPCF_INK_METRICS /* value omitted */

struct libparsepcf_metrics {
	int16_t \fIleft_side_bearing\fP;
	int16_t \fIright_side_bearing\fP;
	int16_t \fIcharacter_width\fP;
	int16_t \fIcharacter_ascent\fP;
	int16_t \fIcharacter_descent\fP;
	uint16_t \fIcharacter_attributes\fP;
};

int libparsepcf_get_metrics_count(const void *\fIdata\fP, size_t \fIsize\fP,
                                  const struct libparsepcf_table *\fItable\fP,
                                  size_t *\fIcount_out\fP);

int libparsepcf_get_metrics(const void *\fIdata\fP, size_t \fIsize\fP,
                            const struct libparsepcf_table *\fItable\fP,
                            struct libparsepcf_metrics *\fImetrics_out\fP,
                            size_t \fIfirst\fP, size_t \fIcount\fP);
.fi
.PP
Link with
.IR -lparsepcf .

.SH DESCRIPTION
In PCF font files, the layout metrics for each
glyph is recorded in a type with the tape
.BR LIBPARSEPCF_METRICS ,
which can be retrieved with the
.BR libparsepcf_get_tables (3)
function. The file may also contain the table
.B LIBPARSEPCF_INK_METRICS
for the ink metrics. If however no
.B LIBPARSEPCF_INK_METRICS
is present in the file, the
.B LIBPARSEPCF_METRICS
file be used for this purpose instead in
addition to layout metrics
.PP
Once the
.B LIBPARSEPCF_METRICS
or
.B LIBPARSEPCF_INK_METRICS
table has been identified, it can be passed as
the third argument
.RI ( table )
to the
.BR libparsepcf_get_metrics_count ()
function along with the font file contents in the
.I data
argument and size, in bytes, of the file in the
.I size
argument. The
.BR libparsepcf_get_metrics_count ()
function will store the number of available
glyphs in
.IR *count_out ,
which shall be used to check that all glyphs
have a metrics recorded.
.PP
Then the
.BR libparsepcf_get_metrics ()
function can be used to get the glyph metrics of
each glyph. The first three arguments shall be the
same as with
.BR libparsepcf_get_metrics_count ().
.I first
shall be the index of the glyph with the lowest index
of the glyph the function shall get the metrics for, and
.I count
shall be the number of consecutive glyphs
(including the first glyph) to get this information
for. For each queried glyph with index
.IR i ,
the metrics will be stored in
.IR metrics_out[i-first] .
.PP
The application shall ensure that
.IR "first + count <= *count_out" .
.PP
Note that glyph indices are not the same as character
codepoints. See
.BR libparsepcf_get_encoding (3)
for details about mapping characters to glyphs.
.PP
The glyph metrics consists of five fields:
.TP
.I left_side_bearing
The number of pixels right of (negative if left of)
the origin (caret position) of the leftmost ink-on
pixel in the glyph
.TP
.I right_side_bearing
The number of pixels right of (negative if left of)
the origin (caret position) of the rightmost ink-on
pixel in the glyph
.TP
.I character_width
The number of pixels the next characters origin shall
be right of the current character's origin (that is
the number of pixels the caret shall advance)
.TP
.I character_ascent
The number of pixels the character ascend above
the baseline (if non-positive, it's fully below
the baseline)
.TP
.I character_descent
The number of pixels the character descend below
the baseline (if non-positive, it's fully above
the baseline)
.PP
Along with the glyph metrics, each glyph may
also have an applications-specific attribute
store in the
.I character_attributes
field.

.SH RETURN VALUE
The
.BR libparsepcf_get_metrics_count ()
and
.BR libparsepcf_get_metrics ()
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_get_metrics_count ()
and
.BR libparsepcf_get_metrics ()
functions fail if:
.TP
.B EBFONT
The font file is corrupt or unsupported.

.SH SEE ALSO
.BR libparsepcf (7),
.BR libparsepcf_preparse_font (3)