aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'graphics')
-rw-r--r--graphics/fontman.cpp20
-rw-r--r--graphics/fontman.h10
-rw-r--r--graphics/fonts/bdf.cpp3
-rw-r--r--graphics/surface.cpp6
4 files changed, 36 insertions, 3 deletions
diff --git a/graphics/fontman.cpp b/graphics/fontman.cpp
index e59e5a33c5..a10d27a2b0 100644
--- a/graphics/fontman.cpp
+++ b/graphics/fontman.cpp
@@ -79,6 +79,26 @@ bool FontManager::assignFontToName(const Common::String &name, const Font *font)
return true;
}
+bool FontManager::setFont(FontUsage usage, const Font *font) {
+ switch (usage) {
+ case kConsoleFont:
+ delete g_consolefont;
+ g_consolefont = (const BdfFont *)font;
+ break;
+ case kGUIFont:
+ delete g_sysfont;
+ g_sysfont = (const BdfFont *)font;
+ break;
+ case kBigGUIFont:
+ delete g_sysfont_big;
+ g_sysfont_big = (const BdfFont *)font;
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
void FontManager::removeFontName(const Common::String &name) {
Common::String lowercaseName = name;
lowercaseName.toLowercase();
diff --git a/graphics/fontman.h b/graphics/fontman.h
index 858a733d45..371ebb1e35 100644
--- a/graphics/fontman.h
+++ b/graphics/fontman.h
@@ -60,6 +60,16 @@ public:
bool assignFontToName(const Common::String &name, const Font *font);
/**
+ * Associates a BDF font object with an 'usage'. This is useful for platforms
+ * with a screen DPI much larger than a regular desktop workstation.
+ *
+ * @param name the name of the font
+ * @param font the font object
+ * @return true on success, false on failure
+ */
+ bool setFont(FontUsage usage, const Font *font);
+
+ /**
* Removes binding from name to font
*
* @param name name which should be removed
diff --git a/graphics/fonts/bdf.cpp b/graphics/fonts/bdf.cpp
index cf2e38d3f1..58c48ed877 100644
--- a/graphics/fonts/bdf.cpp
+++ b/graphics/fonts/bdf.cpp
@@ -81,7 +81,8 @@ void drawCharIntern(byte *ptr, uint pitch, const bitmap_t *src, int h, int minX,
void BdfFont::drawChar(Surface *dst, byte chr, const int tx, const int ty, const uint32 color) const {
assert(dst != 0);
- assert(_desc.bits != 0 && _desc.maxwidth <= 16);
+ // asserting _desc.maxwidth <= 50: let the theme designer decide what looks best
+ assert(_desc.bits != 0 && _desc.maxwidth <= 50);
assert(dst->format.bytesPerPixel == 1 || dst->format.bytesPerPixel == 2);
// If this character is not included in the font, use the default char.
diff --git a/graphics/surface.cpp b/graphics/surface.cpp
index 0fad25734c..e0b25f22e9 100644
--- a/graphics/surface.cpp
+++ b/graphics/surface.cpp
@@ -56,8 +56,10 @@ void Surface::create(uint16 width, uint16 height, const PixelFormat &f) {
format = f;
pitch = w * format.bytesPerPixel;
- pixels = calloc(width * height, format.bytesPerPixel);
- assert(pixels);
+ if (width && height) {
+ pixels = calloc(width * height, format.bytesPerPixel);
+ assert(pixels);
+ }
}
void Surface::free() {