13 unsigned int offset : 20;
14 unsigned int count : 12;
17static struct glyph *glyphs;
18static int glyphs_alloc;
20static unsigned char *xcoords, *ycoords;
21static int coords_offset;
22static int coords_alloc;
24static int fontmap[1024];
27static char current_font[16];
28static int font_loaded;
30static struct glyph *glyph_slot(
int idx)
32 if (glyphs_alloc <= idx) {
33 int new_alloc = idx + ((glyphs_alloc > 0) ? 1000 : 4000);
36 memset(&glyphs[glyphs_alloc], 0,
37 (
new_alloc - glyphs_alloc) *
sizeof(
struct glyph));
44static int coord_slots(
int count)
48 if (coords_alloc < coords_offset + count) {
50 coords_offset +
count + ((coords_alloc > 0) ? 10000 : 60000);
51 xcoords =
G_realloc(xcoords, coords_alloc);
52 ycoords =
G_realloc(ycoords, coords_alloc);
56 coords_offset +=
count;
61static void read_hersh(
const char *filename)
72 unsigned int i, idx,
count;
75 switch (c =
fgetc(fp)) {
86 if (
fread(buf, 1, 5, fp) != 5)
92 if (
fread(buf, 1, 3, fp) != 3)
98 glyph = glyph_slot(idx);
99 coords = coord_slots(count);
102 glyph->count =
count;
104 for (i = 0; i <
count; i++) {
105 if ((i + 4) % 36 == 0) {
107 if (
fgetc(fp) ==
'\r')
115 if (
fgetc(fp) ==
'\r')
122static void load_glyphs(
void)
129 for (i = 1; i <= 4; i++) {
137static void read_fontmap(
const char *
name)
143 memset(fontmap, 0,
sizeof(fontmap));
147 fp =
fopen(buf,
"r");
149 G_warning(
"Unable to open font map '%s': %s. "
150 "Try running 'g.mkfontcap --overwrite'",
155 while (
fscanf(fp,
"%s", buf) == 1) {
158 if (
sscanf(buf,
"%d-%d", &a, &
b) == 2)
160 fontmap[num_chars++] = a++;
161 else if (
sscanf(buf,
"%d", &a) == 1)
162 fontmap[num_chars++] = a;
168static void load_font(
void)
176 read_fontmap(current_font);
187 sizeof(current_font)) {
210 glyph = &glyphs[fontmap[i]];
213 *
X = &xcoords[glyph->offset];
214 *
Y = &ycoords[glyph->offset];
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_warning(const char *,...) __attribute__((format(printf
const char * G_gisbase(void)
Get full path name of the top level module directory.
size_t G_strlcpy(char *, const char *, size_t)
Safe string copy function.
Header file for msvc/fcntl.c.
int get_char_vects(unsigned char achar, int *n, unsigned char **X, unsigned char **Y)
int font_init(const char *name)