# HG changeset patch # User Matti Hamalainen # Date 1349088167 -10800 # Node ID a791146e309484a29ef33d9e15af6a1fabea12d6 # Parent 7b97df6f8a97774f532a5a0af52801010c6c6e9f Make BM text work, a bit at least. diff -r 7b97df6f8a97 -r a791146e3094 dmtext_bm.c --- a/dmtext_bm.c Mon Oct 01 13:42:20 2012 +0300 +++ b/dmtext_bm.c Mon Oct 01 13:42:47 2012 +0300 @@ -11,13 +11,33 @@ { const char *ptr = fmt; DMScaledBlitFunc blit = dmGetScaledBlitFunc(font->glyphs[0]->format, screen->format, mode); + while (*ptr) { - char ch = *ptr++; + SDL_Surface *glyph; + int pos; + int ch = *ptr++; - if (isprint(ch) && ch != ' ' && ch != '\t') + if (ch == 'ยง') { - SDL_Surface *glyph = font->glyphs[(unsigned char) ch]; + xc += 15; + continue; + } + else + if (ch >= 'A' && ch <= 'Z') + pos = ch - 'A' + 256 + 1; + else + if (ch >= 'a' && ch <= 'z') + pos = ch - 'a' + 1; + else + if (ch >= '0' && ch <= '9') + pos = ch - '0' + 48; + else + pos = ch; + + if (pos >= 0 && pos < font->nglyphs) + { + glyph = font->glyphs[pos]; blit(glyph, xc, yc, glyph->w, glyph->h, screen); xc += glyph->w; } @@ -104,6 +124,11 @@ font->width = width; font->height = height; + + fprintf(stderr, "%d x %d split as %d x %d blocks => %d x %d = %d glyphs\n", + image->w, image->h, + width, height, + xglyphs, yglyphs, xglyphs * yglyphs); glyph = 0; for (yc = 0; yc < yglyphs; yc++) @@ -121,6 +146,14 @@ dmFreeBitmapFont(font); return DMERR_MALLOC; } + + SDL_Rect r; + r.x = xc * width; + r.y = yc * height; + r.w = width; + r.h = height; + + SDL_BlitSurface(image, &r, bmp, NULL); font->glyphs[glyph++] = bmp; }