[Scummvm-git-logs] scummvm master -> 796740e2e1b628e666a990621d28d4e8adf2f13b

dreammaster dreammaster at scummvm.org
Wed Sep 22 02:47:26 UTC 2021


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

Summary:
a72e87df63 AGS: Fixed crash in auto outline in case of empty text argument
b63427641d AGS: Moved font's linespacing hack into the game_init
796740e2e1 AGS: Added detection entries


Commit: a72e87df632f3b196c91e2933fae04eec7c01fc8
    https://github.com/scummvm/scummvm/commit/a72e87df632f3b196c91e2933fae04eec7c01fc8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-09-21T18:45:18-07:00

Commit Message:
AGS: Fixed crash in auto outline in case of empty text argument

>From upstream e3665a3c073e574d3e4fade869b3c0c3e88508e5

Changed paths:
    engines/ags/ags.h
    engines/ags/engine/ac/display.cpp


diff --git a/engines/ags/ags.h b/engines/ags/ags.h
index cd0c5648f4..de3843437f 100644
--- a/engines/ags/ags.h
+++ b/engines/ags/ags.h
@@ -51,7 +51,12 @@ namespace AGS {
  */
 
 /* Synced up to upstream: 3.5.1.10
- * edd1eded7f5b1097511b986c7c2c3d944195ded9
+ * f2736d21677d2db4b0559c1ded31e284b8a8f64f
+ *
+ * Commits still pending to be ported:
+ * cae84d689019313cad49b6dca7e916866b90e49e
+ * - We have slightly different blending code, commit needs
+ * to be modified to take that into account
  */
 #define SCREEN_WIDTH 320
 #define SCREEN_HEIGHT 200
diff --git a/engines/ags/engine/ac/display.cpp b/engines/ags/engine/ac/display.cpp
index acd8c49436..c434c84a99 100644
--- a/engines/ags/engine/ac/display.cpp
+++ b/engines/ags/engine/ac/display.cpp
@@ -462,6 +462,9 @@ void wouttextxy_AutoOutline(Bitmap *ds, size_t font, int32_t color, const char *
 
 	size_t const t_width = wgettextwidth(texx, font);
 	size_t const t_height = wgettextheight(texx, font);
+	if (t_width == 0 || t_height == 0)
+		return;
+
 	Bitmap *outline_stencil =
 		CreateTransparentBitmap(t_width, t_height + 2 * thickness, ds->GetColorDepth());
 	Bitmap *texx_stencil =


Commit: b63427641d39cd8478eee84443dfc0cfcea73e2f
    https://github.com/scummvm/scummvm/commit/b63427641d39cd8478eee84443dfc0cfcea73e2f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-09-21T18:45:18-07:00

Commit Message:
AGS: Moved font's linespacing hack into the game_init

>From upstream f8ad7b96b46c33156ee1d6c7c4b64b5029c7b93b

Changed paths:
    engines/ags/engine/ac/display.cpp
    engines/ags/engine/ac/display.h
    engines/ags/engine/game/game_init.cpp
    engines/ags/shared/font/ags_font_renderer.h
    engines/ags/shared/font/fonts.cpp
    engines/ags/shared/font/fonts.h
    engines/ags/shared/font/ttf_font_renderer.cpp
    engines/ags/shared/font/ttf_font_renderer.h
    engines/ags/shared/font/wfn_font_renderer.cpp
    engines/ags/shared/font/wfn_font_renderer.h


diff --git a/engines/ags/engine/ac/display.cpp b/engines/ags/engine/ac/display.cpp
index c434c84a99..33e53826f2 100644
--- a/engines/ags/engine/ac/display.cpp
+++ b/engines/ags/engine/ac/display.cpp
@@ -533,8 +533,20 @@ void wouttext_aligned(Bitmap *ds, int usexp, int yy, int oriwid, int usingfont,
 	wouttext_outline(ds, usexp, yy, usingfont, text_color, text);
 }
 
+int get_font_outline_padding(int font) {
+	if (get_font_outline(font) == FONT_OUTLINE_AUTO) {
+		// scaled up bitmap font, push outline further out
+		if (is_bitmap_font(font) && get_font_scaling_mul(font) > 1)
+			return get_fixed_pixel_size(2); // FIXME: should be 2 + get_fixed_pixel_size(2)?
+		// otherwise, just push outline by 1 pixel
+		else
+			return 2;
+	}
+	return 0;
+}
+
 int getfontheight_outlined(int font) {
-	return getfontheight(font) + 2 * get_font_outline_thickness(font);
+	return getfontheight(font) + 2 * get_font_outline_padding(font);
 }
 
 int getfontspacing_outlined(int font) {
@@ -552,7 +564,7 @@ int getheightoflines(int font, int numlines) {
 }
 
 int wgettextwidth_compensate(const char *tex, int font) {
-	return wgettextwidth(tex, font) + 2 * get_font_outline_thickness(font);
+	return wgettextwidth(tex, font) + 2 * get_font_outline_padding(font);
 }
 
 void do_corner(Bitmap *ds, int sprn, int x, int y, int offx, int offy) {
diff --git a/engines/ags/engine/ac/display.h b/engines/ags/engine/ac/display.h
index 9a9abf71a9..23501d907d 100644
--- a/engines/ags/engine/ac/display.h
+++ b/engines/ags/engine/ac/display.h
@@ -57,6 +57,8 @@ void wouttext_aligned(Shared::Bitmap *ds, int usexp, int yy, int oriwid, int usi
 // need to find a way to make all code use same functions.
 // Get the maximal height of the given font, with corresponding outlining
 int getfontheight_outlined(int font);
+// Get outline's thickness addition to the font's width or height
+int get_font_outline_padding(int font);
 // Get line spacing for the given font, with possible outlining in mind
 int getfontspacing_outlined(int font);
 // Get the distance between bottom one one line and top of the next line (may be negative!)
diff --git a/engines/ags/engine/game/game_init.cpp b/engines/ags/engine/game/game_init.cpp
index d1a2b719b4..4555ac6f64 100644
--- a/engines/ags/engine/game/game_init.cpp
+++ b/engines/ags/engine/game/game_init.cpp
@@ -23,6 +23,7 @@
 #include "ags/engine/ac/character.h"
 #include "ags/engine/ac/character_cache.h"
 #include "ags/engine/ac/dialog.h"
+#include "ags/engine/ac/display.h"
 #include "ags/engine/ac/draw.h"
 #include "ags/engine/ac/file.h"
 #include "ags/engine/ac/game.h"
@@ -273,11 +274,11 @@ void LoadFonts(GameDataVersion data_ver) {
 
 		// Backward compatibility: if the real font's height != formal height
 		// and there's no custom linespacing, then set linespacing = formal height.
-		if (!is_wfn) {
-			int req_height = finfo.SizePt * finfo.SizeMultiplier;
+		if (!is_bitmap_font(i)) {
+			int req_height = _GP(game).fonts[i].SizePt * _GP(game).fonts[i].SizeMultiplier;
 			int height = getfontheight(i);
-			if ((height != req_height) && (finfo.LineSpacing == 0)) {
-				set_font_linespacing(i, req_height + 2 * get_font_outline_thickness(i));
+			if ((height != req_height) && (_GP(game).fonts[i].LineSpacing == 0)) {
+				set_font_linespacing(i, req_height + get_font_outline_padding(i));
 			}
 		}
 	}
diff --git a/engines/ags/shared/font/ags_font_renderer.h b/engines/ags/shared/font/ags_font_renderer.h
index e5e8d5429d..1d7531760f 100644
--- a/engines/ags/shared/font/ags_font_renderer.h
+++ b/engines/ags/shared/font/ags_font_renderer.h
@@ -51,8 +51,8 @@ struct FontRenderParams {
 	int SizeMultiplier = 1;
 };
 
-// Used to tell font information after loading one
-struct LoadedFontInfo {
+// Describes loaded font's properties
+struct FontMetrics {
 	int Height = 0; // formal font height value
 	int RealHeight = 0; // real graphical height of a font
 };
@@ -63,7 +63,7 @@ public:
 	virtual bool IsBitmapFont() = 0;
 	// Load font, applying extended font rendering parameters
 	virtual bool LoadFromDiskEx(int fontNumber, int fontSize, const FontRenderParams *params,
-		LoadedFontInfo *info) = 0;
+		FontMetrics *metrics) = 0;
 protected:
 	IAGSFontRenderer2() {}
 	~IAGSFontRenderer2() {}
diff --git a/engines/ags/shared/font/fonts.cpp b/engines/ags/shared/font/fonts.cpp
index cc6fa18da8..156652670e 100644
--- a/engines/ags/shared/font/fonts.cpp
+++ b/engines/ags/shared/font/fonts.cpp
@@ -20,6 +20,7 @@
  *
  */
 
+#include "ags/lib/std/algorithm.h"
 #include "ags/lib/alfont/alfont.h"
 #include "ags/lib/std/vector.h"
 #include "ags/shared/ac/common.h" // set_our_eip
@@ -91,33 +92,15 @@ bool is_font_loaded(size_t fontNumber) {
 // Finish font's initialization
 static void post_init_font(size_t fontNumber) {
 	Font &font = _GP(fonts)[fontNumber];
-	if (font.LoadedInfo.Height == 0) {
+	if (font.Metrics.Height == 0) {
 		// There is no explicit method for getting maximal possible height of any
 		// random font renderer at the moment; the implementations of GetTextHeight
 		// are allowed to return varied results depending on the text parameter.
 		// We use special line of text to get more or less reliable font height.
 		const char *height_test_string = "ZHwypgfjqhkilIK";
 		int height = font.Renderer->GetTextHeight(height_test_string, fontNumber);
-		font.LoadedInfo.Height = height;
-		font.LoadedInfo.RealHeight = height;
-	}
-	// FIXME: move this out of the font module, as compatibility fixes
-	// depend on the other game data, such as format version, etc.
-	// Backward compatibility: if the real height != formal height
-	// and there's no custom linespacing, then set linespacing = formal height.
-	if ((font.LoadedInfo.RealHeight != font.LoadedInfo.Height) &&
-		(font.Info.LineSpacing == 0)) {
-		font.Info.LineSpacing = font.LoadedInfo.Height;
-		if (get_font_outline(fontNumber) == FONT_OUTLINE_AUTO) {
-			// scaled up bitmap fonts have extra outline offset
-			if (is_bitmap_font(fontNumber) && get_font_scaling_mul(fontNumber) > 1)
-				font.Info.LineSpacing += get_fixed_pixel_size(2);  // FIXME: should be 2 + get_fixed_pixel_size(2)?
-			else
-				font.Info.LineSpacing += 2;
-		}
-	}
-	if (font.Info.Outline != FONT_OUTLINE_AUTO) {
-		font.Info.AutoOutlineThickness = 0;
+		font.Metrics.Height = height;
+		font.Metrics.RealHeight = height;
 	}
 }
 
@@ -201,7 +184,7 @@ void set_font_outline(size_t font_number, int outline_type,
 int getfontheight(size_t fontNumber) {
 	if (fontNumber >= _GP(fonts).size() || !_GP(fonts)[fontNumber].Renderer)
 		return 0;
-	return _GP(fonts)[fontNumber].LoadedInfo.RealHeight;
+	return _GP(fonts)[fontNumber].Metrics.RealHeight;
 }
 
 int getfontlinespacing(size_t fontNumber) {
@@ -376,12 +359,12 @@ bool wloadfont_size(size_t fontNumber, const FontInfo &font_info) {
 		wfreefont(fontNumber);
 	FontRenderParams params;
 	params.SizeMultiplier = font_info.SizeMultiplier;
-	LoadedFontInfo load_info;
+	FontMetrics metrics;
 
-	if (_GP(ttfRenderer).LoadFromDiskEx(fontNumber, font_info.SizePt, &params, &load_info)) {
+	if (_GP(ttfRenderer).LoadFromDiskEx(fontNumber, font_info.SizePt, &params, &metrics)) {
 		_GP(fonts)[fontNumber].Renderer = &_GP(ttfRenderer);
 		_GP(fonts)[fontNumber].Renderer2 = &_GP(ttfRenderer);
-	} else if (_GP(wfnRenderer).LoadFromDiskEx(fontNumber, font_info.SizePt, &params, &load_info)) {
+	} else if (_GP(wfnRenderer).LoadFromDiskEx(fontNumber, font_info.SizePt, &params, &metrics)) {
 		_GP(fonts)[fontNumber].Renderer = &_GP(wfnRenderer);
 		_GP(fonts)[fontNumber].Renderer2 = &_GP(wfnRenderer);
 	}
@@ -390,7 +373,7 @@ bool wloadfont_size(size_t fontNumber, const FontInfo &font_info) {
 		return false;
 
 	_GP(fonts)[fontNumber].Info = font_info;
-	_GP(fonts)[fontNumber].LoadedInfo = load_info;
+	_GP(fonts)[fontNumber].Metrics = metrics;
 	post_init_font(fontNumber);
 	return true;
 }
diff --git a/engines/ags/shared/font/fonts.h b/engines/ags/shared/font/fonts.h
index dcdc1ad852..54fee28cae 100644
--- a/engines/ags/shared/font/fonts.h
+++ b/engines/ags/shared/font/fonts.h
@@ -28,6 +28,7 @@
 #include "ags/shared/util/string.h"
 #include "ags/shared/ac/game_struct_defines.h"
 #include "ags/shared/font/ags_font_renderer.h"
+#include "ags/shared/gfx/allegro_bitmap.h"
 
 namespace AGS3 {
 
@@ -38,14 +39,17 @@ struct FontRenderParams;
 
 namespace AGS {
 namespace Shared {
-class Bitmap;
 
 struct Font {
 	IAGSFontRenderer *Renderer = nullptr;
 	IAGSFontRenderer2 *Renderer2 = nullptr;
 	FontInfo            Info;
 	// Values received from the renderer and saved for the reference
-	AGS3::LoadedFontInfo LoadedInfo;
+	FontMetrics       Metrics;
+
+	// Outline buffers
+	Bitmap TextStencil, TextStencilSub;
+	Bitmap OutlineStencil, OutlineStencilSub;
 
 	Font();
 };
@@ -102,9 +106,16 @@ void set_font_outline(size_t font_number, int outline_type,
 void wouttextxy(Shared::Bitmap *ds, int xxx, int yyy, size_t fontNumber, color_t text_color, const char *texx);
 // Assigns FontInfo to the font
 void set_fontinfo(size_t fontNumber, const FontInfo &finfo);
+// Gets full information about the font
+FontInfo get_fontinfo(size_t font_number);
 // Loads a font from disk
 bool wloadfont_size(size_t fontNumber, const FontInfo &font_info);
 void wgtprintf(Shared::Bitmap *ds, int xxx, int yyy, size_t fontNumber, color_t text_color, char *fmt, ...);
+// Allocates two outline stencil buffers, or returns previously creates ones;
+// these buffers are owned by the font, they should not be deleted by the caller.
+void alloc_font_outline_buffers(size_t font_number,
+	Shared::Bitmap **text_stencil, Shared::Bitmap **outline_stencil,
+	int text_width, int text_height, int color_depth);
 // Free particular font's data
 void wfreefont(size_t fontNumber);
 // Free all fonts data
diff --git a/engines/ags/shared/font/ttf_font_renderer.cpp b/engines/ags/shared/font/ttf_font_renderer.cpp
index a8017a6492..e5312725ef 100644
--- a/engines/ags/shared/font/ttf_font_renderer.cpp
+++ b/engines/ags/shared/font/ttf_font_renderer.cpp
@@ -91,7 +91,7 @@ bool TTFFontRenderer::IsBitmapFont() {
 }
 
 bool TTFFontRenderer::LoadFromDiskEx(int fontNumber, int fontSize,
-		const FontRenderParams *params, LoadedFontInfo *load_info) {
+		const FontRenderParams *params, FontMetrics *metrics) {
 	String file_name = String::FromFormat("agsfnt%d.ttf", fontNumber);
 	soff_t lenof = 0;
 	Stream *reader = _GP(AssetMgr)->OpenAsset(file_name, &lenof);
@@ -136,9 +136,9 @@ bool TTFFontRenderer::LoadFromDiskEx(int fontNumber, int fontSize,
 	_fontData[fontNumber].AlFont = alfptr;
 	_fontData[fontNumber].Params = params ? *params : FontRenderParams();
 
-	if (load_info) {
-		load_info->Height = alfont_get_font_height(alfptr);
-		load_info->RealHeight = alfont_get_font_real_height(alfptr);
+	if (metrics) {
+		metrics->Height = alfont_get_font_height(alfptr);
+		metrics->RealHeight = alfont_get_font_real_height(alfptr);
 	}
 
 	return true;
diff --git a/engines/ags/shared/font/ttf_font_renderer.h b/engines/ags/shared/font/ttf_font_renderer.h
index 7ee9a2d8e2..c1e9b1b1db 100644
--- a/engines/ags/shared/font/ttf_font_renderer.h
+++ b/engines/ags/shared/font/ttf_font_renderer.h
@@ -49,7 +49,7 @@ public:
 	// IAGSFontRenderer2 implementation
 	bool IsBitmapFont() override;
 	bool LoadFromDiskEx(int fontNumber, int fontSize, const FontRenderParams *params,
-		LoadedFontInfo *info) override;
+		FontMetrics *metrics) override;
 
 private:
 	struct FontData {
diff --git a/engines/ags/shared/font/wfn_font_renderer.cpp b/engines/ags/shared/font/wfn_font_renderer.cpp
index 78720d4b58..0baa96b6e1 100644
--- a/engines/ags/shared/font/wfn_font_renderer.cpp
+++ b/engines/ags/shared/font/wfn_font_renderer.cpp
@@ -130,7 +130,7 @@ bool WFNFontRenderer::IsBitmapFont() {
 }
 
 bool WFNFontRenderer::LoadFromDiskEx(int fontNumber, int fontSize,
-		const FontRenderParams *params, LoadedFontInfo *load_info) {
+		const FontRenderParams *params, FontMetrics *metrics) {
 	String file_name;
 	Stream *ffi = nullptr;
 	soff_t asset_size = 0;
diff --git a/engines/ags/shared/font/wfn_font_renderer.h b/engines/ags/shared/font/wfn_font_renderer.h
index 24a730f4d9..be07a62eb0 100644
--- a/engines/ags/shared/font/wfn_font_renderer.h
+++ b/engines/ags/shared/font/wfn_font_renderer.h
@@ -47,7 +47,7 @@ public:
 	// IAGSFontRenderer2 implementation
 	bool IsBitmapFont() override;
 	bool LoadFromDiskEx(int fontNumber, int fontSize,
-		const FontRenderParams *params, LoadedFontInfo *info) override;
+		const FontRenderParams *params, FontMetrics *metrics) override;
 
 private:
 	struct FontData {


Commit: 796740e2e1b628e666a990621d28d4e8adf2f13b
    https://github.com/scummvm/scummvm/commit/796740e2e1b628e666a990621d28d4e8adf2f13b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-09-21T18:54:58-07:00

Commit Message:
AGS: Added detection entries

Changed paths:
    engines/ags/detection_tables.h


diff --git a/engines/ags/detection_tables.h b/engines/ags/detection_tables.h
index 76009fc69a..4181ebc2b8 100644
--- a/engines/ags/detection_tables.h
+++ b/engines/ags/detection_tables.h
@@ -1409,6 +1409,8 @@ const PlainGameDescriptor GAME_NAMES[] = {
 	{ "stanamespiepisode1", "Stan Ames PI, Episode 1" },
 	{ "stansrevenge", "Stan's Revenge" },
 	{ "stargateadv", "Stargate Adventure" },
+	{ "stargatesgc", "Stargate SGC" },
+	{ "stargatesolitaire", "Stargate Solitaire" },
 	{ "starshipcaramba", "Starship Caramba" },
 	{ "starshipposeidon", "Starship Poseidon" },
 	{ "starshipquasar", "Starship Quasar" },
@@ -2019,6 +2021,7 @@ const AGSGameDescription GAME_DESCRIPTIONS[] = {
 	GAME_ENTRY_GOG("primordia", "agsgame.dat", "22313e59c3233001488c26f18c80cc08", 973495830), // Linux
 	GAME_ENTRY_STEAM("primordia", "primordia.exe", "f2edc9c3161f1f538df9b4c59fc89e24", 978377182),
 	GAME_ENTRY("primordia", "primordia.exe", "22313e59c3233001488c26f18c80cc08", 973154021), // DVD version
+	GAME_ENTRY("primordia", "primordia.exe", "8f717a5a14ceda815292ce4065348afb", 978722743),
 	GAME_ENTRY_STEAM("puzzlebots", "ac2game.dat", "34b49df9cf6eadb5c3587b3921d5b72f", 787776664),
 	GAME_ENTRY_GOG("qfi", "qfi.exe", "0702df6e67ef87fd3c51d09303803126", 534847265),
 	GAME_ENTRY_GOG("qfi", "qfi.exe", "32b36aebe0729c9360bc10dcddc0653c", 538562096),
@@ -2326,6 +2329,7 @@ const AGSGameDescription GAME_DESCRIPTIONS[] = {
 	GAME_ENTRY("atotk", "atotk.exe", "37cf2d4d07842d45b59c6dd9387c1ee7", 42740200),
 	GAME_ENTRY("atotk", "atotk.exe", "37cf2d4d07842d45b59c6dd9387c1ee7", 42872046),
 	GAME_ENTRY("atotk", "atotk.exe", "68d4f3488a9dcec74584651c0e29e439", 5078309),
+	GAME_ENTRY("atotk", "atotk.ags", "68d4f3488a9dcec74584651c0e29e439", 5078866), // 2.04
 	GAME_ENTRY("atotkjukebox", "jukebox.exe", "37cf2d4d07842d45b59c6dd9387c1ee7", 1631992),
 	GAME_ENTRY("atreatandsometricks", "a treat and some tricks.exe", "495d45fb8adfd49690ae3b97921feec6", 33708250),
 	GAME_ENTRY("aunaturel", "au naturel.exe", "6cddccb3744ec5c6af7c398fb7b3b11c", 8499426),
@@ -3424,6 +3428,10 @@ const AGSGameDescription GAME_DESCRIPTIONS[] = {
 	GAME_ENTRY("stanamespiepisode1", "NEW.exe", "f120690b506dd63cd7d1112ea6af2f77", 19194728),
 	GAME_ENTRY("stansrevenge", "Gameisle.exe", "3b7cceb3e4bdb031dc5d8f290936e94b", 915036),
 	GAME_ENTRY("stargateadv", "StarGA.exe", "0710e2ec71042617f565c01824f0cf3c", 45738298),
+	GAME_ENTRY("stargateadv", "StarGA.exe", "0710e2ec71042617f565c01824f0cf3c", 45664346),
+	GAME_ENTRY("stargateadv", "StarGA.exe", "0710e2ec71042617f565c01824f0cf3c", 45662205),
+	GAME_ENTRY("stargatesgc", "Stargate SGC.exe", "bdaf20d9779c01986d6d8b7e1d6118ee", 2188193),
+	GAME_ENTRY("stargatesolitaire", "SolitaireSG1.exe", "5529522460cb27d6a4f2619aee618590", 11658638),
 	GAME_ENTRY("starshipcaramba", "karamba.exe", "465f972675db2da6040518221af5b0ba", 21540340),
 	GAME_ENTRY("starshipposeidon", "Starship Poseidon.exe", "5a9abb3094d0b3f4bc09c0c77fbb8024", 4163873),
 	GAME_ENTRY("starshipquasar", "quasar.exe", "8d1c6698abc66509df3dbe57a0a4144b", 11959826), // v1.1




More information about the Scummvm-git-logs mailing list