view dmtext.h @ 75:e6535609c161

Initial implementation of loading and saving of bitmap fonts.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 02 Oct 2012 05:51:08 +0300
parents 03375aa0ef2b
children b10884934aca
line wrap: on
line source

/*
 * DMLib
 * -- Bitmap font support
 * Programmed and designed by Matti 'ccr' Hamalainen
 * (C) Copyright 2012 Tecnic Software productions (TNSP)
 */
#ifndef DMFONT_H
#define DMFONT_H

#include "dmlib.h"
#include "dmres.h"

#ifdef DM_GFX_TTF_TEXT
#include <SDL_ttf.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

/* Bitmapped fonts and text
 */
#ifdef DM_GFX_BM_TEXT

#define DMFONT_MAGIC    "DMFONT"
#define DMFONT_VERSION  0x0100

typedef struct
{
    int width, height;

    int nglyphs;
    SDL_Surface **glyphs;
} DMBitmapFont;


DMBitmapFont *dmNewBitmapFont(int nglyphs);
int dmFreeBitmapFont(DMBitmapFont *font);
int dmLoadBitmapFont(DMResource *res, DMBitmapFont **pfont);
int dmSaveBitmapFont(DMResource *res, DMBitmapFont *font);
int dmCreateBitmapFontFromImage(SDL_Surface *image, int width, int height, DMBitmapFont **pfont);

void dmDrawBMTextConst(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *str);
void dmDrawBMTextVA(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt, va_list ap);
void dmDrawBMText(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt, ...);
#endif


/* TTF text drawing
 */
#ifdef DM_GFX_TTF_TEXT
void       dmDrawTTFTextConst(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int x, int y, const char *fmt);
void       dmDrawTTFTextVA(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int x, int y, const char *fmt, va_list ap);
void       dmDrawTTFText(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int x, int y, const char *fmt, ...);
#endif


#ifdef __cplusplus
}
#endif

#endif // DMFONT_H