aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/ThemeNew.cpp102
-rw-r--r--gui/theme.h1
-rw-r--r--gui/themes/modern.zipbin32709 -> 34689 bytes
3 files changed, 82 insertions, 21 deletions
diff --git a/gui/ThemeNew.cpp b/gui/ThemeNew.cpp
index 1a225c3ab8..11b737ffb1 100644
--- a/gui/ThemeNew.cpp
+++ b/gui/ThemeNew.cpp
@@ -1341,38 +1341,98 @@ void ThemeNew::deleteFonts() {
}
const Graphics::Font *ThemeNew::loadFont(const char *filename) {
- const Graphics::Font *font = 0;
-
+ const Graphics::NewFont *font = 0;
+ Common::String cacheFilename = genCacheFilename(filename);
Common::File fontFile;
- if (fontFile.open(filename)) {
- font = Graphics::loadFont(fontFile);
+
+ if (cacheFilename != "") {
+ if (fontFile.open(cacheFilename))
+ font = Graphics::NewFont::loadFromCache(fontFile);
if (font)
return font;
+
+#ifdef USE_ZLIB
+ unzFile zipFile = unzOpen((_stylefile + ".zip").c_str());
+ if (zipFile && unzLocateFile(zipFile, cacheFilename.c_str(), 2) == UNZ_OK) {
+ unz_file_info fileInfo;
+ unzOpenCurrentFile(zipFile);
+ unzGetCurrentFileInfo(zipFile, &fileInfo, NULL, 0, NULL, 0, NULL, 0);
+ uint8 *buffer = new uint8[fileInfo.uncompressed_size+1];
+ assert(buffer);
+ memset(buffer, 0, (fileInfo.uncompressed_size+1)*sizeof(uint8));
+ unzReadCurrentFile(zipFile, buffer, fileInfo.uncompressed_size);
+ unzCloseCurrentFile(zipFile);
+ Common::MemoryReadStream stream(buffer, fileInfo.uncompressed_size+1);
+
+ font = Graphics::NewFont::loadFromCache(stream);
+
+ delete [] buffer;
+ buffer = 0;
+ }
+ unzClose(zipFile);
+#endif
+ if (font)
+ return font;
+ }
+
+ printf("normal font open!\n");
+ fflush(stdout);
+
+ // normal open
+ if (fontFile.open(filename)) {
+ font = Graphics::NewFont::loadFont(fontFile);
}
#ifdef USE_ZLIB
- unzFile zipFile = unzOpen((_stylefile + ".zip").c_str());
- if (zipFile && unzLocateFile(zipFile, filename, 2) == UNZ_OK) {
- unz_file_info fileInfo;
- unzOpenCurrentFile(zipFile);
- unzGetCurrentFileInfo(zipFile, &fileInfo, NULL, 0, NULL, 0, NULL, 0);
- uint8 *buffer = new uint8[fileInfo.uncompressed_size+1];
- assert(buffer);
- memset(buffer, 0, (fileInfo.uncompressed_size+1)*sizeof(uint8));
- unzReadCurrentFile(zipFile, buffer, fileInfo.uncompressed_size);
- unzCloseCurrentFile(zipFile);
- Common::MemoryReadStream stream(buffer, fileInfo.uncompressed_size+1);
-
- font = Graphics::loadFont(stream);
-
- delete [] buffer;
- buffer = 0;
+ if (!font) {
+ unzFile zipFile = unzOpen((_stylefile + ".zip").c_str());
+ if (zipFile && unzLocateFile(zipFile, filename, 2) == UNZ_OK) {
+ unz_file_info fileInfo;
+ unzOpenCurrentFile(zipFile);
+ unzGetCurrentFileInfo(zipFile, &fileInfo, NULL, 0, NULL, 0, NULL, 0);
+ uint8 *buffer = new uint8[fileInfo.uncompressed_size+1];
+ assert(buffer);
+ memset(buffer, 0, (fileInfo.uncompressed_size+1)*sizeof(uint8));
+ unzReadCurrentFile(zipFile, buffer, fileInfo.uncompressed_size);
+ unzCloseCurrentFile(zipFile);
+ Common::MemoryReadStream stream(buffer, fileInfo.uncompressed_size+1);
+
+ font = Graphics::NewFont::loadFont(stream);
+
+ delete [] buffer;
+ buffer = 0;
+ }
+ unzClose(zipFile);
}
- unzClose(zipFile);
#endif
+
+ if (font) {
+ if (cacheFilename != "") {
+ if (!Graphics::NewFont::cacheFontData(*font, cacheFilename)) {
+ warning("Couldn't create cache file for font '%s'", filename);
+ }
+ }
+ }
+
return font;
}
+Common::String ThemeNew::genCacheFilename(const char *filename) {
+ Common::String cacheName = filename;
+ for (int i = cacheName.size() - 1; i >= 0; --i) {
+ if (cacheName[i] == '.') {
+ while ((uint)i < cacheName.size() - 1) {
+ cacheName.deleteLastChar();
+ }
+
+ cacheName += "fcc";
+ return cacheName;
+ }
+ }
+
+ return "";
+}
+
#pragma mark -
OverlayColor ThemeNew::calcLuminance(OverlayColor col) {
diff --git a/gui/theme.h b/gui/theme.h
index 734ff3c37a..8b0e59a6de 100644
--- a/gui/theme.h
+++ b/gui/theme.h
@@ -364,6 +364,7 @@ private:
void setupFonts();
void deleteFonts();
const Graphics::Font *loadFont(const char *filename);
+ Common::String genCacheFilename(const char *filename);
const Graphics::Font *_fonts[kFontStyleMax];
public:
diff --git a/gui/themes/modern.zip b/gui/themes/modern.zip
index 8c44d3e16f..1817123542 100644
--- a/gui/themes/modern.zip
+++ b/gui/themes/modern.zip
Binary files differ