aboutsummaryrefslogtreecommitdiff
path: root/graphics/fonts/ttf.cpp
diff options
context:
space:
mode:
authorCameron Cawley2018-12-08 21:08:29 +0000
committerEugene Sandulenko2018-12-25 12:47:42 +0100
commitfa60ae728e2b54eceaefd57b82752056cfa198bb (patch)
tree27a30c7388d6d1f9457ae4ad852b0eabe5bce17b /graphics/fonts/ttf.cpp
parent1f6727eab85c8f544718deba6a820e1b71ee5c93 (diff)
downloadscummvm-rg350-fa60ae728e2b54eceaefd57b82752056cfa198bb.tar.gz
scummvm-rg350-fa60ae728e2b54eceaefd57b82752056cfa198bb.tar.bz2
scummvm-rg350-fa60ae728e2b54eceaefd57b82752056cfa198bb.zip
GRAPHICS: Add a function to load TrueType fonts from fonts.dat
Diffstat (limited to 'graphics/fonts/ttf.cpp')
-rw-r--r--graphics/fonts/ttf.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/graphics/fonts/ttf.cpp b/graphics/fonts/ttf.cpp
index 76b7f731be..0b7ae50e41 100644
--- a/graphics/fonts/ttf.cpp
+++ b/graphics/fonts/ttf.cpp
@@ -31,11 +31,13 @@
#include "graphics/font.h"
#include "graphics/surface.h"
+#include "common/file.h"
#include "common/singleton.h"
#include "common/stream.h"
#include "common/memstream.h"
#include "common/hashmap.h"
#include "common/ptr.h"
+#include "common/unzip.h"
#include <ft2build.h>
#include FT_FREETYPE_H
@@ -666,6 +668,23 @@ Font *loadTTFFont(Common::SeekableReadStream &stream, int size, TTFSizeMode size
return font;
}
+Font *loadTTFFontFromArchive(const Common::String &filename, int size, TTFSizeMode sizeMode, uint dpi, TTFRenderMode renderMode, const uint32 *mapping) {
+ Common::Archive *archive;
+ if (!Common::File::exists("fonts.dat") || (archive = Common::makeZipArchive("fonts.dat")) == nullptr) {
+ return 0;
+ }
+
+ Common::File f;
+ if (!f.open(filename, *archive)) {
+ return 0;
+ }
+
+ Font *font = loadTTFFont(f, size, sizeMode, dpi, renderMode, mapping);
+
+ delete archive;
+ return font;
+}
+
} // End of namespace Graphics
namespace Common {