writer_writeString(w, font->id);
writer_writeU32(w, font->num_glyphs);
writer_writeU32(w, font->max_unicode);
+ writer_writeDouble(w, font->ascent);
+ writer_writeDouble(w, font->descent);
int t;
for(t=0;t<font->num_glyphs;t++) {
dumpLine(w, font->glyphs[t].line);
for(t=0;t<font->max_unicode;t++) {
writer_writeU32(w, font->unicode2glyph[t]);
}
+ writer_writeU32(w, font->kerning_size);
+ for(t=0;t<font->kerning_size;t++) {
+ writer_writeU32(w, font->kerning[t].c1);
+ writer_writeU32(w, font->kerning[t].c2);
+ writer_writeU32(w, font->kerning[t].advance);
+ }
}
static gfxfont_t*readFont(reader_t*r)
{
font->id = reader_readString(r);
font->num_glyphs = reader_readU32(r);
font->max_unicode = reader_readU32(r);
+ font->ascent = reader_readDouble(r);
+ font->descent = reader_readDouble(r);
font->glyphs = (gfxglyph_t*)rfx_calloc(sizeof(gfxglyph_t)*font->num_glyphs);
font->unicode2glyph = (int*)rfx_calloc(sizeof(font->unicode2glyph[0])*font->max_unicode);
int t;
for(t=0;t<font->max_unicode;t++) {
font->unicode2glyph[t] = reader_readU32(r);
}
+ font->kerning_size = reader_readU32(r);
+ if(font->kerning_size) {
+ font->kerning = malloc(sizeof(gfxkerning_t)*font->kerning_size);
+ for(t=0;t<font->kerning_size;t++) {
+ font->kerning[t].c1 = reader_readU32(r);
+ font->kerning[t].c2 = reader_readU32(r);
+ font->kerning[t].advance = reader_readU32(r);
+ }
+ }
return font;
}