From e6dc945aaa53b0739148b5ba4ebf7f8870e64370 Mon Sep 17 00:00:00 2001 From: pixel Date: Sat, 21 Dec 2002 12:39:15 +0000 Subject: Commit of the day. --- lib/glfont.cc | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/glfont.cc b/lib/glfont.cc index 91d70ba..3d254d3 100644 --- a/lib/glfont.cc +++ b/lib/glfont.cc @@ -19,8 +19,10 @@ off|siz|description 2 | 1 | Flags 3 | 1 | maxX (maximum width) 4 | 1 | maxY (maximum height) - 5 | X | char entries -5+X| Y | char map + 5 | 1 | base (bottom line from top) + 6 | 1 | inter (size of the interline) + 7 | X | char entries +7+X| Y | char map X = (maxX * maxY + 1) * nbentries Y = nbentries * 4 @@ -76,12 +78,12 @@ nbT = number of textures mogltk::font::font(Handle * ffont) : textcolor(255, 255, 255, 255) { int i; - ffont->SetZ(); - ffont->read(&nbentries, 2); ffont->read(&flags, 1); ffont->read(&maxX, 1); ffont->read(&maxY, 1); + ffont->read(&base, 1); + ffont->read(&inter, 1); nbcU = 256 / maxX; nbcV = 256 / maxY; @@ -133,9 +135,9 @@ mogltk::font::font(Handle * ffont) : textcolor(255, 255, 255, 255) { } } } - if ((curU += maxX) >= 256) { + if (((curU += maxX) + maxX) >= 256) { curU = 0; - if ((curV += maxY) >= 256) { + if (((curV += maxY) + maxY) >= 256) { curV = 0; if ((curT + 1) != nbT) curtex = (Uint8 *) fonttex[++curT]->GetSurface()->pixels; @@ -168,6 +170,17 @@ void mogltk::font::drawentry(Uint16 entry, int x, int y, Color c) { mogltk::glbase::Enter2DMode(); } + if (shadow) { + int os = shadow; + shadow = 0; + + drawentry(entry, x + os, y + os, BLACK); + + shadow = os; + } + + y -= base; + Bind(entry / nbcT); c.Bind(); trueentry = entry % nbcT; @@ -202,9 +215,21 @@ void mogltk::font::putentry(Uint16 entry, Color c) { cx += sizes[entry]; } +void mogltk::font::putchar(char ch, Color c) { + Uint16 * p; + int i; + + for (i = 0, p = corresp; i < nbentries; i++, p++) { + if (*(p++) == ch) { + putentry(*p, c); + return; + } + } +} + void mogltk::font::newline(void) { cx = ox; - cy += maxY; + cy += inter; } int mogltk::font::printf(const String & m, ...) { @@ -218,7 +243,11 @@ int mogltk::font::printf(const String & m, ...) { va_end(ap); for (p = buffer; *p; p++) { - putentry(*p, textcolor); + if (*p == '\n') { + newline(); + } else { + putchar(*p, textcolor); + } } return r; @@ -228,3 +257,6 @@ void mogltk::font::setcolor(Color c) { textcolor = c; } +void mogltk::font::setshadow(int s) { + shadow = s; +} -- cgit v1.2.3