[Scummvm-git-logs] scummvm master -> 368c0928b60fb6b60937235c7108543ad791ecc2

sev- sev at scummvm.org
Wed Jan 25 12:42:47 CET 2017


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:
e2b1cd5c80 GRAPHICS: Implemented test for MacFont scaling
368c0928b6 DIRECTOR: Added test for drawing scaled MacFonts


Commit: e2b1cd5c80256a924b24a4b1a51dfb9ee2a71857
    https://github.com/scummvm/scummvm/commit/e2b1cd5c80256a924b24a4b1a51dfb9ee2a71857
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2017-01-25T12:44:24+01:00

Commit Message:
GRAPHICS: Implemented test for MacFont scaling

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


diff --git a/graphics/fonts/macfont.cpp b/graphics/fonts/macfont.cpp
index d15f0d1..882e841 100644
--- a/graphics/fonts/macfont.cpp
+++ b/graphics/fonts/macfont.cpp
@@ -22,7 +22,7 @@
 
 #include "common/stream.h"
 #include "common/textconsole.h"
-#include "graphics/surface.h"
+#include "graphics/managed_surface.h"
 #include "graphics/fonts/macfont.h"
 
 namespace Graphics {
@@ -395,7 +395,7 @@ int MacFONTFont::getKerningOffset(uint32 left, uint32 right) const {
 	return 0;
 }
 
-MacFONTFont *MacFONTFont::scaleFont(MacFONTFont *src, int newSize) {
+MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize) {
 	if (!src) {
 		warning("Empty font reference in scale font");
 		return NULL;
@@ -433,7 +433,7 @@ MacFONTFont *MacFONTFont::scaleFont(MacFONTFont *src, int newSize) {
 	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];
-		MacGlyph *srcglyph = (i == src->_data._glyphs.size()) ? &src->_data._defaultChar : &src->_data._glyphs[i];
+		const MacGlyph *srcglyph = (i == src->_data._glyphs.size()) ? &src->_data._defaultChar : &src->_data._glyphs[i];
 
 		glyph->width = (int)((float)srcglyph->width * scale);
 		glyph->kerningOffset = (int)((float)srcglyph->kerningOffset * scale);
@@ -452,7 +452,7 @@ MacFONTFont *MacFONTFont::scaleFont(MacFONTFont *src, int newSize) {
 	int dstPitch = data._rowWords;
 
 	for (uint i = 0; i < src->_data._glyphs.size() + 1; i++) {
-		MacGlyph *srcglyph = (i == src->_data._glyphs.size()) ? &src->_data._defaultChar : &src->_data._glyphs[i];
+		const MacGlyph *srcglyph = (i == src->_data._glyphs.size()) ? &src->_data._defaultChar : &src->_data._glyphs[i];
 		MacGlyph *glyph = (i == src->_data._glyphs.size()) ? &data._defaultChar : &data._glyphs[i];
 		byte *ptr = &data._bitImage[glyph->bitmapOffset];
 
@@ -535,4 +535,23 @@ MacFONTFont *MacFONTFont::scaleFont(MacFONTFont *src, int newSize) {
 	return new MacFONTFont(data);
 }
 
+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;
+
+		for (int x = 0; x < width; x++) {
+			uint16 bitmapOffset = x;
+
+			if (srcRow[bitmapOffset / 8] & (1 << (7 - (bitmapOffset % 8)))) {
+				if (dst->format.bytesPerPixel == 1)
+					*((byte *)dst->getBasePtr(x0 + x, y0 + y)) = color;
+				else if (dst->format.bytesPerPixel == 2)
+					*((uint16 *)dst->getBasePtr(x0 + x, y0 + y)) = color;
+				else if (dst->format.bytesPerPixel == 4)
+					*((uint32 *)dst->getBasePtr(x0 + x, y0 + y)) = color;
+			}
+		}
+	}
+}
+
 } // End of namespace Graphics
diff --git a/graphics/fonts/macfont.h b/graphics/fonts/macfont.h
index 5baa643..33fb0fb 100644
--- a/graphics/fonts/macfont.h
+++ b/graphics/fonts/macfont.h
@@ -156,7 +156,8 @@ public:
 
 	int getFontSize() const { return _data._size; }
 
-	static MacFONTFont *scaleFont(MacFONTFont *src, int newSize);
+	static MacFONTFont *scaleFont(const MacFONTFont *src, int newSize);
+	static void testBlit(const MacFONTFont *src, ManagedSurface *dst, int color, int x0, int y0, int width);
 
 private:
 	MacFONTdata _data;


Commit: 368c0928b60fb6b60937235c7108543ad791ecc2
    https://github.com/scummvm/scummvm/commit/368c0928b60fb6b60937235c7108543ad791ecc2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2017-01-25T12:44:24+01:00

Commit Message:
DIRECTOR: Added test for drawing scaled MacFonts

Changed paths:
    engines/director/director.cpp
    engines/director/score.cpp


diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index 527cf7a..3e95d6b 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -119,6 +119,7 @@ Common::Error DirectorEngine::run() {
 		_mainArchive = nullptr;
 		_currentScore = nullptr;
 
+		testFontScaling();
 		testFonts();
 
 		_lingo->runTests();
@@ -130,8 +131,6 @@ Common::Error DirectorEngine::run() {
 	//_mainArchive = new RIFFArchive();
 	//_mainArchive->openFile("bookshelf_example.mmm");
 
-	//testFontScaling();
-
 	if (getPlatform() == Common::kPlatformWindows)
 		_sharedCastFile = "SHARDCST.MMM";
 	else
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index e5e137c..9864a4c 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -27,6 +27,7 @@
 
 #include "engines/util.h"
 #include "graphics/font.h"
+#include "graphics/fonts/macfont.h"
 #include "graphics/palette.h"
 #include "graphics/macgui/macfontmanager.h"
 #include "graphics/macgui/macwindowmanager.h"
@@ -105,6 +106,19 @@ void DirectorEngine::testFontScaling() {
 	surface.create(w, h);
 	surface.clear(255);
 
+	Graphics::MacFont origFont(Graphics::kMacFontNewYork, 18);
+
+	const Graphics::MacFONTFont *font1 = (const Graphics::MacFONTFont *)_wm->_fontMan->getFont(origFont);
+
+	Graphics::MacFONTFont::testBlit(font1, &surface, 0, x, y, 500);
+
+	Graphics::MacFont bigFont(Graphics::kMacFontNewYork, 15);
+
+	font1 = (const Graphics::MacFONTFont *)_wm->_fontMan->getFont(bigFont);
+
+	Graphics::MacFONTFont::testBlit(font1, &surface, 0, x, y + 50, 500);
+
+#if 0
 	const char *text = "d";
 
 	for (int i = 9; i <= 40; i++) {
@@ -121,6 +135,7 @@ void DirectorEngine::testFontScaling() {
 
 		x += width + 1;
 	}
+#endif
 
 	g_system->copyRectToScreen(surface.getPixels(), surface.pitch, 0, 0, w, h);
 





More information about the Scummvm-git-logs mailing list