annotate dmtext.h @ 89:b10884934aca

Various improvements in bitmapped font support, and addition of legacy TSFONT loading support (untested as of now).
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 02 Oct 2012 15:52:44 +0300
parents e6535609c161
children e1e308167991
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
60
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * DMLib
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 * -- Bitmap font support
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 * Programmed and designed by Matti 'ccr' Hamalainen
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 * (C) Copyright 2012 Tecnic Software productions (TNSP)
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 */
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 #ifndef DMFONT_H
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 #define DMFONT_H
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 #include "dmlib.h"
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 #include "dmres.h"
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 #ifdef DM_GFX_TTF_TEXT
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 #include <SDL_ttf.h>
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 #endif
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 #ifdef __cplusplus
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 extern "C" {
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 #endif
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 /* Bitmapped fonts and text
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 */
63
3d9da937db69 More work on the text support.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
23 #ifdef DM_GFX_BM_TEXT
75
e6535609c161 Initial implementation of loading and saving of bitmap fonts.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
24
89
b10884934aca Various improvements in bitmapped font support, and addition of legacy
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
25 // DMFONT format constants
b10884934aca Various improvements in bitmapped font support, and addition of legacy
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
26 #define DMFONT_MAGIC "DMFONT"
b10884934aca Various improvements in bitmapped font support, and addition of legacy
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
27 #define DMFONT_VERSION 0x0100
b10884934aca Various improvements in bitmapped font support, and addition of legacy
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
28
b10884934aca Various improvements in bitmapped font support, and addition of legacy
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
29 #define DMFONT_MIN_WIDTH 3
b10884934aca Various improvements in bitmapped font support, and addition of legacy
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
30 #define DMFONT_MIN_HEIGHT 3
b10884934aca Various improvements in bitmapped font support, and addition of legacy
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
31 #define DMFONT_MAX_WIDTH 128
b10884934aca Various improvements in bitmapped font support, and addition of legacy
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
32 #define DMFONT_MAX_HEIGHT 128
b10884934aca Various improvements in bitmapped font support, and addition of legacy
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
33 #define DMFONT_MAX_GLYPHS 1024
b10884934aca Various improvements in bitmapped font support, and addition of legacy
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
34
b10884934aca Various improvements in bitmapped font support, and addition of legacy
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
35 // Legacy TSFONT loading support
b10884934aca Various improvements in bitmapped font support, and addition of legacy
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
36 #define TSFONT_MAGIC "TSFONT"
b10884934aca Various improvements in bitmapped font support, and addition of legacy
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
37 #define TSFONT_VERSION 0x0205
b10884934aca Various improvements in bitmapped font support, and addition of legacy
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
38
75
e6535609c161 Initial implementation of loading and saving of bitmap fonts.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
39
60
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 typedef struct
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 {
89
b10884934aca Various improvements in bitmapped font support, and addition of legacy
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
42 int width, height; // Dimensions
b10884934aca Various improvements in bitmapped font support, and addition of legacy
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
43 int nglyphs; // Size of glyphs array
b10884934aca Various improvements in bitmapped font support, and addition of legacy
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
44 SDL_Surface **glyphs; // NOTE! Not all glyphs may be allocated
60
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 } DMBitmapFont;
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47
89
b10884934aca Various improvements in bitmapped font support, and addition of legacy
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
48 DMBitmapFont *dmNewBitmapFont(int nglyphs, int width, int height);
65
03375aa0ef2b Implement some new functions for bitmapped font handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
49 int dmFreeBitmapFont(DMBitmapFont *font);
03375aa0ef2b Implement some new functions for bitmapped font handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
50 int dmLoadBitmapFont(DMResource *res, DMBitmapFont **pfont);
75
e6535609c161 Initial implementation of loading and saving of bitmap fonts.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
51 int dmSaveBitmapFont(DMResource *res, DMBitmapFont *font);
65
03375aa0ef2b Implement some new functions for bitmapped font handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
52 int dmCreateBitmapFontFromImage(SDL_Surface *image, int width, int height, DMBitmapFont **pfont);
60
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 void dmDrawBMTextConst(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *str);
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 void dmDrawBMTextVA(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt, va_list ap);
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 void dmDrawBMText(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt, ...);
63
3d9da937db69 More work on the text support.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
57 #endif
60
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 /* TTF text drawing
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 */
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 #ifdef DM_GFX_TTF_TEXT
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 void dmDrawTTFTextConst(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int x, int y, const char *fmt);
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 void dmDrawTTFTextVA(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int x, int y, const char *fmt, va_list ap);
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 void dmDrawTTFText(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int x, int y, const char *fmt, ...);
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 #endif
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 #ifdef __cplusplus
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 }
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 #endif
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72
f28cd66356f6 Initial work for bitmapped fonts and text drawing. Also moved TTF header
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 #endif // DMFONT_H