From 6a231e4b6025b8dc0fb6ad7ff26388261ac7642f Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Wed, 1 May 2019 05:50:08 +0200 Subject: GRAPHICS: Look for fonts.dat in extrapath When running from the source tree, it is convenient to have extrapath set to dists/engine-data, where fonts.dat is located. --- graphics/fonts/ttf.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'graphics/fonts/ttf.cpp') diff --git a/graphics/fonts/ttf.cpp b/graphics/fonts/ttf.cpp index 0b7ae50e41..89f26c7727 100644 --- a/graphics/fonts/ttf.cpp +++ b/graphics/fonts/ttf.cpp @@ -32,6 +32,7 @@ #include "graphics/surface.h" #include "common/file.h" +#include "common/config-manager.h" #include "common/singleton.h" #include "common/stream.h" #include "common/memstream.h" @@ -669,14 +670,24 @@ Font *loadTTFFont(Common::SeekableReadStream &stream, int size, TTFSizeMode size } 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::SeekableReadStream *archiveStream = nullptr; + if (ConfMan.hasKey("extrapath")) { + Common::FSDirectory extrapath(ConfMan.get("extrapath")); + archiveStream = extrapath.createReadStreamForMember("fonts.dat"); + } + + if (!archiveStream) { + archiveStream = SearchMan.createReadStreamForMember("fonts.dat"); + } + + Common::Archive *archive = Common::makeZipArchive(archiveStream); + if (!archive) { + return nullptr; } Common::File f; if (!f.open(filename, *archive)) { - return 0; + return nullptr; } Font *font = loadTTFFont(f, size, sizeMode, dpi, renderMode, mapping); -- cgit v1.2.3