Add demo application.
[bertos.git] / gfx / text_format.c
index 1b0e8a340571b976f160a7466807a7bb2ea1d500..54dab7c866e373e8c7a6d1c596237b50ace63aee 100755 (executable)
 
 /*#*
  *#* $Log$
+ *#* Revision 1.8  2006/03/22 09:50:11  bernie
+ *#* Don't use C99 stuff.
+ *#*
+ *#* Revision 1.7  2006/03/20 17:51:55  bernie
+ *#* Cleanups.
+ *#*
  *#* Revision 1.6  2006/03/13 02:05:54  bernie
  *#* Mark slow paths as UNLIKELY.
  *#*
@@ -199,8 +205,8 @@ int PGM_FUNC(text_xprintf)(struct Bitmap *bm,
 
 struct TextWidthData
 {
-               Bitmap *bitmap;
-               coord_t width;
+       Bitmap *bitmap;
+       coord_t width;
 };
 
 /**
@@ -222,9 +228,9 @@ static int text_charWidth(int c, struct TextWidthData *twd)
        coord_t glyph_width;
 
 
-       if (UNLIKELY(index < bm->font->first || index > bm->font->last))
+       if (UNLIKELY(!FONT_HAS_GLYPH(bm->font, index)))
        {
-               if ('?' >= bm->font->first && '?' <= bm->font->last)
+               if (!FONT_HAS_GLYPH(bm->font, '?'))
                        index = '?';
                else
                        index = bm->font->first;
@@ -264,7 +270,9 @@ int PGM_FUNC(text_vwidthf)(
                return PGM_FUNC(vsprintf)(NULL, fmt, ap) * bm->font->width;
        else
        {
-               struct TextWidthData twd = { bm, 0 };
+               struct TextWidthData twd;
+               twd.bitmap = bm;
+               twd.width = 0;
                _formatted_write(fmt, (void (*)(char, void *))text_charWidth, &twd, ap);
                return twd.width;
        }