[Scummvm-git-logs] scummvm master -> 04f0fa36a68eccf01d2d08827b1d8ecaef7eff50
sev-
sev at scummvm.org
Sat Oct 15 12:25:31 CEST 2016
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
290ac2cc04 GRAPHICS: Added all supported Mac fonts to enum
23544e6866 DIRECTOR: Added Mac font rendering test
04f0fa36a6 GRAPHICS: Fixed BDF font scaling
Commit: 290ac2cc0445e24373ce06f05ebc4cb5e1f35378
https://github.com/scummvm/scummvm/commit/290ac2cc0445e24373ce06f05ebc4cb5e1f35378
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-10-15T12:25:20+02:00
Commit Message:
GRAPHICS: Added all supported Mac fonts to enum
Changed paths:
graphics/macgui/macfontmanager.h
diff --git a/graphics/macgui/macfontmanager.h b/graphics/macgui/macfontmanager.h
index 38ea3f3..e429eea 100644
--- a/graphics/macgui/macfontmanager.h
+++ b/graphics/macgui/macfontmanager.h
@@ -29,7 +29,21 @@ namespace Graphics {
enum {
kMacFontNonStandard = -1,
- kMacFontChicago = 0
+ kMacFontChicago = 0,
+ kMacFontGeneva = 1,
+ kMacFontNewYork = 2,
+ kMacFontMonaco = 4,
+ kMacFontVenice = 5,
+ kMacFontLondon = 6,
+ kMacFontAthens = 7,
+ kMacFontSanFrancisco = 8,
+ kMacFontCairo = 11,
+ kMacFontLosAngeles = 12,
+ kMacFontPalatino = 16,
+ kMacFontTimes = 20,
+ kMacFontHelvetica = 21,
+ kMacFontCourier = 22,
+ kMacFontSymbol = 23
};
enum {
Commit: 23544e6866aa9da9fde1a834eba7c8d4ddfdbed5
https://github.com/scummvm/scummvm/commit/23544e6866aa9da9fde1a834eba7c8d4ddfdbed5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-10-15T12:25:20+02:00
Commit Message:
DIRECTOR: Added Mac font rendering test
Changed paths:
engines/director/director.cpp
engines/director/director.h
engines/director/score.cpp
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index a0a96d6..848eaa9 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -117,6 +117,8 @@ Common::Error DirectorEngine::run() {
//_mainArchive = new RIFFArchive();
//_mainArchive->openFile("bookshelf_example.mmm");
+ //testFont();
+
scanMovies(ConfMan.get("path"));
loadSharedCastsFrom(_sharedCastFile);
diff --git a/engines/director/director.h b/engines/director/director.h
index 484e7f6..7c65897 100644
--- a/engines/director/director.h
+++ b/engines/director/director.h
@@ -133,6 +133,9 @@ private:
Lingo *_lingo;
Common::String _sharedCastFile;
+
+private:
+ void testFont();
};
} // End of namespace Director
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index ccba78e..c95aae1 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -27,6 +27,8 @@
#include "engines/util.h"
#include "graphics/font.h"
#include "graphics/palette.h"
+#include "graphics/macgui/macfontmanager.h"
+#include "graphics/macgui/macwindowmanager.h"
#include "director/score.h"
#include "director/frame.h"
@@ -87,6 +89,51 @@ static byte defaultPalette[768] = {
204, 51, 255, 204, 102, 255, 204, 153, 255, 204, 204, 255, 204, 255, 255, 255,
0, 255, 255, 51, 255, 255, 102, 255, 255, 153, 255, 255, 204, 255, 255, 255 };
+void DirectorEngine::testFont() {
+ int x = 10;
+ int y = 10;
+ int w = 640;
+ int h = 480;
+
+ initGraphics(w, h, true);
+ g_system->getPaletteManager()->setPalette(defaultPalette, 0, 256);
+
+ Graphics::ManagedSurface surface;
+
+ surface.create(w, h);
+ surface.clear(255);
+
+ const char *text = "d";
+
+ for (int i = 9; i <= 40; i++) {
+ Graphics::MacFont macFont(Graphics::kMacFontNewYork, i);
+
+ const Graphics::Font *font = _wm->_fontMan->getFont(macFont);
+
+ int width = font->getStringWidth(text);
+
+ Common::Rect bbox = font->getBoundingBox(text, x, y, w);
+ surface.frameRect(bbox, 15);
+
+ font->drawString(&surface, text, x, y, width, 0);
+
+ x += width + 1;
+ }
+
+ g_system->copyRectToScreen(surface.getPixels(), surface.pitch, 0, 0, w, h);
+
+ Common::Event event;
+
+ while (true) {
+ if (g_system->getEventManager()->pollEvent(event))
+ if (event.type == Common::EVENT_QUIT)
+ break;
+
+ g_system->updateScreen();
+ g_system->delayMillis(10);
+ }
+}
+
Score::Score(DirectorEngine *vm, Archive *archive) {
_vm = vm;
_surface = new Graphics::ManagedSurface;
Commit: 04f0fa36a68eccf01d2d08827b1d8ecaef7eff50
https://github.com/scummvm/scummvm/commit/04f0fa36a68eccf01d2d08827b1d8ecaef7eff50
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-10-15T12:25:21+02:00
Commit Message:
GRAPHICS: Fixed BDF font scaling
Changed paths:
graphics/fonts/bdf.cpp
diff --git a/graphics/fonts/bdf.cpp b/graphics/fonts/bdf.cpp
index bae47c1..e109d07 100644
--- a/graphics/fonts/bdf.cpp
+++ b/graphics/fonts/bdf.cpp
@@ -711,17 +711,17 @@ BdfFont *BdfFont::scaleFont(BdfFont *src, int newSize) {
return NULL;
}
- float scale = newSize / src->getFontSize();
+ float scale = (float)newSize / (float)src->getFontSize();
BdfFontData data;
- data.maxAdvance = src->_data.maxAdvance * scale;
- data.height = src->_data.height * scale;
- data.defaultBox.width = src->_data.defaultBox.width * scale;
- data.defaultBox.height = src->_data.defaultBox.height * scale;
- data.defaultBox.xOffset = src->_data.defaultBox.xOffset * scale;
- data.defaultBox.yOffset = src->_data.defaultBox.yOffset * scale;
- data.ascent = src->_data.ascent * scale;
+ data.maxAdvance = (int)((float)src->_data.maxAdvance * scale);
+ data.height = (int)((float)src->_data.height * scale);
+ data.defaultBox.width = (int)((float)src->_data.defaultBox.width * scale);
+ data.defaultBox.height = (int)((float)src->_data.defaultBox.height * scale);
+ data.defaultBox.xOffset = (int)((float)src->_data.defaultBox.xOffset * scale);
+ data.defaultBox.yOffset = (int)((float)src->_data.defaultBox.yOffset * scale);
+ data.ascent = (int)((float)src->_data.ascent * scale);
data.firstCharacter = src->_data.firstCharacter;
data.defaultCharacter = src->_data.defaultCharacter;
data.numCharacters = src->_data.numCharacters;
@@ -730,22 +730,24 @@ BdfFont *BdfFont::scaleFont(BdfFont *src, int newSize) {
BdfBoundingBox *boxes = new BdfBoundingBox[data.numCharacters];
for (int i = 0; i < data.numCharacters; ++i) {
- boxes[i].width = src->_data.boxes[i].width * scale;
- boxes[i].height = src->_data.boxes[i].height * scale;
- boxes[i].xOffset = src->_data.boxes[i].xOffset * scale;
- boxes[i].yOffset = src->_data.boxes[i].yOffset * scale;
+ boxes[i].width = (int)((float)src->_data.boxes[i].width * scale);
+ if (i == 40)
+ warning("char w: %d, scale: %g", boxes[i].width, scale);
+ boxes[i].height = (int)((float)src->_data.boxes[i].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;
byte *advances = new byte[data.numCharacters];
for (int i = 0; i < data.numCharacters; ++i) {
- advances[i] = src->_data.advances[i] * scale;
+ advances[i] = (int)((float)src->_data.advances[i] * scale);
}
data.advances = advances;
byte **bitmaps = new byte *[data.numCharacters];
- for (int i = 0; i < data.numCharacters; ++i) {
+ for (int i = 0; i < data.numCharacters; i++) {
const BdfBoundingBox &box = data.boxes ? data.boxes[i] : data.defaultBox;
const BdfBoundingBox &srcBox = data.boxes ? src->_data.boxes[i] : src->_data.defaultBox;
@@ -759,26 +761,28 @@ BdfFont *BdfFont::scaleFont(BdfFont *src, int newSize) {
byte *ptr = bitmaps[i];
for (int y = 0; y < box.height; y++) {
- byte *srcd = (byte *)&src->_data.bitmaps[i][((int)(y * scale)) * srcPitch];
+ byte *srcd = (byte *)&src->_data.bitmaps[i][((int)((float)y / scale)) * srcPitch];
byte *dst = ptr;
byte b = 0;
- for (int x = 0; x < box.width; ++x) {
+ for (int x = 0; x < box.width; x++) {
+ int sx = (int)((float)x / scale);
+
+ if (srcd[sx / 8] & (0x80 >> (sx % 8)))
+ b |= 1;
+
if (!(x % 8) && x) {
*dst++ = b;
b = 0;
}
- int sx = x * scale;
-
- if (srcd[sx / 8] & (0x80 >> (sx % 8)))
- b |= 1;
-
b <<= 1;
}
- if (!((box.width - 1) % 8))
+ if (((box.width - 1) % 8)) {
+ b <<= 7 - ((box.width - 1) % 8);
*dst = b;
+ }
ptr += dstPitch;
}
More information about the Scummvm-git-logs
mailing list