# HG changeset patch # User Matti Hamalainen # Date 1349090315 -10800 # Node ID 295d08376744b305b7f16c13b178566f9fbf8783 # Parent be616098142861337938ab3aa412248abe997bc8 Add function for saving a bitmap font. diff -r be6160981428 -r 295d08376744 dmtext_bm.c --- a/dmtext_bm.c Mon Oct 01 14:17:47 2012 +0300 +++ b/dmtext_bm.c Mon Oct 01 14:18:35 2012 +0300 @@ -5,6 +5,7 @@ * (C) Copyright 2012 Tecnic Software productions (TNSP) */ #include "dmtext.h" +#include "dmresw.h" void dmDrawBMTextConst(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt) @@ -161,3 +162,25 @@ *pfont = font; return DMERR_OK; } + +int dmSaveBitmapFont(DMResource *res, DMBitmapFont *font) +{ + int i; + + dmf_write_str(res, (Uint8 *) "DMFONT", 6); + dmf_write_le16(res, 0x0100); + dmf_write_le32(res, font->width); + dmf_write_le32(res, font->height); + dmf_write_le32(res, font->nglyphs); + + for (i = 0; i < font->nglyphs; i++) + { + SDL_Surface *glyph = font->glyphs[i]; + dmf_write_le32(res, glyph->w); + dmf_write_le32(res, glyph->h); + dmf_write_le32(res, glyph->pitch); + dmf_write_str(res, glyph->pixels, glyph->h * glyph->pitch); + } + + return DMERR_OK; +}