[Scummvm-git-logs] scummvm master -> 96b0274fcc9a857dde85efc356b01d61cf576da0

sev- noreply at scummvm.org
Fri Jun 23 10:10:38 UTC 2023


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:
ae89982ded GRAPHICS: Handle null advances and boxes in BdfFonts::scaleFont
96b0274fcc GUI: Scale fonts for classic theme


Commit: ae89982ded2a4831ae4fc3cd577ffbace1e83dcd
    https://github.com/scummvm/scummvm/commit/ae89982ded2a4831ae4fc3cd577ffbace1e83dcd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-06-23T12:03:16+02:00

Commit Message:
GRAPHICS: Handle null advances and boxes in BdfFonts::scaleFont

Changed paths:
    graphics/fonts/bdf.cpp


diff --git a/graphics/fonts/bdf.cpp b/graphics/fonts/bdf.cpp
index 06c57c948c7..414d5338d30 100644
--- a/graphics/fonts/bdf.cpp
+++ b/graphics/fonts/bdf.cpp
@@ -771,20 +771,30 @@ BdfFont *BdfFont::scaleFont(const BdfFont *src, int newSize) {
 	Common::strcpy_s(slant, sz, src->_data.slant);
 	data.slant = slant;
 
-	BdfBoundingBox *boxes = new BdfBoundingBox[data.numCharacters];
-	for (int i = 0; i < data.numCharacters; ++i) {
-		boxes[i].width = (int)(((float)src->_data.boxes[i].width * scale));
-		boxes[i].height = (int)(((float)src->_data.height * scale));
-		boxes[i].xOffset = (int)(((float)src->_data.boxes[i].xOffset * scale));
-		boxes[i].yOffset = (int)(((float)src->_data.boxes[i].yOffset * scale));
+	if (src->_data.boxes) {
+		BdfBoundingBox *boxes = new BdfBoundingBox[data.numCharacters];
+		for (int i = 0; i < data.numCharacters; ++i) {
+			boxes[i].width = (int)(((float)src->_data.boxes[i].width * scale));
+			boxes[i].height = (int)(((float)src->_data.height * scale));
+			boxes[i].xOffset = (int)(((float)src->_data.boxes[i].xOffset * scale));
+			boxes[i].yOffset = (int)(((float)src->_data.boxes[i].yOffset * scale));
+		}
+		data.boxes = boxes;
+	} else {
+		// if the sources have null boxes
+		data.boxes = nullptr;
 	}
-	data.boxes = boxes;
 
-	byte *advances = new byte[data.numCharacters];
-	for (int i = 0; i < data.numCharacters; ++i) {
-		advances[i] = (int)(roundf((float)src->_data.advances[i] * scale));
+	if (src->_data.advances) {
+		byte *advances = new byte[data.numCharacters];
+		for (int i = 0; i < data.numCharacters; ++i) {
+			advances[i] = (int)(roundf((float)src->_data.advances[i] * scale));
+		}
+		data.advances = advances;
+	} else {
+		// if the sources have null advances
+		data.advances = nullptr;
 	}
-	data.advances = advances;
 
 	byte **bitmaps = new byte *[data.numCharacters];
 	for (int i = 0; i < data.numCharacters; i++) {
@@ -800,8 +810,14 @@ BdfFont *BdfFont::scaleFont(const BdfFont *src, int newSize) {
 			const int bytes = dstPitch * box.height;
 			bitmaps[i] = new byte[bytes];
 
-			src->scaleSingleGlyph(&srcSurf, dstGray, dstGraySize, box.width, box.height, box.xOffset, box.yOffset, grayLevel, i + src->_data.firstCharacter,
-								src->_data.height, srcBox.width, scale);
+			int srcBoxWidth = 0;
+			if (src->_data.boxes) {
+				srcBoxWidth = srcBox.width;
+			} else {
+				srcBoxWidth = src->_data.defaultBox.width;
+			}
+			src->scaleSingleGlyph(&srcSurf, dstGray, dstGraySize, box.width, box.height, 0, box.yOffset, grayLevel, i + src->_data.firstCharacter,
+								src->_data.height, srcBoxWidth, scale);
 
 			byte *ptr = bitmaps[i];
 			for (int y = 0; y < box.height; y++) {


Commit: 96b0274fcc9a857dde85efc356b01d61cf576da0
    https://github.com/scummvm/scummvm/commit/96b0274fcc9a857dde85efc356b01d61cf576da0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-06-23T12:08:56+02:00

Commit Message:
GUI: Scale fonts for classic theme

Changed paths:
    gui/ThemeEngine.cpp


diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index 7443f802c37..e81f9354e31 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -1777,9 +1777,12 @@ const Graphics::Font *ThemeEngine::loadFont(const Common::String &filename, cons
 #ifdef USE_TRANSLATION
 	allowNonScalable = TransMan.currentIsBuiltinLanguage();
 #endif
-	if (!font && allowNonScalable)
+	if (!font && allowNonScalable) {
 		font = loadFont(filename, fontName);
 
+		//font = Graphics::BdfFont::scaleFont((const Graphics::BdfFont *)font, pointsize);
+	}
+
 	// If the font is successfully loaded store it in the font manager.
 	if (font) {
 		FontMan.assignFontToName(fontName, font);




More information about the Scummvm-git-logs mailing list