mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-09-29 10:18:11 +03:00
Use msgothic.ttc / msmincho.ttc by default on Windows
Windows ships Japanese fonts, so use C:/Windows/Fonts/msgothic.ttc and msmincho.ttc as the defaults instead of bundling MTLc3m.ttf / mincho.ttf.
This commit is contained in:
+6
-2
@@ -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)
|
||||
|
||||
+2
-2
@@ -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@"
|
||||
|
||||
@@ -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)
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
+2
-11
@@ -28,10 +28,6 @@
|
||||
#include FT_OUTLINE_H
|
||||
#include FT_TRUETYPE_TABLES_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "win/resources.h"
|
||||
#endif
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#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
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2024 <KichikuouChrome@gmail.com>
|
||||
*
|
||||
* 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 <windows.h>
|
||||
#include <SDL_rwops.h>
|
||||
#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));
|
||||
}
|
||||
@@ -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__ */
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user