diff --git a/CMakeLists.txt b/CMakeLists.txt index d60ee43..6ed5afc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,7 +66,8 @@ if (EMSCRIPTEN) add_emscripten_library(zlib -sUSE_ZLIB=1) add_emscripten_library(sdl2 -sUSE_SDL=2) add_emscripten_library(freetype2 -sUSE_FREETYPE=1) - set(DEFAULT_FONT_PATH /fonts/) + set(DEFAULT_GOTHIC_TTF /fonts/MTLc3m.ttf) + set(DEFAULT_MINCHO_TTF /fonts/mincho.ttf) fetch_webp() set(HAVE_WEBP 1) @@ -98,11 +99,14 @@ else() # non-emscripten, non-android # harfbuzz and graphite2, which the static freetype depends on, are C++ libraries. target_link_libraries(freetype2 INTERFACE -lstdc++) add_static_library(sdl2_mixer SDL2MIXER) + set(DEFAULT_GOTHIC_TTF C:/Windows/Fonts/msgothic.ttc) + set(DEFAULT_MINCHO_TTF C:/Windows/Fonts/msmincho.ttc) else() add_library(sdl2 ALIAS PkgConfig::SDL2) add_library(freetype2 ALIAS PkgConfig::FREETYPE) add_library(sdl2_mixer ALIAS PkgConfig::SDL2MIXER) - set(DEFAULT_FONT_PATH ${CMAKE_INSTALL_PREFIX}/share/xsystem35/fonts/) + set(DEFAULT_GOTHIC_TTF ${CMAKE_INSTALL_PREFIX}/share/xsystem35/fonts/MTLc3m.ttf) + set(DEFAULT_MINCHO_TTF ${CMAKE_INSTALL_PREFIX}/share/xsystem35/fonts/mincho.ttf) endif() option(ENABLE_DEBUGGER "Enable built-in debugger" ON) diff --git a/config.h.in b/config.h.in index f489b3c..e33ab96 100644 --- a/config.h.in +++ b/config.h.in @@ -16,5 +16,5 @@ #cmakedefine HAVE_SIGACTION @HAVE_SIGACTION@ #cmakedefine HAVE_WEBP @HAVE_WEBP@ -#define DEFAULT_GOTHIC_TTF "@DEFAULT_FONT_PATH@MTLc3m.ttf" -#define DEFAULT_MINCHO_TTF "@DEFAULT_FONT_PATH@mincho.ttf" +#define DEFAULT_GOTHIC_TTF "@DEFAULT_GOTHIC_TTF@" +#define DEFAULT_MINCHO_TTF "@DEFAULT_MINCHO_TTF@" diff --git a/fonts/CMakeLists.txt b/fonts/CMakeLists.txt index 245b17c..da00f90 100644 --- a/fonts/CMakeLists.txt +++ b/fonts/CMakeLists.txt @@ -1,7 +1,9 @@ -install(FILES - MTLc3m.ttf - mincho.ttf - DESTINATION share/xsystem35/fonts) +if (NOT WIN32 AND NOT ANDROID AND NOT EMSCRIPTEN) + install(FILES + MTLc3m.ttf + mincho.ttf + DESTINATION share/xsystem35/fonts) +endif() # pyftsubset is included in fonttools. find_program(PYFTSUBSET_FOUND pyftsubset) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fd657ca..7ee4fac 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -138,7 +138,7 @@ endif() if (WIN32) target_sources(xsystem35 PRIVATE - win/dialog.c win/resources.rc win/resources.c win/menubar.c win/console.c) + win/dialog.c win/resources.rc win/menubar.c win/console.c) endif() if (NOT HAVE_LIBINTL) diff --git a/src/font.c b/src/font.c index 833e312..7666244 100644 --- a/src/font.c +++ b/src/font.c @@ -28,10 +28,6 @@ #include FT_OUTLINE_H #include FT_TRUETYPE_TABLES_H -#ifdef _WIN32 -#include "win/resources.h" -#endif - #ifdef __EMSCRIPTEN__ #include #endif @@ -60,7 +56,7 @@ static struct { FT_Face face[FONTTYPEMAX]; // opened on first use, shared between all sizes } this; -#if defined(_WIN32) || defined(__ANDROID__) +#ifdef __ANDROID__ // Create a face from the whole content of `rw`. The memory holding the font // file must outlive the face, and faces are never closed, so it is never freed. static FT_Face face_from_rwops(SDL_RWops *rw, int index) { @@ -89,12 +85,7 @@ static FT_Face face_from_rwops(SDL_RWops *rw, int index) { static FT_Face open_face(const char *name, int index) { FT_Face face = NULL; -#ifdef _WIN32 - SDL_RWops *res = open_resource(name, "fonts"); - if (res) - face = face_from_rwops(res, index); -#endif - if (!face && FT_New_Face(ft_library, name, index, &face)) + if (FT_New_Face(ft_library, name, index, &face)) face = NULL; // FT_New_Face() does not clear `face` on failure. #ifdef __ANDROID__ // The default fonts are stored as apk assets, which can only be opened diff --git a/src/win/resources.c b/src/win/resources.c deleted file mode 100644 index 41b8fc1..0000000 --- a/src/win/resources.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2024 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -#include -#include -#include "resources.h" - -SDL_RWops *open_resource(const char* name, const char* type) { - HINSTANCE hInst = GetModuleHandle(NULL); - HRSRC hRes = FindResource(hInst, name, type); - if (!hRes) return NULL; - HGLOBAL hGlobal = LoadResource(hInst, hRes); - if (!hGlobal) return NULL; - return SDL_RWFromConstMem(LockResource(hGlobal), SizeofResource(hInst, hRes)); -} diff --git a/src/win/resources.h b/src/win/resources.h index 8dc04d6..a549561 100644 --- a/src/win/resources.h +++ b/src/win/resources.h @@ -42,7 +42,4 @@ #define ID_OPTION_SOUND 40023 #define ID_MSGSKIP 40030 -struct SDL_RWops; -struct SDL_RWops *open_resource(const char* name, const char* type); - #endif /* __RESOURCES_H__ */ diff --git a/src/win/resources.rc b/src/win/resources.rc index 2418cb5..4fe18ef 100644 --- a/src/win/resources.rc +++ b/src/win/resources.rc @@ -5,14 +5,6 @@ CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "xsystem35.exe.manifest" 100 ICON DISCARDABLE "xsystem35.ico" -// Note for game translators: -// Rather than replacing these, use the "ttfont_gothic" and "ttfont_mincho" -// options in .xsys35rc. That will allow your translated game run on other -// other platforms, such as Android and Web. -MTLc3m.ttf FONTS DISCARDABLE "../../fonts/MTLc3m.ttf" -mincho.ttf FONTS DISCARDABLE "../../fonts/mincho.ttf" - - //////////////////////////////////////////////////////////////////////// LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL