61 file = fopen(path,
"r");
66 printf(
"Error opening %s.\n", path);
71 fseek(file, 0, SEEK_END);
73 fseek(file, 0, SEEK_SET);
75 ini = (
char *)malloc(size);
79 printf(
"Error allocated %d bytes of memory.\n", size);
84 fread(ini, size, 1, file);
101 temp1 = strtok(temp0,
"=");
104 printf(
"Error parsing number of chars.\n");
107 temp0 += strlen(temp1)+1;
109 font->totalchars = (int)strtol(temp0,NULL,10);
111 temp1 = strtok(temp0,
"=");
114 printf(
"Error parsing space width.\n");
117 temp0 += strlen(temp1)+1;
119 font->spacewidth = (int)strtol(temp0,NULL,10);
121 font->charmap = (
unsigned short*)malloc(
sizeof(
short)*font->totalchars);
123 if (font->charmap == NULL)
127 printf(
"Error allocated %d bytes of memory.\n",
sizeof(
short)*font->totalchars);
133 memset(font->charmap,0,
sizeof(
short)*font->totalchars);
137 if (font->chardata == NULL)
140 printf(
"Error allocating %d bytes of memory.\n",
sizeof(
inidata_t)*font->totalchars);
147 memset(font->chardata,0,
sizeof(
inidata_t)*font->totalchars);
149 for (i = 0; i < font->totalchars; i++)
152 temp1 = strtok(temp0,
"=");
156 printf(
"Error parsing Char for char %d.\n", i);
158 free(font->chardata);
162 temp0 += strlen(temp1)+1;
163 font->charmap[i] = (int)strtol(temp0,NULL,10);
165 temp1 = strtok(temp0,
"=");
169 printf(
"Error parsing A for char %d.\n", i);
171 free(font->chardata);
175 temp0 += strlen(temp1)+1;
176 font->chardata[i].A = (int)strtol(temp0,NULL,10);
178 temp1 = strtok(temp0,
"=");
182 printf(
"Error parsing B for char %d.\n", i);
184 free(font->chardata);
188 temp0 += strlen(temp1)+1;
189 font->chardata[i].B = (int)strtol(temp0,NULL,10);
191 temp1 = strtok(temp0,
"=");
195 printf(
"Error parsing C for char %d.\n", i);
197 free(font->chardata);
201 temp0 += strlen(temp1)+1;
202 font->chardata[i].C = (int)strtol(temp0,NULL,10);
204 temp1 = strtok(temp0,
"=");
208 printf(
"Error parsing ox for char %d.\n", i);
210 free(font->chardata);
214 temp0 += strlen(temp1)+1;
215 font->chardata[i].ox = (int)strtol(temp0,NULL,10);
217 temp1 = strtok(temp0,
"=");
221 printf(
"Error parsing oy for char %d.\n", i);
223 free(font->chardata);
227 temp0 += strlen(temp1)+1;
228 font->chardata[i].oy = (int)strtol(temp0,NULL,10);
230 temp1 = strtok(temp0,
"=");
234 printf(
"Error parsing Wid for char %d.\n", i);
236 free(font->chardata);
240 temp0 += strlen(temp1)+1;
241 font->chardata[i].width = (int)strtol(temp0,NULL,10);
243 temp1 = strtok(temp0,
"=");
247 printf(
"Error parsing Hgt for char %d.\n", i);
249 free(font->chardata);
253 temp0 += strlen(temp1)+1;
254 font->chardata[i].height = (int)strtol(temp0,NULL,10);
256 temp1 = strtok(temp0,
"=");
260 printf(
"Error parsing X1 for char %d.\n", i);
262 free(font->chardata);
266 temp0 += strlen(temp1)+1;
267 font->chardata[i].u1 = ftoi4(((
float)(strtod(temp0,NULL) * tex_width)));
269 temp1 = strtok(temp0,
"=");
273 printf(
"Error parsing Y1 for char %d.\n", i);
275 free(font->chardata);
279 temp0 += strlen(temp1)+1;
280 font->chardata[i].v1 = ftoi4(((
float)(strtod(temp0,NULL) * tex_height)));
282 temp1 = strtok(temp0,
"=");
286 printf(
"Error parsing X2 for char %d.\n", i);
288 free(font->chardata);
292 temp0 += strlen(temp1)+1;
293 font->chardata[i].u2 = ftoi4(((
float)(strtod(temp0,NULL) * tex_width)));
295 temp1 = strtok(temp0,
"=");
299 printf(
"Error parsing Y2 for char %d.\n", i);
301 free(font->chardata);
305 temp0 += strlen(temp1)+1;
306 font->chardata[i].v2 = ftoi4(((
float)(strtod(temp0,NULL) * tex_height)));
449 q->dw[1] = GIF_SET_XYZ(x + (
int)((font->chardata[c].width*font->scale)*16.0f) + 32777,y + (
int)((font->chardata[c].height*font->scale)*16.0f) + 32777,v0->z);
461 unsigned short curchar = 0;
467 unsigned short utf8[2048];
469 memset(utf8,0,
sizeof(
short)*2048);
473 length = decode_unicode(str, utf8);
482 convert_to_index(utf8,length,font);
503 for (i = 0; i < length; i++)
506 while (utf8[i] == TAB || utf8[i] == NEWLINE)
508 if (utf8[i] == NEWLINE)
510 x_orig[line] = v_pos.x;
519 x_orig[line] = v_pos.x;
529 for (i = 0; i < length; i++)
532 while (utf8[i] == TAB || utf8[i] == NEWLINE || utf8[i] == SPACE)
534 if (utf8[i] == NEWLINE)
536 x_orig[line] = v_pos.x - line_num[line]*font->scale;
542 line_num[line] += font->spacewidth * 4;
544 if (utf8[i] == SPACE)
546 line_num[line] += font->spacewidth;
552 line_num[line] += font->chardata[curchar].A + font->chardata[curchar].B + font->chardata[curchar].C;
556 x_orig[line] = v_pos.x - line_num[line]*font->scale;
566 for (i = 0; i < length; i++)
569 while (utf8[i] == TAB || utf8[i] == NEWLINE || utf8[i] == SPACE)
571 if (utf8[i] == NEWLINE)
573 x_orig[line] = v_pos.x - (line_num[line]*font->scale)/2.0f;
579 line_num[line] += font->spacewidth * 4;
581 if (utf8[i] == SPACE)
583 line_num[line] += font->spacewidth;
589 line_num[line] += font->chardata[curchar].A + font->chardata[curchar].B + font->chardata[curchar].C;
593 x_orig[line] = v_pos.x - (line_num[line]*font->scale)/2.0f;
609 for (j = 0; j < length; j++)
612 while(utf8[j] == NEWLINE || utf8[j] == TAB || utf8[j] == SPACE)
614 if (utf8[j] == NEWLINE)
617 v_pos.y += font->height*font->scale;
618 v_pos.x = x_orig[line];
622 v_pos.x += font->spacewidth*font->scale * 4.0f;
624 if (utf8[j] == SPACE)
626 v_pos.x += font->spacewidth*font->scale;
631 v_pos.x += (font->chardata[utf8[j]].A*font->scale);
633 q = draw_fontstudio_char(q,utf8[j],&v_pos,font);
635 v_pos.x += (font->chardata[utf8[j]].B*font->scale) + (font->chardata[utf8[j]].C*font->scale);
qword_t * fontstudio_print_string(qword_t *q, int context, const unsigned char *string, int alignment, const vertex_t *v0, color_t *c0, fsfont_t *font)