[AD] Font type field added |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
This patch adds a 'type' field to the FONT structure. This allows
external programs to know if they should cast the vtable for color or
mono fonts, or something else even. I hope I didn't forget anything.
Also, font.h is obsolete and should be deleted. font.c now contains the
'font' definition.
--
- Robert J Ohannessian
diff -ubr \allegro/include/allegro.h allegro/include/allegro.h
--- \allegro/include/allegro.h Fri Dec 15 19:35:48 2000
+++ allegro/include/allegro.h Fri Dec 22 19:56:22 2000
@@ -1317,10 +1317,15 @@
struct FONT_VTABLE;
+#define FONT_TYPE_MONO AL_ID('M','o','n','o')
+#define FONT_TYPE_COLOR AL_ID('C','o','l','r')
+
+
typedef struct FONT
{
void* data;
int height;
+ int type;
struct FONT_VTABLE* vtable;
}FONT;
diff -ubr \allegro/src/datafile.c allegro/src/datafile.c
--- \allegro/src/datafile.c Sun Dec 3 19:13:36 2000
+++ allegro/src/datafile.c Fri Dec 22 20:32:44 2000
@@ -440,6 +440,7 @@
f->data = mf;
f->height = height;
+ f->type = FONT_TYPE_MONO;
f->vtable = font_vtable_mono;
mf->begin = ' ';
@@ -493,6 +494,7 @@
}
f->data = cf;
+ f->type = FONT_TYPE_COLOR;
f->vtable = font_vtable_color;
cf->begin = ' ';
@@ -665,6 +667,7 @@
FONT_MONO_DATA* mf = 0, * iter = (FONT_MONO_DATA*) f->data;
f->vtable = font_vtable_mono;
+ f->type = FONT_TYPE_MONO;
mf = read_font_mono(pack, &height);
if(!mf) {
@@ -680,6 +683,7 @@
} else {
FONT_COLOR_DATA* cf = 0, * iter = (FONT_COLOR_DATA*) f->data;
+ f->type = FONT_TYPE_COLOR;
f->vtable = font_vtable_color;
@@ -2033,7 +2037,7 @@
case DAT_FONT:
f = data[c].dat;
- if(f->vtable == font_vtable_color) {
+ if(f->type == FONT_TYPE_COLOR) {
FONT_COLOR_DATA* cf = (FONT_COLOR_DATA*) f->data;
while(cf) {
for(c2 = cf->begin; c2 < cf->end; c2++) cf->bitmaps[c2 - cf->begin]->seg = _default_ds();
diff -ubr \allegro/src/font.c allegro/src/font.c
--- \allegro/src/font.c Sun Dec 3 19:13:36 2000
+++ allegro/src/font.c Fri Dec 22 19:58:22 2000
@@ -674,6 +674,7 @@
FONT _default_font = {
&ascii_monofont, /* first lot of data */
8, /* height */
+ FONT_TYPE_MONO, /* type */
&_font_vtable_mono /* vtable */
};