mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-31 07:53:36 +00:00
VIDEO: Load font for Subtitles
This commit is contained in:
parent
8fa9f74d59
commit
9cb80bc9fb
@ -22,6 +22,9 @@
|
||||
#include "common/debug.h"
|
||||
#include "common/file.h"
|
||||
|
||||
#include "graphics/fonts/ttf.h"
|
||||
#include "graphics/fontman.h"
|
||||
|
||||
#include "video/subtitles.h"
|
||||
|
||||
namespace Video {
|
||||
@ -218,12 +221,32 @@ Common::String SRTParser::getSubtitle(uint32 timestamp) {
|
||||
return (*entry)->text;
|
||||
}
|
||||
|
||||
Subtitles::Subtitles() : _loaded(false) {
|
||||
Subtitles::Subtitles() : _loaded(false), _font(nullptr) {
|
||||
}
|
||||
|
||||
Subtitles::~Subtitles() {
|
||||
}
|
||||
|
||||
void Subtitles::loadFont(const char *fontname, int height) {
|
||||
Common::File file;
|
||||
|
||||
_fontHeight = height;
|
||||
|
||||
if (!file.open(fontname)) {
|
||||
_font = Graphics::loadTTFFont(file, _fontHeight, Graphics::kTTFSizeModeCharacter, 96);
|
||||
}
|
||||
|
||||
if (!_font)
|
||||
_font = FontMan.getFontByName(fontname);
|
||||
|
||||
if (!_font) {
|
||||
warning("Cannot load font %s", fontname);
|
||||
|
||||
_font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Subtitles::loadSRTFile(const char *fname) {
|
||||
debug(1, "loadSRTFile('%s')", fname);
|
||||
|
||||
|
@ -25,6 +25,10 @@
|
||||
#include "common/str.h"
|
||||
#include "common/array.h"
|
||||
|
||||
namespace Graphics {
|
||||
class Font;
|
||||
}
|
||||
|
||||
namespace Video {
|
||||
|
||||
struct SRTEntry {
|
||||
@ -58,10 +62,14 @@ public:
|
||||
~Subtitles();
|
||||
|
||||
void loadSRTFile(const char *fname);
|
||||
void loadFont(const char *fontname, int height = 30);
|
||||
|
||||
private:
|
||||
SRTParser _srtParser;
|
||||
bool _loaded;
|
||||
|
||||
const Graphics::Font *_font;
|
||||
int _fontHeight;
|
||||
};
|
||||
|
||||
} // End of namespace Video
|
||||
|
Loading…
x
Reference in New Issue
Block a user