Browse Source

* Slightly changed the font header information. No one distributes libcaca

fonts yet anyway :-)
tags/v0.99.beta14
Sam Hocevar sam 18 years ago
parent
commit
4fa891b61b
4 changed files with 3180 additions and 3180 deletions
  1. +7
    -7
      cucul/font.c
  2. +1566
    -1566
      cucul/font_mono9.h
  3. +1601
    -1601
      cucul/font_monobold12.h
  4. +6
    -6
      tools/makefont.c

+ 7
- 7
cucul/font.c View File

@@ -156,7 +156,7 @@ cucul_font_t *cucul_load_font(void const *data, unsigned int size)

f->private = (void *)(uintptr_t)data;

memcpy(&f->header, f->private + 8, sizeof(struct font_header));
memcpy(&f->header, f->private + 4, sizeof(struct font_header));
f->header.control_size = hton32(f->header.control_size);
f->header.data_size = hton32(f->header.data_size);
f->header.version = hton16(f->header.version);
@@ -167,7 +167,7 @@ cucul_font_t *cucul_load_font(void const *data, unsigned int size)
f->header.height = hton16(f->header.height);
f->header.flags = hton16(f->header.flags);

if(size != 8 + f->header.control_size + f->header.data_size
if(size != 4 + f->header.control_size + f->header.data_size
|| (f->header.bpp != 8 && f->header.bpp != 4 &&
f->header.bpp != 2 && f->header.bpp != 1)
|| (f->header.flags & 1) == 0)
@@ -202,7 +202,7 @@ cucul_font_t *cucul_load_font(void const *data, unsigned int size)
}

memcpy(f->block_list,
f->private + 8 + sizeof(struct font_header),
f->private + 4 + sizeof(struct font_header),
f->header.blocks * sizeof(struct block_info));
for(i = 0; i < f->header.blocks; i++)
{
@@ -243,7 +243,7 @@ cucul_font_t *cucul_load_font(void const *data, unsigned int size)
}

memcpy(f->glyph_list,
f->private + 8 + sizeof(struct font_header)
f->private + 4 + sizeof(struct font_header)
+ f->header.blocks * sizeof(struct block_info),
f->header.glyphs * sizeof(struct glyph_info));
for(i = 0; i < f->header.glyphs; i++)
@@ -268,7 +268,7 @@ cucul_font_t *cucul_load_font(void const *data, unsigned int size)
}
}

f->font_data = f->private + 8 + f->header.control_size;
f->font_data = f->private + 4 + f->header.control_size;

return f;
}
@@ -501,8 +501,8 @@ int cucul_render_canvas(cucul_canvas_t *cv, cucul_font_t *f,
*
* struct
* {
* uint8_t caca_header[4]; // "CACA"
* uint8_t caca_file_type[4]; // "FONT"
* uint8_t caca_header[2]; // "\xCA\xCA"
* uint8_t caca_file_type[2]; // "FT"
*
* font_header:
* uint32_t control_size; // Control size (font_data - font_header)


+ 1566
- 1566
cucul/font_mono9.h
File diff suppressed because it is too large
View File


+ 1601
- 1601
cucul/font_monobold12.h
File diff suppressed because it is too large
View File


+ 6
- 6
tools/makefont.c View File

@@ -171,20 +171,20 @@ int main(int argc, char *argv[])
printf("\n");

printf("static unsigned int const %s_size = %i;\n",
prefix, 8 + control_size + data_size);
prefix, 4 + control_size + data_size);
printf("static struct {\n");
printf("char ");
for(i = 0; (i + 1) * STRING_CHUNKS < 8 + control_size + data_size; i++)
printf("d%x[%i],%c", i, STRING_CHUNKS, (i % 6) == 5 ? '\n' : ' ');
printf("d%x[%i];\n", i, 8 + control_size + data_size - i * STRING_CHUNKS);
printf("d%x[%i];\n", i, 4 + control_size + data_size - i * STRING_CHUNKS);
printf("} %s_data = {\n", prefix);
printf("\n");

printf("/* file: */\n");
printf("\"CACA\" /* caca_header */\n");
written += 4;
printf("\"FONT\" /* caca_file_type */\n");
written += 4;
printf("\"\\xCA\\xCA\" /* caca_header */\n");
written += 2;
printf("\"FT\" /* caca_file_type */\n");
written += 2;
printf("\n");

printf("/* font_header: */\n");


Loading…
Cancel
Save