[Scummvm-git-logs] scummvm master -> 60464f19d53d1c3fd1dacb5ad2cf1912c73b2ea2

Scorpeg noreply at scummvm.org
Thu Nov 19 15:51:21 UTC 2026


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

Summary:
1fbb6a4c31 GRAPHICS: Add FreeType glyph and stroker wrappers
60464f19d5 HAROLD: BCB: Update translation loading and FreeType rendering


Commit: 1fbb6a4c3124b690ec025d0261dc946b8c7cb753
    https://github.com/scummvm/scummvm/commit/1fbb6a4c3124b690ec025d0261dc946b8c7cb753
Author: Scorp (scorp at mrs.mn)
Date: 2026-11-19T18:50:25+03:00

Commit Message:
GRAPHICS: Add FreeType glyph and stroker wrappers

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


diff --git a/graphics/fonts/freetype.cpp b/graphics/fonts/freetype.cpp
index 67a91ec0fd8..cfcaec15062 100644
--- a/graphics/fonts/freetype.cpp
+++ b/graphics/fonts/freetype.cpp
@@ -31,6 +31,7 @@
 #include FT_FREETYPE_H
 #include FT_GLYPH_H
 #include FT_MODULE_H
+#include FT_STROKER_H
 
 namespace Graphics {
 namespace FreeType {
@@ -94,6 +95,27 @@ FT_Error Glyph_Copy(FT_Glyph source, FT_Glyph *target) {
 	return FT_Glyph_Copy(source, target);
 }
 
+void Glyph_Get_CBox(FT_Glyph glyph, FT_UInt bbox_mode, FT_BBox *acbox) {
+	FT_Glyph_Get_CBox(glyph, bbox_mode, acbox);
+}
+
+FT_Error Glyph_StrokeBorder(FT_Glyph *pglyph, FT_Stroker stroker, FT_Bool inside, FT_Bool destroy) {
+	return FT_Glyph_StrokeBorder(pglyph, stroker, inside, destroy);
+}
+
+FT_Error Stroker_New(FT_Library library, FT_Stroker *astroker) {
+	return FT_Stroker_New(library, astroker);
+}
+
+void Stroker_Set(FT_Stroker stroker, FT_Fixed radius, FT_Stroker_LineCap line_cap,
+		FT_Stroker_LineJoin line_join, FT_Fixed miter_limit) {
+	FT_Stroker_Set(stroker, radius, line_cap, line_join, miter_limit);
+}
+
+void Stroker_Done(FT_Stroker stroker) {
+	FT_Stroker_Done(stroker);
+}
+
 FT_Error Glyph_To_Bitmap(FT_Glyph *the_glyph, FT_Render_Mode render_mode,
 		FT_Vector *origin, FT_Bool destroy) {
 	return FT_Glyph_To_Bitmap(the_glyph, render_mode, origin, destroy);
@@ -108,6 +130,10 @@ FT_Error Set_Pixel_Sizes(FT_Face face, FT_UInt pixel_width,
 	return FT_Set_Pixel_Sizes(face, pixel_width, pixel_height);
 }
 
+FT_Error Request_Size(FT_Face face, FT_Size_Request req) {
+	return FT_Request_Size(face, req);
+}
+
 FT_Error New_Face(FT_Library library, const char *pathname,
 		FT_Long face_index, FT_Face *aface) {
 	return FT_New_Face(library, pathname, face_index, aface);
diff --git a/graphics/fonts/freetype.h b/graphics/fonts/freetype.h
index abf11495403..9bc5c934f03 100644
--- a/graphics/fonts/freetype.h
+++ b/graphics/fonts/freetype.h
@@ -28,6 +28,7 @@
 #include <ft2build.h>
 #include FT_FREETYPE_H
 #include FT_GLYPH_H
+#include FT_STROKER_H
 
 namespace Graphics {
 namespace FreeType {
@@ -39,11 +40,18 @@ extern FT_Error Done_FreeType_With_Mem(FT_Library library, FT_Memory mem);
 extern FT_Error Load_Glyph(FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags);
 extern FT_Error Get_Glyph(FT_GlyphSlot slot, FT_Glyph *aglyph);
 extern FT_Error Glyph_Copy(FT_Glyph source, FT_Glyph *target);
+extern void Glyph_Get_CBox(FT_Glyph glyph, FT_UInt bbox_mode, FT_BBox *acbox);
 extern FT_Error Glyph_To_Bitmap(FT_Glyph *the_glyph, FT_Render_Mode render_mode,
 	FT_Vector *origin, FT_Bool destroy);
+extern FT_Error Glyph_StrokeBorder(FT_Glyph *pglyph, FT_Stroker stroker, FT_Bool inside, FT_Bool destroy);
+extern FT_Error Stroker_New(FT_Library library, FT_Stroker *astroker);
+extern void Stroker_Set(FT_Stroker stroker, FT_Fixed radius, FT_Stroker_LineCap line_cap,
+	FT_Stroker_LineJoin line_join, FT_Fixed miter_limit);
+extern void Stroker_Done(FT_Stroker stroker);
 extern void Done_Glyph(FT_Glyph glyph);
 extern FT_Error Set_Pixel_Sizes(FT_Face face, FT_UInt pixel_width,
 	FT_UInt pixel_height);
+extern FT_Error Request_Size(FT_Face face, FT_Size_Request req);
 extern FT_Error New_Face(FT_Library library, const char *pathname,
 	FT_Long face_index, FT_Face *aface);
 extern FT_Error New_Memory_Face(FT_Library library, const FT_Byte *file_base,
@@ -59,4 +67,3 @@ extern FT_Error Get_Kerning(FT_Face face, FT_UInt left_glyph,
 #endif
 
 #endif
-


Commit: 60464f19d53d1c3fd1dacb5ad2cf1912c73b2ea2
    https://github.com/scummvm/scummvm/commit/60464f19d53d1c3fd1dacb5ad2cf1912c73b2ea2
Author: Scorp (scorp at mrs.mn)
Date: 2026-11-19T18:51:00+03:00

Commit Message:
HAROLD: BCB: Update translation loading and FreeType rendering

Changed paths:
    engines/harold/bcb/options.cpp
    engines/harold/bcb/text_renderer.cpp
    engines/harold/bcb/translation.cpp
    engines/harold/bcb/translation.h


diff --git a/engines/harold/bcb/options.cpp b/engines/harold/bcb/options.cpp
index d6089bb2afd..ba2c7a6d56f 100644
--- a/engines/harold/bcb/options.cpp
+++ b/engines/harold/bcb/options.cpp
@@ -69,7 +69,7 @@ BCBOptionsWidget::BCBOptionsWidget(GUI::GuiObject *boss, const Common::String &n
 
 	const Common::FSNode gameDataDir(ConfMan.getPath("path", domain));
 	Common::Array<TranslationPackageDefinition> packages;
-	listAvailableTranslationPackages(gameDataDir, packages);
+	listAvailableTranslationPackages(gameDataDir, packages, domain);
 	for (uint i = 0; i < packages.size(); ++i) {
 		const TranslationPackageDefinition &package = packages[i];
 		_languageCodes.push_back(package.code);
diff --git a/engines/harold/bcb/text_renderer.cpp b/engines/harold/bcb/text_renderer.cpp
index 0b7d2316244..a21deadfae8 100644
--- a/engines/harold/bcb/text_renderer.cpp
+++ b/engines/harold/bcb/text_renderer.cpp
@@ -149,7 +149,7 @@ bool getPillowTextMaskMetrics(FT_Face face, const Common::Array<PillowGlyphInfo>
 			return false;
 
 		FT_BBox bbox;
-		FT_Glyph_Get_CBox(glyph, FT_GLYPH_BBOX_PIXELS, &bbox);
+		Graphics::FreeType::Glyph_Get_CBox(glyph, FT_GLYPH_BBOX_PIXELS, &bbox);
 		Graphics::FreeType::Done_Glyph(glyph);
 
 		bboxXMin = MIN<int>(bboxXMin, bbox.xMin + px);
@@ -229,9 +229,9 @@ bool drawFreeTypeTextPass(Graphics::Surface &surface, FT_Face face, const Common
 
 	FT_Stroker stroker = nullptr;
 	if (strokeOnly) {
-		if (FT_Stroker_New(face->glyph->library, &stroker))
+		if (Graphics::FreeType::Stroker_New(face->glyph->library, &stroker))
 			return false;
-		FT_Stroker_Set(stroker, (FT_Fixed)round(strokeWidth * 64.0), FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0);
+		Graphics::FreeType::Stroker_Set(stroker, (FT_Fixed)round(strokeWidth * 64.0), FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0);
 	}
 
 	FT_Pos penX = 0;
@@ -242,20 +242,20 @@ bool drawFreeTypeTextPass(Graphics::Surface &surface, FT_Face face, const Common
 		const int py = ftPixel(originY);
 		if (Graphics::FreeType::Load_Glyph(face, glyphs[i].index, loadFlags)) {
 			if (stroker)
-				FT_Stroker_Done(stroker);
+				Graphics::FreeType::Stroker_Done(stroker);
 			return false;
 		}
 
 		if (strokeOnly) {
 			FT_Glyph glyph;
 			if (Graphics::FreeType::Get_Glyph(face->glyph, &glyph)) {
-				FT_Stroker_Done(stroker);
+				Graphics::FreeType::Stroker_Done(stroker);
 				return false;
 			}
-			if (FT_Glyph_StrokeBorder(&glyph, stroker, 0, 1) ||
+			if (Graphics::FreeType::Glyph_StrokeBorder(&glyph, stroker, 0, 1) ||
 				Graphics::FreeType::Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, nullptr, 1)) {
 				Graphics::FreeType::Done_Glyph(glyph);
-				FT_Stroker_Done(stroker);
+				Graphics::FreeType::Stroker_Done(stroker);
 				return false;
 			}
 			FT_BitmapGlyph bitmapGlyph = (FT_BitmapGlyph)glyph;
@@ -274,7 +274,7 @@ bool drawFreeTypeTextPass(Graphics::Surface &surface, FT_Face face, const Common
 	}
 
 	if (stroker)
-		FT_Stroker_Done(stroker);
+		Graphics::FreeType::Stroker_Done(stroker);
 	return true;
 }
 
@@ -291,7 +291,7 @@ bool drawFreeTypeTextLine(Graphics::Surface &surface, FT_Face face, int size,
 		request.type = FT_SIZE_REQUEST_TYPE_NOMINAL;
 		request.width = size * 64;
 		request.height = size * 64;
-		ok = !FT_Request_Size(face, &request);
+		ok = !Graphics::FreeType::Request_Size(face, &request);
 	}
 
 	Common::Array<PillowGlyphInfo> glyphs;
diff --git a/engines/harold/bcb/translation.cpp b/engines/harold/bcb/translation.cpp
index f687e90f656..3dd81bf65b4 100644
--- a/engines/harold/bcb/translation.cpp
+++ b/engines/harold/bcb/translation.cpp
@@ -21,6 +21,7 @@
 
 #include "common/archive.h"
 #include "common/compression/unzip.h"
+#include "common/config-manager.h"
 #include "common/fs.h"
 #include "common/language.h"
 #include "common/ptr.h"
@@ -45,6 +46,8 @@ bool getTranslationPackageCode(const Common::String &fileName, Common::String &c
 
 	Common::String lowerFileName = fileName;
 	lowerFileName.toLowercase();
+	if (lowerFileName.hasPrefix("bcb_translation_"))
+		lowerFileName = Common::String(prefix) + lowerFileName.substr(strlen("bcb_translation_"));
 	if (!lowerFileName.hasPrefix(prefix) || !lowerFileName.hasSuffix(suffix))
 		return false;
 
@@ -210,27 +213,66 @@ Common::String makeTextStringKey(TextTranslationType type, uint primaryId, uint
 	return "";
 }
 
-void listAvailableTranslationPackages(const Common::FSNode &gameDataDir, Common::Array<TranslationPackageDefinition> &packages) {
-	packages.clear();
+static TranslationPackageDefinition &findOrAddTranslation(Common::Array<TranslationPackageDefinition> &packages, const Common::String &code) {
+	for (auto &package : packages)
+		if (package.code.equalsIgnoreCase(code))
+			return package;
+	TranslationPackageDefinition definition;
+	definition.code = code;
+	definition.displayName = getTranslationPackageDisplayName(code);
+	packages.push_back(definition);
+	return packages.back();
+}
 
+static void findLooseTranslations(const Common::FSNode &dir, Common::Array<TranslationPackageDefinition> &packages, const Common::String &directoryCode = Common::String()) {
 	Common::FSList children;
-	if (!gameDataDir.getChildren(children, Common::FSNode::kListFilesOnly))
+	if (!dir.isDirectory() || !dir.getChildren(children, Common::FSNode::kListFilesOnly))
 		return;
+	for (const auto &child : children) {
+		Common::String name = child.getName();
+		name.toLowercase();
+		if (name.hasPrefix("strings_") && name.hasSuffix(".yml") && name.size() > 12) {
+			const Common::String code = name.substr(8, name.size() - 12);
+			if (directoryCode.empty() || code.equalsIgnoreCase(directoryCode))
+				findOrAddTranslation(packages, code);
+		}
+	}
+}
 
-	for (Common::FSList::const_iterator it = children.begin(); it != children.end(); ++it) {
-		Common::String code;
-		const Common::String fileName = it->getName();
-		if (!getTranslationPackageCode(fileName, code))
-			continue;
-		if (!packageHasMatchingStrings(*it, code))
-			continue;
+static Common::FSNode findLanguageDirectory(const Common::FSNode &dir, const Common::String &code) {
+	Common::FSList children;
+	if (dir.isDirectory() && dir.getChildren(children, Common::FSNode::kListDirectoriesOnly))
+		for (const auto &child : children)
+			if (child.getName().equalsIgnoreCase(code))
+				return child;
+	return Common::FSNode();
+}
 
-		TranslationPackageDefinition definition;
-		definition.code = code;
-		definition.displayName = getTranslationPackageDisplayName(code);
-		definition.fileName = fileName;
-		packages.push_back(definition);
+static void findTranslationSources(const Common::FSNode &root, Common::Array<TranslationPackageDefinition> &packages) {
+	Common::FSList children;
+	if (root.isDirectory() && root.getChildren(children, Common::FSNode::kListFilesOnly)) {
+		for (const auto &child : children) {
+			Common::String code;
+			if (getTranslationPackageCode(child.getName(), code) && packageHasMatchingStrings(child, code)) {
+				TranslationPackageDefinition &package = findOrAddTranslation(packages, code);
+				if (package.archivePath.empty())
+					package.archivePath = child.getPath();
+			}
+		}
 	}
+	const Common::FSNode dir = root.getChild("translation");
+	findLooseTranslations(dir, packages);
+	children.clear();
+	if (dir.isDirectory() && dir.getChildren(children, Common::FSNode::kListDirectoriesOnly))
+		for (const auto &child : children)
+			findLooseTranslations(child, packages, child.getName());
+}
+
+void listAvailableTranslationPackages(const Common::FSNode &gameDataDir, Common::Array<TranslationPackageDefinition> &packages, const Common::String &target) {
+	packages.clear();
+	findTranslationSources(gameDataDir, packages);
+	if (ConfMan.hasKey("extrapath", target))
+		findTranslationSources(Common::FSNode(ConfMan.getPath("extrapath", target)), packages);
 }
 
 bool isTranslationPackageAvailable(const Common::FSNode &gameDataDir, const Common::String &code) {
@@ -247,19 +289,40 @@ bool loadTranslationPackage(const Common::FSNode &gameDataDir, const Common::Str
 
 	Common::Array<TranslationPackageDefinition> packages;
 	listAvailableTranslationPackages(gameDataDir, packages);
-	Common::String fileName;
+	Common::Path archivePath;
+	bool found = false;
 	for (const auto &package : packages) {
 		if (package.code.equalsIgnoreCase(code)) {
-			fileName = package.fileName;
+			archivePath = package.archivePath;
+			found = true;
 			break;
 		}
 	}
-	if (fileName.empty())
-		return false;
-	const Common::FSNode packageNode = gameDataDir.getChild(fileName);
-	translation.packageArchive = Common::makeZipArchive(packageNode, false);
-	if (!translation.packageArchive)
+	if (!found)
 		return false;
+	Common::SearchSet *sources = new Common::SearchSet();
+	translation.packageArchive = sources;
+	if (!archivePath.empty()) {
+		Common::Archive *archive = Common::makeZipArchive(Common::FSNode(archivePath), false);
+		if (archive)
+			sources->add("translation archive", archive, 0);
+	}
+	const Common::FSNode looseDir = gameDataDir.getChild("translation");
+	if (looseDir.isDirectory()) {
+		sources->addDirectory("game translation", looseDir, 1, 3);
+		const Common::FSNode languageDir = findLanguageDirectory(looseDir, code);
+		if (languageDir.isDirectory())
+			sources->addDirectory("game language translation", languageDir, 2, 3);
+	}
+	if (ConfMan.hasKey("extrapath")) {
+		const Common::FSNode extraDir = Common::FSNode(ConfMan.getPath("extrapath")).getChild("translation");
+		if (extraDir.isDirectory()) {
+			sources->addDirectory("extra translation", extraDir, 3, 3);
+			const Common::FSNode languageDir = findLanguageDirectory(extraDir, code);
+			if (languageDir.isDirectory())
+				sources->addDirectory("extra language translation", languageDir, 4, 3);
+		}
+	}
 
 	if (!translation.strings.load(translation.packageArchive->createReadStreamForMember(Common::Path(getTranslationStringFileName(code), '/')))) {
 		translation.clear();
diff --git a/engines/harold/bcb/translation.h b/engines/harold/bcb/translation.h
index d098c8008ea..256de3090b0 100644
--- a/engines/harold/bcb/translation.h
+++ b/engines/harold/bcb/translation.h
@@ -24,6 +24,7 @@
 
 #include "common/array.h"
 #include "common/hash-str.h"
+#include "common/path.h"
 #include "common/scummsys.h"
 #include "common/str.h"
 
@@ -44,7 +45,7 @@ class HighQualityTextRenderer;
 struct TranslationPackageDefinition {
 	Common::String code;
 	Common::String displayName;
-	Common::String fileName;
+	Common::Path archivePath;
 };
 
 enum TextTranslationType {
@@ -74,7 +75,7 @@ public:
 };
 
 Common::String makeTextStringKey(TextTranslationType type, uint primaryId, uint secondaryId);
-void listAvailableTranslationPackages(const Common::FSNode &gameDataDir, Common::Array<TranslationPackageDefinition> &packages);
+void listAvailableTranslationPackages(const Common::FSNode &gameDataDir, Common::Array<TranslationPackageDefinition> &packages, const Common::String &target = Common::String());
 bool isTranslationPackageAvailable(const Common::FSNode &gameDataDir, const Common::String &code);
 bool loadTranslationPackage(const Common::FSNode &gameDataDir, const Common::String &code, TextTranslationData &translation);
 bool applyPatchImage(Graphics::Surface &surface, Common::SeekableReadStream *stream, const char *debugName);




More information about the Scummvm-git-logs mailing list