Skip to content

Commit

Permalink
DIRECTOR: Added Mac font rendering test
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Oct 15, 2016
1 parent 290ac2c commit 23544e6
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions engines/director/director.cpp
Expand Up @@ -117,6 +117,8 @@ Common::Error DirectorEngine::run() {
//_mainArchive = new RIFFArchive();
//_mainArchive->openFile("bookshelf_example.mmm");

//testFont();

scanMovies(ConfMan.get("path"));

loadSharedCastsFrom(_sharedCastFile);
Expand Down
3 changes: 3 additions & 0 deletions engines/director/director.h
Expand Up @@ -133,6 +133,9 @@ class DirectorEngine : public ::Engine {
Lingo *_lingo;

Common::String _sharedCastFile;

private:
void testFont();
};

} // End of namespace Director
Expand Down
47 changes: 47 additions & 0 deletions engines/director/score.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 23544e6

Please sign in to comment.