[Scummvm-git-logs] scummvm master -> 80b66994852f2618f3885e50d71151a80eca7c92

sev- noreply at scummvm.org
Tue Feb 25 23:02:31 UTC 2025


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

Summary:
80b6699485 GRAPHICS: MACGUI: Moved windows cached fonts earlier in MacFontManager


Commit: 80b66994852f2618f3885e50d71151a80eca7c92
    https://github.com/scummvm/scummvm/commit/80b66994852f2618f3885e50d71151a80eca7c92
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2025-02-26T00:02:22+01:00

Commit Message:
GRAPHICS: MACGUI: Moved windows cached fonts earlier in MacFontManager

Since we cache windows an mac fonts, this ensures that we check both caches
before attempting to generate substitutes, whuch affects greatly
performance in Windows Director games

Changed paths:
    graphics/macgui/macfontmanager.cpp


diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp
index b0c101c8057..c79fb643ffc 100644
--- a/graphics/macgui/macfontmanager.cpp
+++ b/graphics/macgui/macfontmanager.cpp
@@ -504,17 +504,47 @@ const Font *MacFontManager::getFont(MacFont *macFont) {
 		}
 
 		if (!_fontRegistry.contains(macFont->getName())) {
-			// Let's try to generate name
-			if (macFont->getSlant() != kMacFontRegular) {
-				name = getFontName(macFont->getId(), macFont->getSize(), macFont->getSlant(), true);
-				macFont->setName(name);
-			}
+			int id = macFont->getId();
+
+			if (_fontInfo.contains(id) && _winFontRegistry.contains(_fontInfo.getVal(id)->name)) {
+				font = _winFontRegistry.getVal(_fontInfo.getVal(id)->name);
+				const Graphics::WinFont *winfont = (const Graphics::WinFont *)font;
+
+				if (winfont->getFontHeight() != macFont->getSize()) {
+					Common::String fullFontName = Common::String::format("%s-%d-%d", winfont->getName().c_str(), winfont->getStyle(), macFont->getSize());
+
+					if (_winFontRegistry.contains(fullFontName)) {
+						font = _winFontRegistry.getVal(fullFontName);
+					} else {
+						// Generate a scaledFont
+						Graphics::WinFont *scaledWinFont = WinFont::scaleFont(winfont, macFont->getSize());
+						if (scaledWinFont) {
+							debugC(1, kDebugLevelMacGUI, "MacFontManager::getFont(): Generated scaled winFont %s", fullFontName.c_str());
+
+							// register font generated for reuse
+							_winFontRegistry.setVal(fullFontName, scaledWinFont);
 
-			if (!_fontRegistry.contains(macFont->getName()))
-				generateFontSubstitute(*macFont);
+							font = scaledWinFont;
+						}
+					}
+				}
+			}
 		}
 
-		font = FontMan.getFontByName(macFont->getName());
+		if (!font) {
+			if (!_fontRegistry.contains(macFont->getName())) {
+				// Let's try to generate name
+				if (macFont->getSlant() != kMacFontRegular) {
+					name = getFontName(macFont->getId(), macFont->getSize(), macFont->getSlant(), true);
+					macFont->setName(name);
+				}
+
+				if (!_fontRegistry.contains(macFont->getName()))
+					generateFontSubstitute(*macFont);
+			}
+
+			font = FontMan.getFontByName(macFont->getName());
+		}
 
 		if (!font) {
 			debugC(1, kDebugLevelMacGUI, "Cannot load font '%s'", macFont->getName().c_str());
@@ -555,37 +585,6 @@ const Font *MacFontManager::getFont(MacFont *macFont) {
 	}
 #endif
 
-	if (!font) {
-		int id = macFont->getId();
-
-		if (_fontInfo.contains(id) && _winFontRegistry.contains(_fontInfo.getVal(id)->name)) {
-			font = _winFontRegistry.getVal(_fontInfo.getVal(id)->name);
-			const Graphics::WinFont *winfont = (const Graphics::WinFont *)font;
-
-			if (winfont->getFontHeight() != macFont->getSize()) {
-				debugC(1, kDebugLevelMacGUI, "MacFontManager::getFont(): For font '%s' windows font '%s' is used of a different size %d", macFont->getName().c_str(), winfont->getName().c_str(), winfont->getFontHeight());
-
-				Common::String fullFontName = Common::String::format("%s-%d-%d", winfont->getName().c_str(), winfont->getStyle(), macFont->getSize());
-
-				if (_winFontRegistry.contains(fullFontName)) {
-					// Check if we have generated this earlier, in that case reuse it.
-					font = _winFontRegistry.getVal(fullFontName);
-				} else {
-					// Generate a scaledFont
-					Graphics::WinFont *scaledWinFont = WinFont::scaleFont(winfont, macFont->getSize());
-					if (scaledWinFont) {
-						debugC(1, kDebugLevelMacGUI, "MacFontManager::getFont(): Generated scaled winFont %s", fullFontName.c_str());
-
-						// register font generated for reuse
-						_winFontRegistry.setVal(fullFontName, scaledWinFont);
-
-						font = scaledWinFont;
-					}
-				}
-			}
-		}
-	}
-
 	if (!font) {
 		font = macFont->getFallback();
 




More information about the Scummvm-git-logs mailing list