[Scummvm-git-logs] scummvm branch-2-3 -> 6bbee47f71aaa00866f11fa5197acd2c70017b6e

criezy criezy at scummvm.org
Fri Sep 24 22:52:22 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:
f6eeae4736 GRAPHICS: Support loading a Windows font from an existing stream
6bbee47f71 AGS: Try to load font with WinFont as a fallback when TTFFont fails


Commit: f6eeae473655e2f52a650394f0267109b80873a9
    https://github.com/scummvm/scummvm/commit/f6eeae473655e2f52a650394f0267109b80873a9
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-09-24T23:51:46+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: 6bbee47f71aaa00866f11fa5197acd2c70017b6e
    https://github.com/scummvm/scummvm/commit/6bbee47f71aaa00866f11fa5197acd2c70017b6e
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-09-24T23:52:00+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 99fec416e6..b472c563cc 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