changeset 63:3d9da937db69

More work on the text support.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 01 Oct 2012 10:42:56 +0300
parents daeb5d4f6bad
children ad1ef3f0d474
files config.mak.in dmtext.c dmtext.h
diffstat 3 files changed, 15 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/config.mak.in	Mon Oct 01 09:50:43 2012 +0300
+++ b/config.mak.in	Mon Oct 01 10:42:56 2012 +0300
@@ -18,6 +18,7 @@
 DMRES_MEMIO=yes
 
 
+DM_GFX_BM_TEXT=yes
 DM_GFX_TTF_TEXT=yes
 DM_GFX_LINES=no
 DM_GFX_BLITS=yes
--- a/dmtext.c	Mon Oct 01 09:50:43 2012 +0300
+++ b/dmtext.c	Mon Oct 01 10:42:56 2012 +0300
@@ -8,14 +8,14 @@
 
 #ifdef DM_GFX_TTF_TEXT
 
-void dmDrawTTFTextConst(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int x, int y, const char *fmt)
+void dmDrawTTFTextConst(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int xc, int yc, const char *fmt)
 {
     SDL_Surface *text = TTF_RenderText_Blended(font, fmt, col);
     if (text)
     {
         SDL_Rect rect;
-        rect.x = x;
-        rect.y = y;
+        rect.x = xc;
+        rect.y = yc;
         rect.w = text->w;
         rect.h = text->h;
         SDL_BlitSurface(text, NULL, screen, &rect);
@@ -23,22 +23,22 @@
     }
 }
 
-void dmDrawTTFTextVA(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int x, int y, const char *fmt, va_list ap)
+void dmDrawTTFTextVA(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int xc, int yc, const char *fmt, va_list ap)
 {
     char *tmp = dm_strdup_vprintf(fmt, ap);
     if (tmp != NULL)
     {
-        dmDrawTTFTextConst(screen, font, col, x, y, tmp);
+        dmDrawTTFTextConst(screen, font, col, xc, yc, tmp);
         dmFree(tmp);
     }
 }
 
-void dmDrawTTFText(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int x, int y, const char *fmt, ...)
+void dmDrawTTFText(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int xc, int yc, const char *fmt, ...)
 {
     va_list ap;
     
     va_start(ap, fmt);
-    dmDrawTTFTextVA(screen, font, col, x, y, fmt, ap);
+    dmDrawTTFTextVA(screen, font, col, xc, yc, fmt, ap);
     va_end(ap);
 }
 
@@ -49,7 +49,7 @@
 void dmDrawBMTextConst(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt)
 {
     const char *ptr = fmt;
-    DMScaledBlitFunc *blit = dmGetScaledBlitFunc(screen, font->glyphs[0], mode);
+    DMScaledBlitFunc blit = dmGetScaledBlitFunc(screen->format, font->glyphs[0]->format, mode);
     while (*ptr)
     {
         char ch = *ptr++;
@@ -57,8 +57,8 @@
         if (isprint(ch) && ch != ' ' && ch != '\t')
         {
             SDL_Surface *glyph = font->glyphs[(unsigned char) ch];
-            blit(glyph, xc, yc, glyph->width, glyph->height, screen);
-            xc += glyph->width;
+            blit(glyph, xc, yc, glyph->w, glyph->h, screen);
+            xc += glyph->w;
         }
         else
             xc += font->width;
@@ -71,7 +71,7 @@
     char *tmp = dm_strdup_vprintf(fmt, ap);
     if (tmp != NULL)
     {
-        dmDrawBMTextConst(screen, font, col, x, y, tmp);
+        dmDrawBMTextConst(screen, font, mode, xc, yc, tmp);
         dmFree(tmp);
     }
 }
@@ -82,7 +82,7 @@
     va_list ap;
     
     va_start(ap, fmt);
-    dmDrawBMTextVA(screen, font, col, x, y, fmt, ap);
+    dmDrawBMTextVA(screen, font, mode, xc, yc, fmt, ap);
     va_end(ap);
 }
 
--- a/dmtext.h	Mon Oct 01 09:50:43 2012 +0300
+++ b/dmtext.h	Mon Oct 01 10:42:56 2012 +0300
@@ -20,6 +20,7 @@
 
 /* Bitmapped fonts and text
  */
+#ifdef DM_GFX_BM_TEXT
 typedef struct
 {
     int width, height;
@@ -34,6 +35,7 @@
 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