diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/font.cpp | 3 | ||||
-rw-r--r-- | gui/font.h | 13 | ||||
-rw-r--r-- | gui/newgui.cpp | 6 |
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) { |