[Scummvm-git-logs] scummvm master -> 4dd8e71fb98f477c7c71517d4ad41227942eba9d

ysj1173886760 42030331+ysj1173886760 at users.noreply.github.com
Thu Jul 22 13:42:58 UTC 2021


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

Summary:
79755cfb02 GRAPHICS: MACGUI: implement basic italic supporting.
63b9ae3679 GRAPHICS: MACGUI: enhance italic font. Fix the implementation for generating slant fonts.
9ec4a2449e GRAPHICS: MACGUI: using bitmapWidth to replace width when dealing with bitmap.
e02911f283 GRAPHICS: MACGUI: add 1 to the width of outline font.
4dd8e71fb9 GRAPHICS: MACGUI: fix outline style font.


Commit: 79755cfb027734a805a3dbcf7104d7cc16b384d2
    https://github.com/scummvm/scummvm/commit/79755cfb027734a805a3dbcf7104d7cc16b384d2
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-07-22T21:42:18+08:00

Commit Message:
GRAPHICS: MACGUI: implement basic italic supporting.

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


diff --git a/graphics/fonts/macfont.cpp b/graphics/fonts/macfont.cpp
index 26756b653f..ea7030718d 100644
--- a/graphics/fonts/macfont.cpp
+++ b/graphics/fonts/macfont.cpp
@@ -468,6 +468,7 @@ bool dododo;
 static void magnifyGray(Surface *src, int *dstGray, int width, int height, float scale);
 static void makeBold(Surface *src, int *dstGray, MacGlyph *glyph, int height);
 static void makeOutline(Surface *src, Surface *dst, MacGlyph *glyph, int height);
+static void makeItalic(Surface *src, Surface *dst, MacGlyph *glyph, int height);
 
 MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize, bool bold, bool italic, bool outline) {
 	if (!src) {
@@ -515,6 +516,10 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize, bool bo
 
 	// Determine width of the bit image table
 	int newBitmapWidth = 0;
+
+	// offset for bold and italic, and we need to calc italic offset ourself
+	int bitmapOffset = italic ? (data._fRectHeight - 1) / SLANTDEEP : 2;
+
 	for (uint i = 0; i < src->_data._glyphs.size() + 1; i++) {
 		MacGlyph *glyph = (i == src->_data._glyphs.size()) ? &data._defaultChar : &data._glyphs[i];
 		const MacGlyph *srcglyph = (i == src->_data._glyphs.size()) ? &src->_data._defaultChar : &src->_data._glyphs[i];
@@ -525,7 +530,7 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize, bool bo
 		glyph->bitmapOffset = newBitmapWidth;
 
 		// Align width to a byte
-		newBitmapWidth += (glyph->bitmapWidth + 7 + 2) & ~0x7; // Add 2 pixels for italic and bold
+		newBitmapWidth += (glyph->bitmapWidth + 7 + bitmapOffset) & ~0x7; // Add 2 pixels for italic and bold
 	}
 
 	data._rowWords = newBitmapWidth;
@@ -606,6 +611,12 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize, bool bo
 			srcSurf.copyFrom(tmpSurf);
 		}
 
+		if (italic) {
+			tmpSurf.fillRect(Common::Rect(tmpSurf.w, tmpSurf.h), 0);
+			makeItalic(&srcSurf, &tmpSurf, glyph, data._fRectHeight);
+			srcSurf.copyFrom(tmpSurf);
+		}
+
 		byte *ptr = &data._bitImage[glyph->bitmapOffset / 8];
 
 		for (int y = 0; y < data._fRectHeight; y++) {
@@ -762,6 +773,24 @@ static void makeOutline(Surface *src, Surface *dst, MacGlyph *glyph, int height)
 	}
 }
 
+static void makeItalic(Surface *src, Surface *dst, MacGlyph *glyph, int height) {
+	int slantDeep = SLANTDEEP;
+	int dw = (height - 1) / slantDeep;
+
+	for (uint16 y = 0; y < height; y++) {
+		int dx = dw - y / slantDeep;
+		byte *srcPtr = (byte *)src->getBasePtr(0, y);
+		byte *dstPtr = (byte *)dst->getBasePtr(dx, y);
+
+		for (uint16 x = 0; x < glyph->width; x++, srcPtr++, dstPtr++) {
+			*dstPtr = *srcPtr;
+		}
+	}
+	glyph->bitmapWidth += dw;
+	glyph->width += dw;
+	glyph->kerningOffset -= dw / 2;
+}
+
 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 69ee2ca5d2..652044c3b2 100644
--- a/graphics/fonts/macfont.h
+++ b/graphics/fonts/macfont.h
@@ -30,6 +30,8 @@
 
 namespace Graphics {
 
+#define SLANTDEEP 3
+
 class MacFontFamily {
 public:
 	MacFontFamily();


Commit: 63b9ae36790a7508625792ef0e2d1a35168266c3
    https://github.com/scummvm/scummvm/commit/63b9ae36790a7508625792ef0e2d1a35168266c3
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-07-22T21:42:19+08:00

Commit Message:
GRAPHICS: MACGUI: enhance italic font. Fix the implementation for generating slant fonts.

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


diff --git a/graphics/fonts/macfont.cpp b/graphics/fonts/macfont.cpp
index ea7030718d..38745bb6bf 100644
--- a/graphics/fonts/macfont.cpp
+++ b/graphics/fonts/macfont.cpp
@@ -624,7 +624,7 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize, bool bo
 			byte *srcPtr = (byte *)srcSurf.getBasePtr(0, y);
 			byte b = 0;
 
-			for (int x = 0; x < glyph->width; x++, srcPtr++) {
+			for (int x = 0; x < glyph->bitmapWidth; x++, srcPtr++) {
 				b <<= 1;
 
 				if (*srcPtr == 1)
@@ -646,13 +646,13 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize, bool bo
 			}
 #endif
 
-			if (((glyph->width - 1) % 8)) {
+			if (((glyph->bitmapWidth - 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);
+				b <<= 7 - ((glyph->bitmapWidth - 1) % 8);
 				*dst = b;
 
 #if DEBUGSCALING
@@ -732,6 +732,7 @@ static void magnifyGray(Surface *src, int *dstGray, int width, int height, float
 
 static void makeBold(Surface *src, int *dstGray, MacGlyph *glyph, int height) {
 	glyph->width++;
+	glyph->bitmapWidth++;
 
 	for (uint16 y = 0; y < height; y++) {
 		byte *srcPtr = (byte *)src->getBasePtr(0, y);
@@ -754,7 +755,7 @@ static void makeBold(Surface *src, int *dstGray, MacGlyph *glyph, int height) {
 }
 
 static void makeOutline(Surface *src, Surface *dst, MacGlyph *glyph, int height) {
-	glyph->width += 2;
+	glyph->bitmapWidth += 2;
 	glyph->height++;
 
 	for (uint16 y = 0; y < height + 1; y++) {
@@ -762,11 +763,11 @@ static void makeOutline(Surface *src, Surface *dst, MacGlyph *glyph, int height)
 		byte *srcPtr2 = (byte *)src->getBasePtr(0, (y == height ? 0 : y + 1));
 		byte *dstPtr = (byte *)dst->getBasePtr(0, y);
 
-		for (uint16 x = 0; x < glyph->width; x++, dstPtr++) {
+		for (uint16 x = 0; x < glyph->bitmapWidth; x++, dstPtr++) {
 			byte pixX, pixR, pixB;
-			pixX = (x == 0 || x == glyph->width - 2) ? 0 : *srcPtr++;
-			pixB = (x == 0 || x == glyph->width - 2 || y == height) ? 0 : *srcPtr2++;
-			pixR = (x == glyph->width - 1) ? 0 : *srcPtr;
+			pixX = (x == 0 || x == glyph->bitmapWidth - 2) ? 0 : *srcPtr++;
+			pixB = (x == 0 || x == glyph->bitmapWidth - 2 || y == height) ? 0 : *srcPtr2++;
+			pixR = (x == glyph->bitmapWidth - 1) ? 0 : *srcPtr;
 
 			*dstPtr = (pixX ^ pixR) | (pixX ^ pixB);
 		}
@@ -774,11 +775,10 @@ static void makeOutline(Surface *src, Surface *dst, MacGlyph *glyph, int height)
 }
 
 static void makeItalic(Surface *src, Surface *dst, MacGlyph *glyph, int height) {
-	int slantDeep = SLANTDEEP;
-	int dw = (height - 1) / slantDeep;
+	int dw = (height - 1) / SLANTDEEP;
 
 	for (uint16 y = 0; y < height; y++) {
-		int dx = dw - y / slantDeep;
+		int dx = dw - y / SLANTDEEP;
 		byte *srcPtr = (byte *)src->getBasePtr(0, y);
 		byte *dstPtr = (byte *)dst->getBasePtr(dx, y);
 
@@ -787,7 +787,6 @@ static void makeItalic(Surface *src, Surface *dst, MacGlyph *glyph, int height)
 		}
 	}
 	glyph->bitmapWidth += dw;
-	glyph->width += dw;
 	glyph->kerningOffset -= dw / 2;
 }
 
diff --git a/graphics/fonts/macfont.h b/graphics/fonts/macfont.h
index 652044c3b2..591f3022da 100644
--- a/graphics/fonts/macfont.h
+++ b/graphics/fonts/macfont.h
@@ -30,7 +30,7 @@
 
 namespace Graphics {
 
-#define SLANTDEEP 3
+#define SLANTDEEP 2
 
 class MacFontFamily {
 public:


Commit: 9ec4a2449ec0ecd42faea55b8a9e24830f64e368
    https://github.com/scummvm/scummvm/commit/9ec4a2449ec0ecd42faea55b8a9e24830f64e368
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-07-22T21:42:19+08:00

Commit Message:
GRAPHICS: MACGUI: using bitmapWidth to replace width when dealing with bitmap.

Changed paths:
    graphics/fonts/macfont.cpp


diff --git a/graphics/fonts/macfont.cpp b/graphics/fonts/macfont.cpp
index 38745bb6bf..baf477bfcb 100644
--- a/graphics/fonts/macfont.cpp
+++ b/graphics/fonts/macfont.cpp
@@ -561,7 +561,7 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize, bool bo
 		for (int y = 0; y < data._fRectHeight; y++) {
 			byte *dst = (byte *)srcSurf.getBasePtr(0, y);
 
-			for (int x = 0; x < glyph->width; x++, grayPtr++, dst++) {
+			for (int x = 0; x < glyph->bitmapWidth; x++, grayPtr++, dst++) {
 #if DEBUGSCALING
 				if (i == ccc) {
 					if (*grayPtr)
@@ -586,10 +586,10 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize, bool bo
 			makeBold(&srcSurf, dstGray, glyph, data._fRectHeight);
 
 			for (uint16 y = 0; y < data._fRectHeight; y++) {
-				int *srcPtr = &dstGray[y * glyph->width];
+				int *srcPtr = &dstGray[y * glyph->bitmapWidth];
 				byte *dstPtr = (byte *)srcSurf.getBasePtr(0, y);
 
-				for (uint16 x = 0; x < glyph->width; x++, srcPtr++, dstPtr++) {
+				for (uint16 x = 0; x < glyph->bitmapWidth; x++, srcPtr++, dstPtr++) {
 					if (*srcPtr)
 						*dstPtr = 1;
 
@@ -736,12 +736,12 @@ static void makeBold(Surface *src, int *dstGray, MacGlyph *glyph, int height) {
 
 	for (uint16 y = 0; y < height; y++) {
 		byte *srcPtr = (byte *)src->getBasePtr(0, y);
-		int *dst = &dstGray[y * glyph->width];
+		int *dst = &dstGray[y * glyph->bitmapWidth];
 
-		for (uint16 x = 0; x < glyph->width; x++, srcPtr++, dst++) {
+		for (uint16 x = 0; x < glyph->bitmapWidth; 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 right = x > glyph->bitmapWidth - 1 ? false : *(srcPtr + 1) == 1;
 
 			bool edge, bold, res;
 


Commit: e02911f283d4d81fccac1c3d93a3eb5c4bfb6344
    https://github.com/scummvm/scummvm/commit/e02911f283d4d81fccac1c3d93a3eb5c4bfb6344
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-07-22T21:42:19+08:00

Commit Message:
GRAPHICS: MACGUI: add 1 to the width of outline font.

Changed paths:
    graphics/fonts/macfont.cpp


diff --git a/graphics/fonts/macfont.cpp b/graphics/fonts/macfont.cpp
index baf477bfcb..73f8b0a9a1 100644
--- a/graphics/fonts/macfont.cpp
+++ b/graphics/fonts/macfont.cpp
@@ -756,6 +756,7 @@ static void makeBold(Surface *src, int *dstGray, MacGlyph *glyph, int height) {
 
 static void makeOutline(Surface *src, Surface *dst, MacGlyph *glyph, int height) {
 	glyph->bitmapWidth += 2;
+	glyph->width++;
 	glyph->height++;
 
 	for (uint16 y = 0; y < height + 1; y++) {


Commit: 4dd8e71fb98f477c7c71517d4ad41227942eba9d
    https://github.com/scummvm/scummvm/commit/4dd8e71fb98f477c7c71517d4ad41227942eba9d
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-07-22T21:42:19+08:00

Commit Message:
GRAPHICS: MACGUI: fix outline style font.

Changed paths:
    graphics/fonts/macfont.cpp


diff --git a/graphics/fonts/macfont.cpp b/graphics/fonts/macfont.cpp
index 73f8b0a9a1..19f2703b42 100644
--- a/graphics/fonts/macfont.cpp
+++ b/graphics/fonts/macfont.cpp
@@ -502,7 +502,6 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize, bool bo
 	data._nDescent = (int)((float)src->_data._nDescent * scale);
 	data._fRectWidth = (int)((float)src->_data._fRectWidth * scale + data._lastChar * 2);
 	data._fRectHeight = (int)((float)src->_data._fRectHeight * scale);
-	data._surfHeight = data._fRectHeight + 2;	// Outline
 	data._owTLoc = src->_data._owTLoc;
 	data._ascent = (int)((float)src->_data._ascent * scale);
 	data._descent = (int)((float)src->_data._descent * scale);
@@ -514,6 +513,10 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize, bool bo
 
 	data._glyphs.resize(src->_data._glyphs.size());
 
+	if (outline)
+		data._fRectHeight += 2;
+	data._surfHeight = data._fRectHeight;
+
 	// Determine width of the bit image table
 	int newBitmapWidth = 0;
 
@@ -607,6 +610,7 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize, bool bo
 		}
 
 		if (outline) {
+			tmpSurf.fillRect(Common::Rect(tmpSurf.w, tmpSurf.h), 0);
 			makeOutline(&srcSurf, &tmpSurf, glyph, data._fRectHeight);
 			srcSurf.copyFrom(tmpSurf);
 		}
@@ -759,18 +763,20 @@ static void makeOutline(Surface *src, Surface *dst, MacGlyph *glyph, int height)
 	glyph->width++;
 	glyph->height++;
 
-	for (uint16 y = 0; y < height + 1; y++) {
+	for (uint16 y = 0; y < height + 2; y++) {
 		byte *srcPtr = (byte *)src->getBasePtr(0, y);
-		byte *srcPtr2 = (byte *)src->getBasePtr(0, (y == height ? 0 : y + 1));
 		byte *dstPtr = (byte *)dst->getBasePtr(0, y);
 
-		for (uint16 x = 0; x < glyph->bitmapWidth; x++, dstPtr++) {
-			byte pixX, pixR, pixB;
-			pixX = (x == 0 || x == glyph->bitmapWidth - 2) ? 0 : *srcPtr++;
-			pixB = (x == 0 || x == glyph->bitmapWidth - 2 || y == height) ? 0 : *srcPtr2++;
-			pixR = (x == glyph->bitmapWidth - 1) ? 0 : *srcPtr;
-
-			*dstPtr = (pixX ^ pixR) | (pixX ^ pixB);
+		for (uint16 x = 0; x < glyph->bitmapWidth; x++, dstPtr++, srcPtr++) {
+			if (*srcPtr)
+				continue;
+			// for every white pixel, if there is black pixel around it. It means that the white pixel is boundary, then we draw it as black pixel.
+			byte *left = (byte *)src->getBasePtr(MAX(x - 1, 0), y);
+			byte *right = (byte *)src->getBasePtr(MIN(x + 1, src->w - 1), y);
+			byte *up = (byte *)src->getBasePtr(x, MAX(y - 1, 0));
+			byte *down = (byte *)src->getBasePtr(x, MIN(y + 1, src->h - 1));
+			if (*left || *right || *up || *down)
+				*dstPtr = 1;
 		}
 	}
 }




More information about the Scummvm-git-logs mailing list