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
|
/* pbmfont.h - header file for font routines in libpbm
*/
#include "pbm.h"
#ifdef __cplusplus
extern "C" {
#endif
#if 0
} /* to fake out automatic code indenters */
#endif
/* Maximum dimensions for fonts */
#define pbm_maxfontwidth() 65536
#define pbm_maxfontheight() 65536
/* These limits are not in the official Adobe BDF definition, but
should never be a problem for practical purposes, considering that
a 65536 x 65536 glyph occupies 4G pixels.
*/
typedef wchar_t PM_WCHAR;
/* Precaution to make adjustments, if necessary, for systems with
unique wchar_t.
*/
#define PM_FONT_MAXGLYPH 255
#define PM_FONT2_MAXGLYPH 65535
/* Upper limit of codepoint value.
This is large enough to handle Unicode Plane 0 (Basic Multilingual
Plane: BMP) which defines the great majority of characters used in
modern languages.
This can be set to a higher value at some cost to efficiency.
As of Unicode v. 11.0.0 planes up to 16 are defined.
*/
struct glyph {
/* A glyph consists of white borders and the "central glyph" which
can be anything, but normally does not have white borders because
it's more efficient to represent white borders explicitly.
*/
unsigned int width;
unsigned int height;
/* The dimensions of the central glyph, i.e. the 'bmap' array */
int x;
/* Width in pixels of the white left border of this glyph.
This can actually be negative to indicate that the central
glyph backs up over the previous character in the line. In
that case, if there is no previous character in the line, it
is as if 'x' is 0.
*/
int y;
/* Height in pixels of the white bottom border of this glyph.
Can be negative.
*/
unsigned int xadd;
/* Width of glyph -- white left border plus central glyph
plus white right border
*/
const char * bmap;
/* The raster of the central glyph. It is an 'width' by
'height' array in row major order, with each byte being 1
for black; 0 for white. E.g. if 'width' is 20 pixels and
'height' is 40 pixels and it's a rectangle that is black on
the top half and white on the bottom, this is an array of
800 bytes, with the first 400 having value 0x01 and the
last 400 having value 0x00.
*/
};
struct font {
/* This describes a combination of font and character set. Given
an code point in the range 0..255, this structure describes the
glyph for that character.
*/
unsigned int maxwidth, maxheight;
int x;
/* The minimum value of glyph.font. The left edge of the glyph
in the glyph set which advances furthest to the left. */
int y;
/* Amount of white space that should be added between lines of
this font. Can be negative.
*/
struct glyph * glyph[256];
/* glyph[i] is the glyph for code point i */
const bit ** oldfont;
/* for compatibility with old pbmtext routines */
/* oldfont is NULL if the font is BDF derived */
int fcols, frows;
};
struct font2 {
/* Font structure for expanded character set. Code point is in the
range 0..maxglyph .
*/
int maxwidth, maxheight;
int x;
/* The minimum value of glyph.font. The left edge of the glyph
in the glyph set which advances furthest to the left. */
int y;
/* Amount of white space that should be added between lines of
this font. Can be negative.
*/
struct glyph ** glyph;
/* glyph[i] is the glyph for code point i */
PM_WCHAR maxglyph;
/* max code point for glyphs, including vacant slots */
const bit ** oldfont;
/* for compatibility with old pbmtext routines */
/* oldfont is NULL if the font is BDF derived */
unsigned int fcols, frows;
};
struct font *
pbm_defaultfont(const char* const which);
struct font *
pbm_dissectfont(const bit ** const font,
unsigned int const frows,
unsigned int const fcols);
struct font *
pbm_loadfont(const char * const filename);
struct font *
pbm_loadpbmfont(const char * const filename);
struct font *
pbm_loadbdffont(const char * const filename);
struct font2 *
pbm_loadbdffont2(const char * const filename,
PM_WCHAR const maxglyph);
struct font2 *
pbm_expandbdffont(const struct font * const font);
void
pbm_dumpfont(struct font * const fontP,
FILE * const ofP);
extern struct font pbm_defaultFixedfont;
extern struct font pbm_defaultBdffont;
#ifdef __cplusplus
}
#endif
|