diff dmtext_bm.c @ 132:b5569c84f00a

Add support for loading ancient version of TSFONTs.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 04 Oct 2012 15:43:10 +0300
parents 975725e3126d
children 67d2cba58a87
line wrap: on
line diff
--- a/dmtext_bm.c	Thu Oct 04 09:40:03 2012 +0300
+++ b/dmtext_bm.c	Thu Oct 04 15:43:10 2012 +0300
@@ -196,6 +196,10 @@
 
         if (version > TSFONT_VERSION)
             return DMERR_VERSION;
+
+#ifdef FN_DEBUG
+        fprintf(stderr, "TSFONT v%d.%d (0x%04x), encoding=%d\n", version >> 8, version & 0xff, version, encoding);
+#endif
         
         // There were only two encodings, 0 = none and 1 = RLE
         // of which RLE was never actually used ... derp.
@@ -229,10 +233,23 @@
     width = dmfgetc(res);
     height = dmfgetc(res);
 
+#ifdef FN_DEBUG
+    fprintf(stderr, "nglyphs=%d (0x%02x), width=%d, height=%d\n", nglyphs, nglyphs, width, height);
+#endif
+
     if (tsfont)
     {
         // TSFONT color assignments (boolean) .. we discard this.
         dmfgetc(res);
+        
+        // Very old TSFONTs have some extra data that is not used
+        // .. can't actually even remember what it was for.
+        if (version == 0x0200)
+        {
+            int i;
+            for (i = 0; i < 32; i++)
+                dmfgetc(res);
+        }
     }
 
     if (width < DMFONT_MIN_WIDTH ||
@@ -293,6 +310,10 @@
             width = dmfgetc(res);
             height = dmfgetc(res);
 
+#ifdef FN_DEBUG
+            fprintf(stderr, "#%d @ %d - w=%d, h=%d\n", i, index, width, height);
+#endif
+
             if (width < DMFONT_MIN_WIDTH ||
                 height < DMFONT_MIN_HEIGHT ||
                 width > DMFONT_MAX_WIDTH ||