diff options
author | Paul Gilbert | 2018-10-27 21:48:22 -0700 |
---|---|---|
committer | Paul Gilbert | 2018-12-08 19:05:59 -0800 |
commit | e5854a6bd35fb29912bc185af32a3443598dc3cb (patch) | |
tree | c68ec451d84e9037b16c8d76811a8a17bc34cc53 | |
parent | 65fa4fa7cbfeb5eae8da6e8a4a077f3c8e1866f6 (diff) | |
download | scummvm-rg350-e5854a6bd35fb29912bc185af32a3443598dc3cb.tar.gz scummvm-rg350-e5854a6bd35fb29912bc185af32a3443598dc3cb.tar.bz2 scummvm-rg350-e5854a6bd35fb29912bc185af32a3443598dc3cb.zip |
GLK: Add loading of TrueType fonts
-rw-r--r-- | engines/gargoyle/configure.engine | 2 | ||||
-rw-r--r-- | engines/gargoyle/fonts.cpp | 36 | ||||
-rw-r--r-- | engines/gargoyle/fonts.h | 15 |
3 files changed, 36 insertions, 17 deletions
diff --git a/engines/gargoyle/configure.engine b/engines/gargoyle/configure.engine index 671f91cf54..3569297cbd 100644 --- a/engines/gargoyle/configure.engine +++ b/engines/gargoyle/configure.engine @@ -1,3 +1,3 @@ # This file is included from the main "configure" script # add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] -add_engine gargoyle "Interactive Fiction games" no +add_engine gargoyle "Interactive Fiction games" no "" "" "freetype2" diff --git a/engines/gargoyle/fonts.cpp b/engines/gargoyle/fonts.cpp index 9264db2f46..41067a5185 100644 --- a/engines/gargoyle/fonts.cpp +++ b/engines/gargoyle/fonts.cpp @@ -23,6 +23,8 @@ #include "gargoyle/fonts.h" #include "gargoyle/glk_types.h" #include "gargoyle/conf.h" +#include "common/file.h" +#include "graphics/fonts/ttf.h" namespace Gargoyle { @@ -54,15 +56,15 @@ Fonts::Fonts() { double monoSize = g_conf->_monoSize; double propSize = g_conf->_propSize; - _fontTable[0] = new Font(gli_conf_monor, monoSize, monoAspect, FONTR); - _fontTable[1] = new Font(gli_conf_monob, monoSize, monoAspect, FONTB); - _fontTable[2] = new Font(gli_conf_monoi, monoSize, monoAspect, FONTI); - _fontTable[3] = new Font(gli_conf_monoz, monoSize, monoAspect, FONTZ); + _fontTable[0] = loadFont(MONOR, monoSize, monoAspect, FONTR); + _fontTable[1] = loadFont(MONOB, monoSize, monoAspect, FONTB); + _fontTable[2] = loadFont(MONOI, monoSize, monoAspect, FONTI); + _fontTable[3] = loadFont(MONOZ, monoSize, monoAspect, FONTZ); - _fontTable[4] = new Font(gli_conf_propr, propSize, propAspect, FONTR); - _fontTable[5] = new Font(gli_conf_propb, propSize, propAspect, FONTB); - _fontTable[6] = new Font(gli_conf_propi, propSize, propAspect, FONTI); - _fontTable[7] = new Font(gli_conf_propz, propSize, propAspect, FONTZ); + _fontTable[4] = loadFont(PROPR, propSize, propAspect, FONTR); + _fontTable[5] = loadFont(PROPB, propSize, propAspect, FONTB); + _fontTable[6] = loadFont(PROPI, propSize, propAspect, FONTI); + _fontTable[7] = loadFont(PROPZ, propSize, propAspect, FONTZ); } Fonts::~Fonts() { @@ -82,8 +84,24 @@ FACES Fonts::getId(const Common::String &name) { return MONOR; } -/*--------------------------------------------------------------------------*/ +Graphics::Font *Fonts::loadFont(FACES face, double size, double aspect, int style) { + static const char *const MAP[8] = { + "Go-Mono-Regular", + "Go-Mono-Bold", + "Go-Mono-Italic", + "Go-Mono-BoldItalic", + "NotoSerif-Regular", + "NotoSerif-Bold", + "NotoSerif-Italic", + "NotoSerif-BoldItalic" + }; + Common::File f; + if (!f.open(Common::String::format("%s.ttf", MAP[face]))) + return nullptr; + + return Graphics::loadTTFFont(f, size, Graphics::kTTFSizeModeCharacter); +} } // End of namespace Gargoyle diff --git a/engines/gargoyle/fonts.h b/engines/gargoyle/fonts.h index c3034743ce..be00a8db8a 100644 --- a/engines/gargoyle/fonts.h +++ b/engines/gargoyle/fonts.h @@ -25,6 +25,7 @@ #include "gargoyle/glk_types.h" #include "common/str.h" +#include "graphics/font.h" namespace Gargoyle { @@ -34,19 +35,19 @@ enum FACES { MONOR, MONOB, MONOI, MONOZ, PROPR, PROPB, PROPI, PROPZ }; enum TYPES { MONOF, PROPF }; enum STYLES { FONTR, FONTB, FONTI, FONTZ }; +/* class Font { + public: - /** - * Constructor - */ - Font(const char *name, double size, double aspect, STYLES style) { - // TODO - } + Font(const char *name, double size, double aspect, STYLES style); }; +*/ class Fonts { private: - Font *_fontTable[FONTS_TOTAL]; + Graphics::Font *_fontTable[FONTS_TOTAL]; +private: + Graphics::Font *loadFont(FACES face, double size, double aspect, int style); public: /** * Get the index/id of a font by name |