Permalink
Browse files

MYST3: Use the TTF font provided by the game for subtitles

  • Loading branch information...
1 parent 50bb94d commit 6a1511e1f9139591d6abb666d1fa8d2b9178adac @bgK bgK committed Feb 12, 2012
Showing with 28 additions and 3 deletions.
  1. +22 −3 engines/myst3/subtitles.cpp
  2. +6 −0 engines/myst3/subtitles.h
@@ -26,6 +26,7 @@
#include "graphics/fontman.h"
#include "graphics/font.h"
+#include "graphics/fonts/ttf.h"
namespace Myst3 {
@@ -34,9 +35,11 @@ Subtitles::Subtitles(Myst3Engine *vm, uint32 id) :
_id(id),
_surface(0),
_texture(0),
- _frame(-1) {
+ _frame(-1),
+ _font(0) {
loadFontSettings(1100);
+ loadFont();
loadSubtitles(id);
createTexture();
}
@@ -49,6 +52,8 @@ Subtitles::~Subtitles() {
if (_texture) {
_vm->_gfx->freeTexture(_texture);
}
+
+ delete _font;
}
void Subtitles::loadFontSettings(int32 id) {
@@ -85,6 +90,17 @@ void Subtitles::loadFontSettings(int32 id) {
delete data;
}
+void Subtitles::loadFont() {
+ // Use the TTF font provided by the game if TTF support is available
+#ifdef USE_FREETYPE2
+ Common::SeekableReadStream *s = SearchMan.createReadStreamForMember("arir67w.ttf");
+ if (s) {
+ _font = Graphics::loadTTFFont(*s, _fontSize);
+ delete s;
+ }
+#endif
+}
+
void Subtitles::loadSubtitles(int32 id) {
// Subtitles may be overridden using a variable
const DirectorySubEntry *desc;
@@ -159,8 +175,11 @@ void Subtitles::setFrame(int32 frame) {
_frame = phrase->frame;
- // TODO: Use the TTF font provided by the game
- const Graphics::Font *font = FontMan.getFontByUsage(Graphics::FontManager::kLocalizedFont);
+ const Graphics::Font *font;
+ if (_font)
+ font = _font;
+ else
+ font = FontMan.getFontByUsage(Graphics::FontManager::kLocalizedFont);
if (!font)
error("No available font");
@@ -27,6 +27,10 @@
#include "common/array.h"
+namespace Graphics {
+ class Font;
+}
+
namespace Myst3 {
class Myst3Engine;
@@ -41,6 +45,7 @@ class Subtitles : public Drawable {
private:
void loadFontSettings(int32 id);
+ void loadFont();
void loadSubtitles(int32 id);
void createTexture();
@@ -52,6 +57,7 @@ class Subtitles : public Drawable {
Myst3Engine *_vm;
uint32 _id;
+ const Graphics::Font *_font;
Common::Array<Phrase> _phrases;

0 comments on commit 6a1511e

Please sign in to comment.