22 if(code < 0x20)
return NULL;
23 for(i = 0; i < font->
count; i++) {
25 return font->
glyph[i];
47 if((dq == 0 && line[i] ==
' ') || line[i] == 0) {
51 args[argc] = line + incr;
52 if(args[argc][0] ==
'"') args[argc]++;
53 if(args[argc][strlen(args[argc]) - 1] ==
'"') args[argc][strlen(args[argc]) - 1] = 0;
60 }
else if(line[i] ==
'"') {
66 unsigned char* linebuf = store->
buffer + store->line_index * wid * 4;
67 for(i = 0; line[i] != 0; i++) {
70 if(
'0' <= line[i] && line[i] <=
'9') {
72 }
else if(
'a' <= line[i] && line[i] <=
'f') {
73 n = 10 + line[i] -
'a';
74 }
else if(
'A' <= line[i] && line[i] <=
'F') {
75 n = 10 + line[i] -
'A';
77 for(j = 0; j < (wid > 4 ? 4 : wid); j++) {
79 memset(linebuf + 16 * i + 4 * j, 255, 4);
86 }
else if(argc > 0 && strcmp(args[0],
"STARTCHAR") == 0) {
89 }
else if(argc > 0 && strcmp(args[0],
"ENDCHAR") == 0) {
93 store->line_index = -1;
94 }
else if(argc > 0 && strcmp(args[0],
"BITMAP") == 0) {
95 store->line_index = 0;
96 }
else if(argc == 2) {
97 if(strcmp(args[0],
"COPYRIGHT") == 0) {
99 }
else if(strcmp(args[0],
"NOTICE") == 0) {
101 }
else if(strcmp(args[0],
"FOUNDRY") == 0) {
103 }
else if(strcmp(args[0],
"CHARS") == 0) {
106 font->
count = atoi(args[1]);
108 for(j = 0; j < font->
count; j++) font->
glyph[j] = NULL;
109 }
else if(strcmp(args[0],
"ENCODING") == 0) {
112 }
else if(argc == 3) {
113 if(strcmp(args[0],
"DWIDTH") == 0) {
117 }
else if(argc == 5) {
118 if(strcmp(args[0],
"FONTBOUNDINGBOX") == 0) {
121 font->
bbox.
x = atoi(args[3]);
122 font->
bbox.
y = atoi(args[4]);
123 }
else if(strcmp(args[0],
"BBX") == 0) {
129 store->
buffer = malloc(atoi(args[1]) * atoi(args[2]) * 4);
130 memset(store->
buffer, 0, atoi(args[1]) * atoi(args[2]) * 4);
141 store.line_index = -1;
143 memset(font, 0,
sizeof(*font));
145 buf = malloc(size + 1);
147 memcpy(buf, data, size);
150 if(buf[i] == 0 || buf[i] ==
'\n') {
152 char* line = buf + incr;
156 gf_font_parse_line(draw, path, &store, font, line);
171 if(gf_stat(path, &s) != 0) {
174 gf_log_function(NULL,
"%s: %lu bytes", path, (
unsigned long)s.st_size);
175 buf = malloc(s.st_size + 1);
177 f = fopen(path,
"r");
178 fread(buf, s.st_size, 1, f);
181 font = gf_font_create_raw(draw, path, buf, s.st_size);
190 for(i = 0; i < font->
count; i++) {
#define gf_log_function(engine, fmt,...)
Output log with line number and function name.
Required headers before anything.
int dwidth[2]
Device width.
gf_font_bbox_t bbox
Bounding box.
gf_texture_t * texture
Texture.
Internal struct used for parsing.
int glyph_index
Current glyph index.
unsigned char * buffer
Glyph buffer.
gf_font_glyph_t ** glyph
Glyph data.
gf_font_bbox_t bbox
Bounding box.