Re: [AD] truecolor fonts

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Milan Mimica wrote:

Attached is my attemp to fix this. It allows merging 8-bit and truecolor

Doh!!! Just ignore this big fat patch. It doesn't work at all. I'm sorry.

In addition, it is possible to upgrade/adapt the first font to the second one, allegro will figure out what to do. Right now, passing mono font as the first argument and color font as the second would return NULL, notwithstanding what docs say.

Still, here is the patch to fix this. It should be safe.


--
Milan Mimica
http://sparklet.sf.net
diff -u3pr allegro-4.2.0-old/src/font.c allegro-4.2.0/src/font.c
--- allegro-4.2.0-old/src/font.c	2005-09-02 01:32:58.000000000 +0200
+++ allegro-4.2.0/src/font.c	2005-09-02 19:06:34.000000000 +0200
@@ -1252,14 +1252,24 @@ static FONT *color_merge_fonts(FONT *fon
 {
    FONT *fontout = NULL, *font2_upgr = NULL;
    FONT_COLOR_DATA *cf, *cf1, *cf2;
-   
+
    if (!font1 || !font2)
       return NULL;
-      
+
+   /* We adapt the second font to the first one so swap fonts if needed. */
+   if (is_mono_font(font1)) {
+      FONT *tmp;
+
+      if (is_mono_font(font2))
+         return NULL;
+
+      /* swap */
+      tmp = font1;
+      font1 = font2;
+      font2 = tmp;
+   }
+
    /* Promote font 2 to colour if it is a monochrome font */
-   if (!is_color_font(font1))
-      return NULL;
-   
    if (is_mono_font(font2)) {
       font2_upgr = upgrade_to_color(font2);
       /* Couldn't update font */
@@ -1277,7 +1287,7 @@ static FONT *color_merge_fonts(FONT *fon
    fontout->height = MAX(font1->height, font2->height);
    fontout->vtable = font1->vtable;
    cf = fontout->data = NULL;
-   
+
    cf1 = font1->data;
    cf2 = font2_upgr->data;
    while (cf1 || cf2) {


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/