[Scummvm-git-logs] scummvm master -> 8c8a710d80394a7c60456cfdfded46d222c5ee21

sev- sev at scummvm.org
Tue Jan 7 20:57:29 UTC 2020


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

Summary:
bfd796fec2 GRAPHICS: MACGUI: Use regular slant as font substitutes
f7970c30a4 GRAPHICS: FONTS: Fix BDF font scaling
90c305c904 GRAPHICS: FONTS: Use better algorithm for MacFONT scaling added debug output
b5a95d4783 GRAPHICS: FONTS: Made scaling form MacFONT as a step
fc00b78a48 GRAPHICS: FONTS: Implement generation of bold fonts
8c8a710d80 GRAPHICS: MACGUI: Generate bold font substitutes in MacFontManager


Commit: bfd796fec2e723bb3a43e672fcddf2dfd5108ccf
    https://github.com/scummvm/scummvm/commit/bfd796fec2e723bb3a43e672fcddf2dfd5108ccf
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-01-07T21:57:12+01:00

Commit Message:
GRAPHICS: MACGUI: Use regular slant as font substitutes

Changed paths:
    graphics/macgui/macfontmanager.cpp


diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp
index e8e3d43..151a3d9 100644
--- a/graphics/macgui/macfontmanager.cpp
+++ b/graphics/macgui/macfontmanager.cpp
@@ -405,35 +405,53 @@ void MacFontManager::generateFontSubstitute(MacFont &macFont) {
 	// No simple substitute was found. Looking for neighborhood fonts
 
 	// First we gather all font sizes for this font
-	Common::Array<int> sizes;
+	Common::Array<MacFont *> sizes;
 	for (Common::HashMap<Common::String, MacFont *>::iterator i = _fontRegistry.begin(); i != _fontRegistry.end(); ++i) {
 		if (i->_value->getId() == macFont.getId() && i->_value->getSlant() == macFont.getSlant() && !i->_value->isGenerated())
-			sizes.push_back(i->_value->getSize());
+			sizes.push_back(i->_value);
 	}
 
 	if (sizes.empty()) {
-		debug(1, "No viable substitute found for font %s", getFontName(macFont).c_str());
-		return;
+		if (macFont.getSlant() == kMacFontRegular) {
+			debug(1, "No viable substitute found for font %s", getFontName(macFont).c_str());
+			return;
+		}
+
+		// Now let's try to find a regular font
+		for (Common::HashMap<Common::String, MacFont *>::iterator i = _fontRegistry.begin(); i != _fontRegistry.end(); ++i) {
+			if (i->_value->getId() == macFont.getId() && i->_value->getSlant() == kMacFontRegular && !i->_value->isGenerated())
+				sizes.push_back(i->_value);
+		}
+
+		if (sizes.empty()) {
+			debug(1, "No viable substitute found for font %s", getFontName(macFont).c_str());
+			return;
+		}
 	}
 
-	// Now looking next larger font, and store the largest one for next check
-	int candidate = 1000;
-	int maxSize = sizes[0];
+	// Now looking for the next larger font, and store the largest one for next check
+	MacFont *candidate = nullptr;
+	MacFont *maxSize = sizes[0];
 	for (uint i = 0; i < sizes.size(); i++) {
-		if (sizes[i] > macFont.getSize() && sizes[i] < candidate)
+		if (sizes[i]->getSize() == macFont.getSize()) { // Same size but regular slant
+			candidate = sizes[i];
+			break;
+		}
+
+		if (sizes[i]->getSize() > macFont.getSize() && candidate && sizes[i]->getSize() < candidate->getSize())
 			candidate = sizes[i];
 
-		if (sizes[i] > maxSize)
+		if (sizes[i]->getSize() > maxSize->getSize())
 			maxSize = sizes[i];
 	}
 
-	if (candidate != 1000) {
-		generateFont(macFont, *_fontRegistry[getFontName(macFont.getId(), candidate, macFont.getSlant())]);
+	if (candidate) {
+		generateFont(macFont, *candidate);
 		return;
 	}
 
 	// Now next smaller font, which is the biggest we have
-	generateFont(macFont, *_fontRegistry[getFontName(macFont.getId(), maxSize, macFont.getSlant())]);
+	generateFont(macFont, *maxSize);
 }
 
 void MacFontManager::generateFont(MacFont &toFont, MacFont &fromFont) {


Commit: f7970c30a4a2ace45dc98f2d4d0cd3be1114ba65
    https://github.com/scummvm/scummvm/commit/f7970c30a4a2ace45dc98f2d4d0cd3be1114ba65
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-01-07T21:57:12+01:00

Commit Message:
GRAPHICS: FONTS: Fix BDF font scaling

Changed paths:
    graphics/fonts/bdf.cpp


diff --git a/graphics/fonts/bdf.cpp b/graphics/fonts/bdf.cpp
index 4374c36..d901d1b 100644
--- a/graphics/fonts/bdf.cpp
+++ b/graphics/fonts/bdf.cpp
@@ -767,17 +767,17 @@ BdfFont *BdfFont::scaleFont(BdfFont *src, int newSize) {
 				byte b = 0;
 
 				for (int x = 0; x < box.width; x++) {
+					b <<= 1;
+
 					int sx = (int)((float)x / scale);
 
 					if (srcd[sx / 8] & (0x80 >> (sx % 8)))
 						b |= 1;
 
-					if (!(x % 8) && x) {
+					if (x % 8 == 7) {
 						*dst++ = b;
 						b = 0;
 					}
-
-					b <<= 1;
 				}
 
 				if (((box.width - 1) % 8)) {


Commit: 90c305c9049d2ac96acb79aaf82ca3bab9be9624
    https://github.com/scummvm/scummvm/commit/90c305c9049d2ac96acb79aaf82ca3bab9be9624
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-01-07T21:57:12+01:00

Commit Message:
GRAPHICS: FONTS: Use better algorithm for MacFONT scaling added debug output

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


diff --git a/graphics/fonts/macfont.cpp b/graphics/fonts/macfont.cpp
index 4264f64..5400497 100644
--- a/graphics/fonts/macfont.cpp
+++ b/graphics/fonts/macfont.cpp
@@ -25,6 +25,8 @@
 #include "graphics/managed_surface.h"
 #include "graphics/fonts/macfont.h"
 
+#define DEBUGSCALING 0
+
 namespace Graphics {
 
 enum {
@@ -393,6 +395,10 @@ int MacFONTFont::getKerningOffset(uint32 left, uint32 right) const {
 	return 0;
 }
 
+#if DEBUGSCALING
+bool dododo;
+#endif
+
 MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize) {
 	if (!src) {
 		warning("Empty font reference in scale font");
@@ -404,6 +410,11 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize) {
 		return NULL;
 	}
 
+	Graphics::Surface srcSurf;
+	srcSurf.create(src->getFontSize() * 3, src->getFontSize() * 3, PixelFormat::createFormatCLUT8());
+	int dstGraySize = newSize * 3 * newSize * 3;
+	int *dstGray = (int *)malloc(dstGraySize * sizeof(int));
+
 	float scale = (float)newSize / (float)src->getFontSize();
 
 	MacFONTdata data;
@@ -427,7 +438,7 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize) {
 
 	data._glyphs.resize(src->_data._glyphs.size());
 
-	// Dtermine width of the bit image table
+	// Determine width of the bit image table
 	int newBitmapWidth = 0;
 	for (uint i = 0; i < src->_data._glyphs.size() + 1; i++) {
 		MacGlyph *glyph = (i == src->_data._glyphs.size()) ? &data._defaultChar : &data._glyphs[i];
@@ -435,7 +446,7 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize) {
 
 		glyph->width = (int)((float)srcglyph->width * scale);
 		glyph->kerningOffset = (int)((float)srcglyph->kerningOffset * scale);
-		glyph->bitmapWidth = (int)((float)srcglyph->bitmapWidth * scale);
+		glyph->bitmapWidth = glyph->width; //(int)((float)srcglyph->bitmapWidth * scale);
 		glyph->bitmapOffset = newBitmapWidth;
 
 		newBitmapWidth += (glyph->bitmapWidth + 7) & ~0x7;
@@ -446,45 +457,146 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize) {
 	uint bitImageSize = data._rowWords * data._fRectHeight;
 	data._bitImage = new byte[bitImageSize];
 
-	int srcPitch = src->_data._rowWords;
 	int dstPitch = data._rowWords;
 
 	for (uint i = 0; i < src->_data._glyphs.size() + 1; i++) {
 		const MacGlyph *srcglyph = (i == src->_data._glyphs.size()) ? &src->_data._defaultChar : &src->_data._glyphs[i];
+
+		int grayLevel = src->_data._fRectHeight * srcglyph->width / 4;
+
+#if DEBUGSCALING
+		int ccc = 'c';
+		dododo = i == ccc;
+#endif
+
+		srcSurf.fillRect(Common::Rect(srcSurf.w, srcSurf.h), 0);
+		src->drawChar(&srcSurf, i + src->_data._firstChar, 0, 0, 1);
+		memset(dstGray, 0, dstGraySize * sizeof(int));
+		src->magnifyGray(&srcSurf, srcglyph, dstGray, scale);
+
 		MacGlyph *glyph = (i == src->_data._glyphs.size()) ? &data._defaultChar : &data._glyphs[i];
 		byte *ptr = &data._bitImage[glyph->bitmapOffset / 8];
+		int *grayPtr = dstGray;
 
 		for (int y = 0; y < data._fRectHeight; y++) {
-			const byte *srcd = (const byte *)&src->_data._bitImage[((int)((float)y / scale)) * srcPitch];
 			byte *dst = ptr;
 			byte b = 0;
 
-			for (int x = 0; x < glyph->width; x++) {
-				int sx = (int)((float)x / scale) + srcglyph->bitmapOffset;
+			for (int x = 0; x < glyph->width; x++, grayPtr++) {
+				b <<= 1;
+
+#if DEBUGSCALING
+				if (i == ccc) {
+					if (*grayPtr)
+						debugN(1, "%3d ", *grayPtr);
+					else
+						debugN(1, "    ");
+				}
+#endif
 
-				if (srcd[sx / 8] & (0x80 >> (sx % 8)))
+				if (*grayPtr > grayLevel)
 					b |= 1;
 
-				if (!(x % 8) && x) {
+				if (x % 8 == 7) {
 					*dst++ = b;
 					b = 0;
 				}
+			}
 
-				b <<= 1;
+#if DEBUGSCALING
+			if (i == ccc) {
+				debugN(1, "--> %d ", grayLevel);
+
+				grayPtr = &dstGray[y * glyph->width];
+				for (int x = 0; x < glyph->width; x++, grayPtr++)
+					debugN("%c", *grayPtr > grayLevel ? '#' : '.');
 			}
+#endif
 
 			if (((glyph->width - 1) % 8)) {
+#if DEBUGSCALING
+				if (i == ccc)
+					debugN("  --- %02x (w: %d bw: %d << %d)", b, glyph->width, glyph->bitmapWidth, 7 - ((glyph->width - 1) % 8));
+#endif
+
 				b <<= 7 - ((glyph->width - 1) % 8);
 				*dst = b;
+
+#if DEBUGSCALING
+				if (i == ccc)
+					debugN("  --- %02x ", b);
+#endif
 			}
 
+#if DEBUGSCALING
+			if (i == ccc) {
+				byte *srcRow = data._bitImage + y * data._rowWords;
+
+				for (uint16 x = 0; x < glyph->bitmapWidth; x++) {
+					uint16 bitmapOffset = glyph->bitmapOffset + x;
+
+					debugN("%c", srcRow[bitmapOffset / 8] & (1 << (7 - (bitmapOffset % 8))) ? '*' : '.');
+				}
+
+				debug("");
+			}
+#endif
+
 			ptr += dstPitch;
 		}
 	}
 
+	srcSurf.free();
+	free(dstGray);
+
 	return new MacFONTFont(data);
 }
 
+#define howmany(x, y)	(((x)+((y)-1))/(y))
+
+static void countupScore(int *dstGray, int x, int y, int bbw, int bbh, float scale) {
+	int newbbw = bbw * scale;
+	int newbbh = bbh * scale;
+	int x_ = x * newbbw;
+	int y_ = y * newbbh;
+	int x1 = x_ + newbbw;
+	int y1 = y_ + newbbh;
+
+	int newxbegin = x_ / bbw;
+	int newybegin = y_ / bbh;
+	int newxend = howmany(x1, bbw);
+	int newyend = howmany(y1, bbh);
+
+	for (int newy = newybegin; newy < newyend; newy++) {
+		for (int newx = newxbegin; newx < newxend; newx++) {
+			int newX = newx * bbw;
+			int newY = newy * bbh;
+			int newX1 = newX + bbw;
+			int newY1 = newY + bbh;
+			dstGray[newy * newbbw + newx] += (MIN(x1, newX1) - MAX(x_, newX)) *
+											 (MIN(y1, newY1) - MAX(y_, newY));
+		}
+	}
+}
+
+void MacFONTFont::magnifyGray(Surface *src, const MacGlyph *glyph, int *dstGray, float scale) const {
+	for (uint16 y = 0; y < _data._fRectHeight; y++) {
+		for (uint16 x = 0; x < glyph->width; x++) {
+			if (*((byte *)src->getBasePtr(x, y)) == 1)
+				countupScore(dstGray, x, y, glyph->width, _data._fRectHeight, scale);
+#if DEBUGSCALING
+			if (dododo)
+				debugN("%c", *((byte *)src->getBasePtr(x, y)) == 1 ? '*' : ' ');
+#endif
+		}
+
+#if DEBUGSCALING
+		if (dododo)
+			debug("");
+#endif
+	}
+}
+
 void MacFONTFont::testBlit(const MacFONTFont *src, ManagedSurface *dst, int color, int x0, int y0, int width) {
 	for (int y = 0; y < src->_data._fRectHeight; y++) {
 		byte *srcRow = src->_data._bitImage + y * src->_data._rowWords;
diff --git a/graphics/fonts/macfont.h b/graphics/fonts/macfont.h
index b2e1fb0..3208759 100644
--- a/graphics/fonts/macfont.h
+++ b/graphics/fonts/macfont.h
@@ -166,6 +166,7 @@ private:
 	MacFONTdata _data;
 
 	const MacGlyph *findGlyph(uint32 c) const;
+	void magnifyGray(Surface *src, const MacGlyph *glyph, int *dstGray, float scale) const;
 };
 
 } // End of namespace Graphics


Commit: b5a95d478302c3f98f559eb676d2f3bcba3ce09d
    https://github.com/scummvm/scummvm/commit/b5a95d478302c3f98f559eb676d2f3bcba3ce09d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-01-07T21:57:12+01:00

Commit Message:
GRAPHICS: FONTS: Made scaling form MacFONT as a step

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


diff --git a/graphics/fonts/macfont.cpp b/graphics/fonts/macfont.cpp
index 5400497..2ae9fc8 100644
--- a/graphics/fonts/macfont.cpp
+++ b/graphics/fonts/macfont.cpp
@@ -399,6 +399,8 @@ int MacFONTFont::getKerningOffset(uint32 left, uint32 right) const {
 bool dododo;
 #endif
 
+static void magnifyGray(Surface *src, const MacGlyph *glyph, int *dstGray, int height, float scale);
+
 MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize) {
 	if (!src) {
 		warning("Empty font reference in scale font");
@@ -449,7 +451,8 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize) {
 		glyph->bitmapWidth = glyph->width; //(int)((float)srcglyph->bitmapWidth * scale);
 		glyph->bitmapOffset = newBitmapWidth;
 
-		newBitmapWidth += (glyph->bitmapWidth + 7) & ~0x7;
+		// Align width to a byte
+		newBitmapWidth += (glyph->bitmapWidth + 7 + 2) & ~0x7; // Add 2 pixels for italic and bold
 	}
 
 	data._rowWords = newBitmapWidth;
@@ -472,19 +475,15 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize) {
 		srcSurf.fillRect(Common::Rect(srcSurf.w, srcSurf.h), 0);
 		src->drawChar(&srcSurf, i + src->_data._firstChar, 0, 0, 1);
 		memset(dstGray, 0, dstGraySize * sizeof(int));
-		src->magnifyGray(&srcSurf, srcglyph, dstGray, scale);
+		magnifyGray(&srcSurf, srcglyph, dstGray, src->_data._fRectHeight, scale);
 
 		MacGlyph *glyph = (i == src->_data._glyphs.size()) ? &data._defaultChar : &data._glyphs[i];
-		byte *ptr = &data._bitImage[glyph->bitmapOffset / 8];
 		int *grayPtr = dstGray;
 
 		for (int y = 0; y < data._fRectHeight; y++) {
-			byte *dst = ptr;
-			byte b = 0;
-
-			for (int x = 0; x < glyph->width; x++, grayPtr++) {
-				b <<= 1;
+			byte *dst = (byte *)srcSurf.getBasePtr(0, y);
 
+			for (int x = 0; x < glyph->width; x++, grayPtr++, dst++) {
 #if DEBUGSCALING
 				if (i == ccc) {
 					if (*grayPtr)
@@ -493,8 +492,28 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize) {
 						debugN(1, "    ");
 				}
 #endif
-
 				if (*grayPtr > grayLevel)
+					*dst = 1;
+				else
+					*dst = 0;
+			}
+#if DEBUGSCALING
+			if (i == ccc)
+				debug(1, "");
+#endif
+		}
+
+		byte *ptr = &data._bitImage[glyph->bitmapOffset / 8];
+
+		for (int y = 0; y < data._fRectHeight; y++) {
+			byte *dst = ptr;
+			byte *srcPtr = (byte *)srcSurf.getBasePtr(0, y);
+			byte b = 0;
+
+			for (int x = 0; x < glyph->width; x++, srcPtr++) {
+				b <<= 1;
+
+				if (*srcPtr == 1)
 					b |= 1;
 
 				if (x % 8 == 7) {
@@ -579,11 +598,11 @@ static void countupScore(int *dstGray, int x, int y, int bbw, int bbh, float sca
 	}
 }
 
-void MacFONTFont::magnifyGray(Surface *src, const MacGlyph *glyph, int *dstGray, float scale) const {
-	for (uint16 y = 0; y < _data._fRectHeight; y++) {
+static void magnifyGray(Surface *src, const MacGlyph *glyph, int *dstGray, int height, float scale) {
+	for (uint16 y = 0; y < height; y++) {
 		for (uint16 x = 0; x < glyph->width; x++) {
 			if (*((byte *)src->getBasePtr(x, y)) == 1)
-				countupScore(dstGray, x, y, glyph->width, _data._fRectHeight, scale);
+				countupScore(dstGray, x, y, glyph->width, height, scale);
 #if DEBUGSCALING
 			if (dododo)
 				debugN("%c", *((byte *)src->getBasePtr(x, y)) == 1 ? '*' : ' ');
@@ -602,7 +621,7 @@ void MacFONTFont::testBlit(const MacFONTFont *src, ManagedSurface *dst, int colo
 		byte *srcRow = src->_data._bitImage + y * src->_data._rowWords;
 
 		for (int x = 0; x < width; x++) {
-			uint16 bitmapOffset = x;
+			uint16 bitmapOffset = x + 64;
 
 			if (srcRow[bitmapOffset / 8] & (1 << (7 - (bitmapOffset % 8)))) {
 				if (dst->format.bytesPerPixel == 1)
diff --git a/graphics/fonts/macfont.h b/graphics/fonts/macfont.h
index 3208759..b2e1fb0 100644
--- a/graphics/fonts/macfont.h
+++ b/graphics/fonts/macfont.h
@@ -166,7 +166,6 @@ private:
 	MacFONTdata _data;
 
 	const MacGlyph *findGlyph(uint32 c) const;
-	void magnifyGray(Surface *src, const MacGlyph *glyph, int *dstGray, float scale) const;
 };
 
 } // End of namespace Graphics


Commit: fc00b78a48e3d5950858cfe5c5720de03f2ff803
    https://github.com/scummvm/scummvm/commit/fc00b78a48e3d5950858cfe5c5720de03f2ff803
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-01-07T21:57:12+01:00

Commit Message:
GRAPHICS: FONTS: Implement generation of bold fonts

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


diff --git a/graphics/fonts/macfont.cpp b/graphics/fonts/macfont.cpp
index 2ae9fc8..730229c 100644
--- a/graphics/fonts/macfont.cpp
+++ b/graphics/fonts/macfont.cpp
@@ -399,9 +399,10 @@ int MacFONTFont::getKerningOffset(uint32 left, uint32 right) const {
 bool dododo;
 #endif
 
-static void magnifyGray(Surface *src, const MacGlyph *glyph, int *dstGray, int height, float scale);
+static void magnifyGray(Surface *src, int *dstGray, int width, int height, float scale);
+static void makeBold(Surface *src, int *dstGray, MacGlyph *glyph, int height);
 
-MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize) {
+MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize, bool bold, bool italic) {
 	if (!src) {
 		warning("Empty font reference in scale font");
 		return NULL;
@@ -413,8 +414,8 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize) {
 	}
 
 	Graphics::Surface srcSurf;
-	srcSurf.create(src->getFontSize() * 3, src->getFontSize() * 3, PixelFormat::createFormatCLUT8());
-	int dstGraySize = newSize * 3 * newSize * 3;
+	srcSurf.create(src->getFontSize() * 2, src->getFontSize() * 2, PixelFormat::createFormatCLUT8());
+	int dstGraySize = newSize * 2 * newSize;
 	int *dstGray = (int *)malloc(dstGraySize * sizeof(int));
 
 	float scale = (float)newSize / (float)src->getFontSize();
@@ -475,7 +476,7 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize) {
 		srcSurf.fillRect(Common::Rect(srcSurf.w, srcSurf.h), 0);
 		src->drawChar(&srcSurf, i + src->_data._firstChar, 0, 0, 1);
 		memset(dstGray, 0, dstGraySize * sizeof(int));
-		magnifyGray(&srcSurf, srcglyph, dstGray, src->_data._fRectHeight, scale);
+		magnifyGray(&srcSurf, dstGray, srcglyph->width, src->_data._fRectHeight, scale);
 
 		MacGlyph *glyph = (i == src->_data._glyphs.size()) ? &data._defaultChar : &data._glyphs[i];
 		int *grayPtr = dstGray;
@@ -503,6 +504,31 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize) {
 #endif
 		}
 
+		if (bold) {
+			memset(dstGray, 0, dstGraySize * sizeof(int));
+			makeBold(&srcSurf, dstGray, glyph, data._fRectHeight);
+
+			for (uint16 y = 0; y < data._fRectHeight; y++) {
+				int *srcPtr = &dstGray[y * glyph->width];
+				byte *dstPtr = (byte *)srcSurf.getBasePtr(0, y);
+
+				for (uint16 x = 0; x < glyph->width; x++, srcPtr++, dstPtr++) {
+					if (*srcPtr)
+						*dstPtr = 1;
+
+#if DEBUGSCALING
+					if (i == ccc)
+						debugN("%c", *srcPtr ? '@' : '.');
+#endif
+				}
+
+#if DEBUGSCALING
+				if (i == ccc)
+					debug("");
+#endif
+			}
+		}
+
 		byte *ptr = &data._bitImage[glyph->bitmapOffset / 8];
 
 		for (int y = 0; y < data._fRectHeight; y++) {
@@ -598,11 +624,11 @@ static void countupScore(int *dstGray, int x, int y, int bbw, int bbh, float sca
 	}
 }
 
-static void magnifyGray(Surface *src, const MacGlyph *glyph, int *dstGray, int height, float scale) {
+static void magnifyGray(Surface *src, int *dstGray, int width, int height, float scale) {
 	for (uint16 y = 0; y < height; y++) {
-		for (uint16 x = 0; x < glyph->width; x++) {
+		for (uint16 x = 0; x < width; x++) {
 			if (*((byte *)src->getBasePtr(x, y)) == 1)
-				countupScore(dstGray, x, y, glyph->width, height, scale);
+				countupScore(dstGray, x, y, width, height, scale);
 #if DEBUGSCALING
 			if (dododo)
 				debugN("%c", *((byte *)src->getBasePtr(x, y)) == 1 ? '*' : ' ');
@@ -616,6 +642,49 @@ static void magnifyGray(Surface *src, const MacGlyph *glyph, int *dstGray, int h
 	}
 }
 
+static const bool bdir = true;
+static const bool pile = false;
+
+static void makeBold(Surface *src, int *dstGray, MacGlyph *glyph, int height) {
+	glyph->width++;
+
+	for (uint16 y = 0; y < height; y++) {
+		byte *srcPtr = (byte *)src->getBasePtr(0, y);
+		int *dst = &dstGray[y * glyph->width];
+
+		for (uint16 x = 0; x < glyph->width; x++, srcPtr++, dst++) {
+			bool left = x ? *(srcPtr - 1) == 1 : false;
+			bool center = *srcPtr == 1;
+			bool right = x > glyph->width - 1 ? false : *(srcPtr + 1) == 1;
+
+			bool tmp, bold;
+
+			bool res;
+
+			if (bdir) {
+				/* left shifted image */
+				bold = left;
+			} else {
+				/* right shifted image */
+				bold = right;
+			}
+			if (pile) {
+				/* left edge */
+				tmp = left;
+				res = (!tmp && center) || bold;
+			} else {
+				/* right edge */
+				tmp = right;
+				res = (!tmp && bold) || center;
+			}
+
+			res = center || left;
+
+			*dst = res ? 1 : 0;
+		}
+	}
+}
+
 void MacFONTFont::testBlit(const MacFONTFont *src, ManagedSurface *dst, int color, int x0, int y0, int width) {
 	for (int y = 0; y < src->_data._fRectHeight; y++) {
 		byte *srcRow = src->_data._bitImage + y * src->_data._rowWords;
diff --git a/graphics/fonts/macfont.h b/graphics/fonts/macfont.h
index b2e1fb0..cb11304 100644
--- a/graphics/fonts/macfont.h
+++ b/graphics/fonts/macfont.h
@@ -159,7 +159,7 @@ public:
 
 	int getFontSize() const { return _data._size; }
 
-	static MacFONTFont *scaleFont(const MacFONTFont *src, int newSize);
+	static MacFONTFont *scaleFont(const MacFONTFont *src, int newSize, bool bold = false, bool italic = false);
 	static void testBlit(const MacFONTFont *src, ManagedSurface *dst, int color, int x0, int y0, int width);
 
 private:


Commit: 8c8a710d80394a7c60456cfdfded46d222c5ee21
    https://github.com/scummvm/scummvm/commit/8c8a710d80394a7c60456cfdfded46d222c5ee21
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-01-07T21:57:12+01:00

Commit Message:
GRAPHICS: MACGUI: Generate bold font substitutes in MacFontManager

Changed paths:
    graphics/macgui/macfontmanager.cpp


diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp
index 151a3d9..ff94038 100644
--- a/graphics/macgui/macfontmanager.cpp
+++ b/graphics/macgui/macfontmanager.cpp
@@ -458,7 +458,14 @@ void MacFontManager::generateFont(MacFont &toFont, MacFont &fromFont) {
 	debugN("Found font substitute for font '%s' ", getFontName(toFont).c_str());
 	debug("as '%s'", getFontName(fromFont).c_str());
 
-	MacFONTFont *font = Graphics::MacFONTFont::scaleFont(fromFont.getFont(), toFont.getSize());
+	bool bold = false, italic = false;
+
+	if (fromFont.getSlant() == kMacFontRegular) {
+		bold = toFont.getSlant() == kMacFontBold;
+		italic = toFont.getSlant() == kMacFontItalic;
+	}
+
+	MacFONTFont *font = Graphics::MacFONTFont::scaleFont(fromFont.getFont(), toFont.getSize(), bold, italic);
 
 	if (!font) {
 		warning("Failed to generate font '%s'", getFontName(toFont).c_str());




More information about the Scummvm-git-logs mailing list