[Scummvm-git-logs] scummvm master -> 10b1c806c7486dc2ed7871f6cd9db6c3aa6f3e0a

OMGPizzaGuy noreply at scummvm.org
Thu Oct 22 02:25:17 UTC 2026


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
10b1c806c7 ULTIMA8: Change key of TTF font cache to a string


Commit: 10b1c806c7486dc2ed7871f6cd9db6c3aa6f3e0a
    https://github.com/scummvm/scummvm/commit/10b1c806c7486dc2ed7871f6cd9db6c3aa6f3e0a
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2026-10-21T21:23:22-05:00

Commit Message:
ULTIMA8: Change key of TTF font cache to a string

Changed paths:
    engines/ultima/ultima8/gfx/fonts/font_manager.cpp
    engines/ultima/ultima8/gfx/fonts/font_manager.h


diff --git a/engines/ultima/ultima8/gfx/fonts/font_manager.cpp b/engines/ultima/ultima8/gfx/fonts/font_manager.cpp
index 2bce6bafd6e..6f3534cd976 100644
--- a/engines/ultima/ultima8/gfx/fonts/font_manager.cpp
+++ b/engines/ultima/ultima8/gfx/fonts/font_manager.cpp
@@ -86,12 +86,9 @@ Font *FontManager::getTTFont(unsigned int fontnum) {
 
 Graphics::Font *FontManager::getTTF_Font(const Common::Path &filename, int pointsize, bool antialiasing) {
 #ifdef USE_FREETYPE2
-	TTFId id;
-	id._filename = filename;
-	id._pointSize = pointsize;
-
-	TTFFonts::iterator iter;
-	iter = _ttfFonts.find(id);
+	Graphics::TTFRenderMode mode = antialiasing ? Graphics::kTTFRenderModeNormal : Graphics::kTTFRenderModeMonochrome;
+	Common::String key = filename.toString() + Common::String::format(":%d:%d", pointsize, mode);
+	auto iter = _ttfFonts.find(key);
 
 	if (iter != _ttfFonts.end())
 		return iter->_value;
@@ -105,7 +102,6 @@ Graphics::Font *FontManager::getTTF_Font(const Common::Path &filename, int point
 
 	// open font using ScummVM TTF API
 	// Note: The RWops and ReadStream will be deleted by the TTF_Font
-	Graphics::TTFRenderMode mode = antialiasing ? Graphics::kTTFRenderModeNormal : Graphics::kTTFRenderModeMonochrome;
 	Graphics::Font *font = Graphics::loadTTFFont(fontids, DisposeAfterUse::YES, pointsize, Graphics::kTTFSizeModeCharacter, 0, 0, mode, 0, false);
 
 	if (!font) {
@@ -114,7 +110,7 @@ Graphics::Font *FontManager::getTTF_Font(const Common::Path &filename, int point
 		return nullptr;
 	}
 
-	_ttfFonts[id] = font;
+	_ttfFonts[key] = font;
 
 	debugC(kDebugGraphics, "Opened TTF: %s.", filename.toString().c_str());
 	return font;
diff --git a/engines/ultima/ultima8/gfx/fonts/font_manager.h b/engines/ultima/ultima8/gfx/fonts/font_manager.h
index 8aa7e0d604a..0b0c7d75740 100644
--- a/engines/ultima/ultima8/gfx/fonts/font_manager.h
+++ b/engines/ultima/ultima8/gfx/fonts/font_manager.h
@@ -23,6 +23,7 @@
 #define ULTIMA8_GFX_FONTS_FONTMANAGER_H
 
 #include "common/hashmap.h"
+#include "common/hash-str.h"
 #include "common/path.h"
 #include "graphics/font.h"
 
@@ -39,31 +40,7 @@ class TTFont;
 
 class FontManager {
 private:
-	struct TTFId {
-		Common::Path _filename;
-		int _pointSize;
-		bool operator<(const TTFId &other) const {
-			return (_pointSize < other._pointSize ||
-			        (_pointSize == other._pointSize &&
-			         _filename < other._filename));
-		}
-	};
-
-	struct TTFHash {
-		uint operator()(const TTFId &x) const {
-			// TODO: See if something better can be used as a hash key
-			int64 val = (int64)&x;
-			return (uint)val;
-		}
-	};
-	struct TTFEqual {
-		bool operator()(const TTFId &x, const TTFId &y) const {
-			return x._filename == y._filename && x._pointSize == y._pointSize;
-		}
-	};
-
-	typedef Common::HashMap<TTFId, Graphics::Font *, TTFHash, TTFEqual> TTFFonts;
-	TTFFonts _ttfFonts;
+	Common::HashMap<Common::String, Graphics::Font *> _ttfFonts;
 
 	//! Get a (possibly cached) TTF_Font structure for filename/pointsize,
 	//! loading it if necessary.




More information about the Scummvm-git-logs mailing list