aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2018-11-09 19:30:03 -0800
committerPaul Gilbert2018-12-08 19:05:59 -0800
commit7cba554fc5ea46c3a6bbe23e073de16914d7895f (patch)
tree50d96bc43c0acc814bac810f6382cc56bf997f70
parent3c2fd3e74f9a205109ab9b57c5af893011560452 (diff)
downloadscummvm-rg350-7cba554fc5ea46c3a6bbe23e073de16914d7895f.tar.gz
scummvm-rg350-7cba554fc5ea46c3a6bbe23e073de16914d7895f.tar.bz2
scummvm-rg350-7cba554fc5ea46c3a6bbe23e073de16914d7895f.zip
GLK: Don't leading & baseline for fonts go below minimum size
-rw-r--r--engines/gargoyle/fonts.cpp15
-rw-r--r--engines/gargoyle/fonts.h8
2 files changed, 12 insertions, 11 deletions
diff --git a/engines/gargoyle/fonts.cpp b/engines/gargoyle/fonts.cpp
index 857ef1599a..9c074127df 100644
--- a/engines/gargoyle/fonts.cpp
+++ b/engines/gargoyle/fonts.cpp
@@ -38,11 +38,14 @@ Fonts::Fonts(Graphics::ManagedSurface *surface) : _surface(surface), _fontsMissi
if (!loadFonts())
error("Could not load data file");
- if (!g_conf->_leading)
- g_conf->_leading = g_conf->_propSize + 2;
- if (!g_conf->_baseLine)
- g_conf->_baseLine = g_conf->_propSize + 0.5;
-
+ // TODO: See if there's any better way for getting the leading and baseline
+ Common::Rect r1 = _fontTable[7]->getBoundingBox('o');
+ Common::Rect r2 = _fontTable[7]->getBoundingBox('y');
+ double baseLine = (double)r1.bottom;
+ double leading = (double)r2.bottom + 2;
+
+ g_conf->_leading = MAX((double)g_conf->_leading, leading);
+ g_conf->_baseLine = MAX((double)g_conf->_baseLine, baseLine);
g_conf->_cellW = _fontTable[0]->getStringWidth("0");
g_conf->_cellH = g_conf->_leading;
}
@@ -142,13 +145,11 @@ int Fonts::drawStringUni(const Point &pos, int fontIdx, const byte *rgb, const C
}
size_t Fonts::stringWidth(int fontIdx, const Common::String &text, int spw) {
- // TODO: Handle spw
const Graphics::Font *font = _fontTable[fontIdx];
return font->getStringWidth(text) * GLI_SUBPIX;
}
size_t Fonts::stringWidthUni(int fontIdx, const Common::U32String &text, int spw) {
- // TODO: Handle spw
const Graphics::Font *font = _fontTable[fontIdx];
return font->getStringWidth(text) * GLI_SUBPIX;
}
diff --git a/engines/gargoyle/fonts.h b/engines/gargoyle/fonts.h
index 2f2cb4145c..1437bd8152 100644
--- a/engines/gargoyle/fonts.h
+++ b/engines/gargoyle/fonts.h
@@ -98,19 +98,19 @@ public:
* Get the width in pixels of a string
* @param fontIdx Which font to use
* @param text Text to get the width of
- * @param spw ???
+ * @param spw Delta X
* @returns Width of string multiplied by GLI_SUBPIX
*/
- size_t stringWidth(int fontIdx, const Common::String &text, int spw = -1);
+ size_t stringWidth(int fontIdx, const Common::String &text, int spw = 0);
/**
* Get the width in pixels of a unicode string
* @param fontIdx Which font to use
* @param text Text to get the width of
- * @param spw ???
+ * @param spw Delta X
* @returns Width of string multiplied by GLI_SUBPIX
*/
- size_t stringWidthUni(int fontIdx, const Common::U32String &text, int spw = -1);
+ size_t stringWidthUni(int fontIdx, const Common::U32String &text, int spw = 0);
};
} // End of namespace Gargoyle