[Scummvm-git-logs] scummvm master -> 07ce31ecae3d63b7cc3867d972ddad4244292cb8

criezy criezy at scummvm.org
Fri Sep 24 22:51:25 UTC 2021


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

Summary:
3e1c61cdb8 GRAPHICS: Support loading a Windows font from an existing stream
07ce31ecae AGS: Try to load font with WinFont as a fallback when TTFFont fails


Commit: 3e1c61cdb8627475ade7436c18ff421516433c75
    https://github.com/scummvm/scummvm/commit/3e1c61cdb8627475ade7436c18ff421516433c75
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-09-24T23:42:18+01:00

Commit Message:
GRAPHICS: Support loading a Windows font from an existing stream

Changed paths:
    graphics/fonts/winfont.cpp
    graphics/fonts/winfont.h


diff --git a/graphics/fonts/winfont.cpp b/graphics/fonts/winfont.cpp
index b02323ec82..99485c2347 100644
--- a/graphics/fonts/winfont.cpp
+++ b/graphics/fonts/winfont.cpp
@@ -86,6 +86,16 @@ bool WinFont::loadFromFON(const Common::String &fileName, const WinFontDirEntry
 	return ok;
 }
 
+bool WinFont::loadFromFON(Common::SeekableReadStream &stream, const WinFontDirEntry &dirEntry) {
+	Common::WinResources *exe = Common::WinResources::createFromEXE(&stream);
+	if (!exe)
+		return false;
+
+	bool ok = loadFromEXE(exe, Common::String("stream"), dirEntry);
+	delete exe;
+	return ok;
+}
+
 bool WinFont::loadFromEXE(Common::WinResources *exe, const Common::String &fileName, const WinFontDirEntry &dirEntry) {
 	// Let's pull out the font directory
 	Common::SeekableReadStream *fontDirectory = exe->getResource(Common::kWinFontDir, Common::String("FONTDIR"));
diff --git a/graphics/fonts/winfont.h b/graphics/fonts/winfont.h
index a30c59bbc6..9f7211bf4f 100644
--- a/graphics/fonts/winfont.h
+++ b/graphics/fonts/winfont.h
@@ -54,6 +54,7 @@ public:
 	 * If dirEntry is not given, the first font in the FONTDIR will be loaded
 	 */
 	bool loadFromFON(const Common::String &fileName, const WinFontDirEntry &dirEntry = WinFontDirEntry());
+	bool loadFromFON(Common::SeekableReadStream &stream, const WinFontDirEntry &dirEntry = WinFontDirEntry());
 
 	/** Open a font from an FNT file */
 	bool loadFromFNT(const Common::String &fileName);


Commit: 07ce31ecae3d63b7cc3867d972ddad4244292cb8
    https://github.com/scummvm/scummvm/commit/07ce31ecae3d63b7cc3867d972ddad4244292cb8
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-09-24T23:43:33+01:00

Commit Message:
AGS: Try to load font with WinFont as a fallback when TTFFont fails

This fixes bug #12948 AGS: Segfault when picking up at police report.
For that bug the font is properly loaded by FreeType, but it is a
non-scalable Windows font whose size does not match the requested
size. The original AGS handles TTF font sizes differently to how we
do it in TTFFont (and also has some hacks on top of that), and it
was easier here to use WinFont that try to tweak TTFont to work
with this case.

Changed paths:
    engines/ags/lib/alfont/alfont.cpp


diff --git a/engines/ags/lib/alfont/alfont.cpp b/engines/ags/lib/alfont/alfont.cpp
index 188007b18c..cba1e7b8c4 100644
--- a/engines/ags/lib/alfont/alfont.cpp
+++ b/engines/ags/lib/alfont/alfont.cpp
@@ -22,6 +22,7 @@
 
 #include "common/file.h"
 #include "graphics/fonts/ttf.h"
+#include "graphics/fonts/winfont.h"
 #include "ags/lib/alfont/alfont.h"
 #include "ags/ags.h"
 #include "ags/globals.h"
@@ -37,7 +38,16 @@ Graphics::Font *ALFONT_FONT::getFont() {
 		Graphics::TTFRenderMode renderMode = Graphics::kTTFRenderModeMonochrome;
 		if (ShouldAntiAliasText())
 			renderMode = Graphics::kTTFRenderModeLight;
-		_fonts[_size] = Graphics::loadTTFFont(_ttfData, _size, Graphics::kTTFSizeModeCharacter, 0, renderMode);
+		Graphics::Font *font = Graphics::loadTTFFont(_ttfData, _size, Graphics::kTTFSizeModeCharacter, 0, renderMode);
+		if (!font) {
+			// Try WinFont as TTFFont may fail loading those
+			Graphics::WinFont *winfont = new Graphics::WinFont();
+			if (winfont->loadFromFON(_ttfData))
+				font = winfont;
+			else
+				delete winfont;
+		}
+		_fonts[_size] = font;
 		assert(_fonts[_size]);
 	}
 




More information about the Scummvm-git-logs mailing list