aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorMax Horn2004-03-15 18:44:14 +0000
committerMax Horn2004-03-15 18:44:14 +0000
commit7410f041ee8bb18f1d8a6a5999b81ca202a1a38c (patch)
treeff197186d5bbb902d0de12316d8f7ecd8fda4bb8 /gui
parentd26f96e9ad405c9d55b40c10e0c2406f1f1bfca0 (diff)
downloadscummvm-rg350-7410f041ee8bb18f1d8a6a5999b81ca202a1a38c.tar.gz
scummvm-rg350-7410f041ee8bb18f1d8a6a5999b81ca202a1a38c.tar.bz2
scummvm-rg350-7410f041ee8bb18f1d8a6a5999b81ca202a1a38c.zip
cleanup; added a TODO to Font class
svn-id: r13308
Diffstat (limited to 'gui')
-rw-r--r--gui/font.cpp3
-rw-r--r--gui/font.h13
-rw-r--r--gui/newgui.cpp6
3 files changed, 17 insertions, 5 deletions
diff --git a/gui/font.cpp b/gui/font.cpp
index a4031a4144..5d68eb7f07 100644
--- a/gui/font.cpp
+++ b/gui/font.cpp
@@ -71,6 +71,9 @@ void NewFont::drawChar(const Surface *dst, byte chr, int x, int y, uint32 color)
}
+#pragma mark -
+
+
int Font::getStringWidth(const Common::String &str) const {
int space = 0;
diff --git a/gui/font.h b/gui/font.h
index 55ad9e9a1d..207b42a493 100644
--- a/gui/font.h
+++ b/gui/font.h
@@ -46,6 +46,19 @@ struct Surface {
Surface() : pixels(0), w(0), h(0), pitch(0), bytesPerPixel(0) {}
};
+/**
+ * Instances of this class represent a distinct font, with a built-in renderer.
+ * @todo Maybe move the high-level methods (drawString etc.) to a separate
+ * FontRenderer class? That way, we could have different variants... ?
+ * @todo Add more parameters to drawString, or additional similar methods,
+ * featuring abilities like
+ * - rendering with wrap-around instead of inserting an ellipsis or
+ * cutting them; needs a 'height' parameter
+ * - rendering multi-line strings (essentially, invoke the regular
+ * drawString for each line, and advance one line)
+ * - combinations of the two above: honor line feeds, and also wrap
+ * overlong lines
+ */
class Font {
public:
virtual int getFontHeight() const = 0;
diff --git a/gui/newgui.cpp b/gui/newgui.cpp
index 5f03cc0db2..a167fd9382 100644
--- a/gui/newgui.cpp
+++ b/gui/newgui.cpp
@@ -363,11 +363,7 @@ void NewGui::drawChar(byte chr, int xx, int yy, OverlayColor color) {
}
int NewGui::getStringWidth(const String &str) {
- int space = 0;
-
- for (uint i = 0; i < str.size(); ++i)
- space += getCharWidth(str[i]);
- return space;
+ return g_guifont.getStringWidth(str);
}
int NewGui::getCharWidth(byte c) {