Fully remove bitmap font support (#11863)

Freetype is now a build requirement.
This commit is contained in:
sfan5 2022-01-08 14:53:25 +01:00 committed by GitHub
parent bf22569019
commit 76dbd0d2d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 71 additions and 319 deletions

@ -150,29 +150,6 @@ jobs:
run: | run: |
./bin/minetestserver --run-unittests ./bin/minetestserver --run-unittests
# Build without freetype (client-only)
clang_9_no_freetype:
name: "clang_9 (FREETYPE=0)"
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Install deps
run: |
source ./util/ci/common.sh
install_linux_deps clang-9
- name: Build
run: |
./util/ci/build.sh
env:
CC: clang-9
CXX: clang++-9
CMAKE_FLAGS: "-DENABLE_FREETYPE=0 -DBUILD_SERVER=0"
- name: Test
run: |
./bin/minetest --run-unittests
docker: docker:
name: "Docker image" name: "Docker image"
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04

@ -135,7 +135,8 @@ Compiling
| GCC | 4.9+ | Can be replaced with Clang 3.4+ | | GCC | 4.9+ | Can be replaced with Clang 3.4+ |
| CMake | 3.5+ | | | CMake | 3.5+ | |
| IrrlichtMt | - | Custom version of Irrlicht, see https://github.com/minetest/irrlicht | | IrrlichtMt | - | Custom version of Irrlicht, see https://github.com/minetest/irrlicht |
| SQLite3 | 3.0+ | | | Freetype | 2.0+ | |
| SQLite3 | 3+ | |
| Zstd | 1.0+ | | | Zstd | 1.0+ | |
| LuaJIT | 2.0+ | Bundled Lua 5.1 is used if not present | | LuaJIT | 2.0+ | Bundled Lua 5.1 is used if not present |
| GMP | 5.0.0+ | Bundled mini-GMP is used if not present | | GMP | 5.0.0+ | Bundled mini-GMP is used if not present |
@ -143,7 +144,7 @@ Compiling
For Debian/Ubuntu users: For Debian/Ubuntu users:
sudo apt install g++ make libc6-dev cmake libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev libzstd-dev sudo apt install g++ make libc6-dev cmake libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev libzstd-dev libluajit-5.1-dev
For Fedora users: For Fedora users:
@ -247,7 +248,6 @@ General options and their default values:
MinSizeRel - Release build with -Os passed to compiler to make executable as small as possible MinSizeRel - Release build with -Os passed to compiler to make executable as small as possible
ENABLE_CURL=ON - Build with cURL; Enables use of online mod repo, public serverlist and remote media fetching via http ENABLE_CURL=ON - Build with cURL; Enables use of online mod repo, public serverlist and remote media fetching via http
ENABLE_CURSES=ON - Build with (n)curses; Enables a server side terminal (command line option: --terminal) ENABLE_CURSES=ON - Build with (n)curses; Enables a server side terminal (command line option: --terminal)
ENABLE_FREETYPE=ON - Build with FreeType2; Allows using TTF fonts
ENABLE_GETTEXT=ON - Build with Gettext; Allows using translations ENABLE_GETTEXT=ON - Build with Gettext; Allows using translations
ENABLE_GLES=OFF - Build for OpenGL ES instead of OpenGL (requires support by IrrlichtMt) ENABLE_GLES=OFF - Build for OpenGL ES instead of OpenGL (requires support by IrrlichtMt)
ENABLE_LEVELDB=ON - Build with LevelDB; Enables use of LevelDB map backend ENABLE_LEVELDB=ON - Build with LevelDB; Enables use of LevelDB map backend
@ -273,10 +273,10 @@ Library specific options:
EGL_INCLUDE_DIR - Only if building with GLES; directory that contains egl.h EGL_INCLUDE_DIR - Only if building with GLES; directory that contains egl.h
EGL_LIBRARY - Only if building with GLES; path to libEGL.a/libEGL.so EGL_LIBRARY - Only if building with GLES; path to libEGL.a/libEGL.so
EXTRA_DLL - Only on Windows; optional paths to additional DLLs that should be packaged EXTRA_DLL - Only on Windows; optional paths to additional DLLs that should be packaged
FREETYPE_INCLUDE_DIR_freetype2 - Only if building with FreeType 2; directory that contains an freetype directory with files such as ftimage.h in it FREETYPE_INCLUDE_DIR_freetype2 - Directory that contains files such as ftimage.h
FREETYPE_INCLUDE_DIR_ft2build - Only if building with FreeType 2; directory that contains ft2build.h FREETYPE_INCLUDE_DIR_ft2build - Directory that contains ft2build.h
FREETYPE_LIBRARY - Only if building with FreeType 2; path to libfreetype.a/libfreetype.so/freetype.lib FREETYPE_LIBRARY - Path to libfreetype.a/libfreetype.so/freetype.lib
FREETYPE_DLL - Only if building with FreeType 2 on Windows; path to libfreetype.dll FREETYPE_DLL - Only on Windows; path to libfreetype-6.dll
GETTEXT_DLL - Only when building with gettext on Windows; paths to libintl + libiconv DLLs GETTEXT_DLL - Only when building with gettext on Windows; paths to libintl + libiconv DLLs
GETTEXT_INCLUDE_DIR - Only when building with gettext; directory that contains iconv.h GETTEXT_INCLUDE_DIR - Only when building with gettext; directory that contains iconv.h
GETTEXT_LIBRARY - Only when building with gettext on Windows; path to libintl.dll.a GETTEXT_LIBRARY - Only when building with gettext on Windows; path to libintl.dll.a
@ -337,7 +337,6 @@ vcpkg install zlib zstd curl[winssl] openal-soft libvorbis libogg libjpeg-turbo
- **Don't forget about IrrlichtMt.** The easiest way is to clone it to `lib/irrlichtmt` as described in the Linux section. - **Don't forget about IrrlichtMt.** The easiest way is to clone it to `lib/irrlichtmt` as described in the Linux section.
- `curl` is optional, but required to read the serverlist, `curl[winssl]` is required to use the content store. - `curl` is optional, but required to read the serverlist, `curl[winssl]` is required to use the content store.
- `openal-soft`, `libvorbis` and `libogg` are optional, but required to use sound. - `openal-soft`, `libvorbis` and `libogg` are optional, but required to use sound.
- `freetype` is optional, it allows true-type font rendering.
- `luajit` is optional, it replaces the integrated Lua interpreter with a faster just-in-time interpreter. - `luajit` is optional, it replaces the integrated Lua interpreter with a faster just-in-time interpreter.
- `gmp` and `jsoncpp` are optional, otherwise the bundled versions will be compiled - `gmp` and `jsoncpp` are optional, otherwise the bundled versions will be compiled
@ -429,8 +428,7 @@ cmake .. \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.14 \ -DCMAKE_OSX_DEPLOYMENT_TARGET=10.14 \
-DCMAKE_FIND_FRAMEWORK=LAST \ -DCMAKE_FIND_FRAMEWORK=LAST \
-DCMAKE_INSTALL_PREFIX=../build/macos/ \ -DCMAKE_INSTALL_PREFIX=../build/macos/ \
-DRUN_IN_PLACE=FALSE \ -DRUN_IN_PLACE=FALSE -DENABLE_GETTEXT=TRUE
-DENABLE_FREETYPE=TRUE -DENABLE_GETTEXT=TRUE
make -j$(nproc) make -j$(nproc)
make install make install

@ -91,7 +91,6 @@ LOCAL_CFLAGS += \
-DENABLE_GLES=1 \ -DENABLE_GLES=1 \
-DUSE_CURL=1 \ -DUSE_CURL=1 \
-DUSE_SOUND=1 \ -DUSE_SOUND=1 \
-DUSE_FREETYPE=1 \
-DUSE_LEVELDB=0 \ -DUSE_LEVELDB=0 \
-DUSE_LUAJIT=1 \ -DUSE_LUAJIT=1 \
-DUSE_GETTEXT=1 \ -DUSE_GETTEXT=1 \

@ -886,10 +886,6 @@ tooltip_show_delay (Tooltip delay) int 400
# Append item name to tooltip. # Append item name to tooltip.
tooltip_append_itemname (Append item name) bool false tooltip_append_itemname (Append item name) bool false
# Whether FreeType fonts are used, requires FreeType support to be compiled in.
# If disabled, bitmap and XML vectors fonts are used instead.
freetype (FreeType fonts) bool true
font_bold (Font bold by default) bool false font_bold (Font bold by default) bool false
font_italic (Font italic by default) bool false font_italic (Font italic by default) bool false
@ -909,9 +905,7 @@ font_size (Font size) int 16 1
# sized 16, 32, 48, etc., so a mod requesting a size of 25 will get 32. # sized 16, 32, 48, etc., so a mod requesting a size of 25 will get 32.
font_size_divisible_by (Font size divisible by) int 1 1 font_size_divisible_by (Font size divisible by) int 1 1
# Path to the default font. # Path to the default font. Must be a TrueType font.
# If “freetype” setting is enabled: Must be a TrueType font.
# If “freetype” setting is disabled: Must be a bitmap or XML vectors font.
# The fallback font will be used if the font cannot be loaded. # The fallback font will be used if the font cannot be loaded.
font_path (Regular font path) filepath fonts/Arimo-Regular.ttf font_path (Regular font path) filepath fonts/Arimo-Regular.ttf
@ -928,9 +922,7 @@ mono_font_size (Monospace font size) int 16 1
# sized 16, 32, 48, etc., so a mod requesting a size of 25 will get 32. # sized 16, 32, 48, etc., so a mod requesting a size of 25 will get 32.
mono_font_size_divisible_by (Monospace font size divisible by) int 1 1 mono_font_size_divisible_by (Monospace font size divisible by) int 1 1
# Path to the monospace font. # Path to the monospace font. Must be a TrueType font.
# If “freetype” setting is enabled: Must be a TrueType font.
# If “freetype” setting is disabled: Must be a bitmap or XML vectors font.
# This font is used for e.g. the console and profiler screen. # This font is used for e.g. the console and profiler screen.
mono_font_path (Monospace font path) filepath fonts/Cousine-Regular.ttf mono_font_path (Monospace font path) filepath fonts/Cousine-Regular.ttf
@ -938,9 +930,7 @@ mono_font_path_bold (Bold monospace font path) filepath fonts/Cousine-Bold.ttf
mono_font_path_italic (Italic monospace font path) filepath fonts/Cousine-Italic.ttf mono_font_path_italic (Italic monospace font path) filepath fonts/Cousine-Italic.ttf
mono_font_path_bold_italic (Bold and italic monospace font path) filepath fonts/Cousine-BoldItalic.ttf mono_font_path_bold_italic (Bold and italic monospace font path) filepath fonts/Cousine-BoldItalic.ttf
# Path of the fallback font. # Path of the fallback font. Must be a TrueType font.
# If “freetype” setting is enabled: Must be a TrueType font.
# If “freetype” setting is disabled: Must be a bitmap or XML vectors font.
# This font will be used for certain languages or if the default font is unavailable. # This font will be used for certain languages or if the default font is unavailable.
fallback_font_path (Fallback font path) filepath fonts/DroidSansFallbackFull.ttf fallback_font_path (Fallback font path) filepath fonts/DroidSansFallbackFull.ttf

@ -16,7 +16,6 @@ PREDEFINED = "USE_SPATIAL=1" \
"USE_REDIS=1" \ "USE_REDIS=1" \
"USE_SOUND=1" \ "USE_SOUND=1" \
"USE_CURL=1" \ "USE_CURL=1" \
"USE_FREETYPE=1" \
"USE_GETTEXT=1" "USE_GETTEXT=1"
# Input # Input

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 135 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

@ -122,16 +122,8 @@ if(BUILD_CLIENT)
endif() endif()
endif() endif()
if(BUILD_CLIENT)
option(ENABLE_FREETYPE "Enable FreeType2 (TrueType fonts and basic unicode support)" TRUE) find_package(Freetype REQUIRED)
set(USE_FREETYPE FALSE)
if(BUILD_CLIENT AND ENABLE_FREETYPE)
find_package(Freetype)
if(FREETYPE_FOUND)
message(STATUS "Freetype enabled.")
set(USE_FREETYPE TRUE)
endif()
endif() endif()
option(ENABLE_CURSES "Enable ncurses console" TRUE) option(ENABLE_CURSES "Enable ncurses console" TRUE)
@ -495,13 +487,11 @@ include_directories(
${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}
${ZLIB_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR}
${ZSTD_INCLUDE_DIR} ${ZSTD_INCLUDE_DIR}
${SOUND_INCLUDE_DIRS}
${SQLITE3_INCLUDE_DIR} ${SQLITE3_INCLUDE_DIR}
${LUA_INCLUDE_DIR} ${LUA_INCLUDE_DIR}
${GMP_INCLUDE_DIR} ${GMP_INCLUDE_DIR}
${JSON_INCLUDE_DIR} ${JSON_INCLUDE_DIR}
${LUA_BIT_INCLUDE_DIR} ${LUA_BIT_INCLUDE_DIR}
${X11_INCLUDE_DIR}
${PROJECT_SOURCE_DIR}/script ${PROJECT_SOURCE_DIR}/script
) )
@ -509,8 +499,12 @@ if(USE_GETTEXT)
include_directories(${GETTEXT_INCLUDE_DIR}) include_directories(${GETTEXT_INCLUDE_DIR})
endif() endif()
if(USE_FREETYPE) if(BUILD_CLIENT)
include_directories(${FREETYPE_INCLUDE_DIRS}) include_directories(
${FREETYPE_INCLUDE_DIRS}
${SOUND_INCLUDE_DIRS}
${X11_INCLUDE_DIR}
)
endif() endif()
if(USE_CURL) if(USE_CURL)
@ -539,6 +533,7 @@ if(BUILD_CLIENT)
${GMP_LIBRARY} ${GMP_LIBRARY}
${JSON_LIBRARY} ${JSON_LIBRARY}
${LUA_BIT_LIBRARY} ${LUA_BIT_LIBRARY}
${FREETYPE_LIBRARY}
${PLATFORM_LIBS} ${PLATFORM_LIBS}
) )
if(NOT USE_LUAJIT) if(NOT USE_LUAJIT)
@ -573,18 +568,12 @@ if(BUILD_CLIENT)
${CURL_LIBRARY} ${CURL_LIBRARY}
) )
endif() endif()
if(USE_FREETYPE)
if(FREETYPE_PKGCONFIG_FOUND) if(FREETYPE_PKGCONFIG_FOUND)
set_target_properties(${PROJECT_NAME} set_target_properties(${PROJECT_NAME}
PROPERTIES PROPERTIES
COMPILE_FLAGS "${FREETYPE_CFLAGS_STR}" COMPILE_FLAGS "${FREETYPE_CFLAGS_STR}"
) )
endif() endif()
target_link_libraries(
${PROJECT_NAME}
${FREETYPE_LIBRARY}
)
endif()
if (USE_CURSES) if (USE_CURSES)
target_link_libraries(${PROJECT_NAME} ${CURSES_LIBRARIES}) target_link_libraries(${PROJECT_NAME} ${CURSES_LIBRARIES})
endif() endif()
@ -896,14 +885,8 @@ if(BUILD_CLIENT)
endforeach() endforeach()
endif() endif()
# Install necessary fonts depending on configuration
if(USE_FREETYPE)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../fonts" DESTINATION "${SHAREDIR}" install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../fonts" DESTINATION "${SHAREDIR}"
FILES_MATCHING PATTERN "*.ttf" PATTERN "*.txt") FILES_MATCHING PATTERN "*.ttf" PATTERN "*.txt")
else()
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../fonts" DESTINATION "${SHAREDIR}"
FILES_MATCHING PATTERN "*.png" PATTERN "*.xml")
endif()
endif(BUILD_CLIENT) endif(BUILD_CLIENT)
if(BUILD_SERVER) if(BUILD_SERVER)

@ -24,10 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "porting.h" #include "porting.h"
#include "filesys.h" #include "filesys.h"
#include "gettext.h" #include "gettext.h"
#if USE_FREETYPE
#include "irrlicht_changes/CGUITTFont.h" #include "irrlicht_changes/CGUITTFont.h"
#endif
/** maximum size distance for getting a "similar" font size */ /** maximum size distance for getting a "similar" font size */
#define MAX_FONT_SIZE_OFFSET 10 #define MAX_FONT_SIZE_OFFSET 10
@ -45,9 +42,8 @@ static void font_setting_changed(const std::string &name, void *userdata)
FontEngine::FontEngine(gui::IGUIEnvironment* env) : FontEngine::FontEngine(gui::IGUIEnvironment* env) :
m_env(env) m_env(env)
{ {
for (u32 &i : m_default_size) { for (u32 &i : m_default_size) {
i = (FontMode) FONT_SIZE_UNSPECIFIED; i = FONT_SIZE_UNSPECIFIED;
} }
assert(g_settings != NULL); // pre-condition assert(g_settings != NULL); // pre-condition
@ -56,25 +52,19 @@ FontEngine::FontEngine(gui::IGUIEnvironment* env) :
readSettings(); readSettings();
if (m_currentMode != FM_Simple) { const char *settings[] = {
g_settings->registerChangedCallback("font_size", font_setting_changed, NULL); "font_size", "font_bold", "font_italic", "font_size_divisible_by",
g_settings->registerChangedCallback("font_bold", font_setting_changed, NULL); "mono_font_size", "mono_font_size_divisible_by",
g_settings->registerChangedCallback("font_italic", font_setting_changed, NULL); "font_shadow", "font_shadow_alpha",
g_settings->registerChangedCallback("font_path", font_setting_changed, NULL); "font_path", "font_path_bold", "font_path_italic", "font_path_bold_italic",
g_settings->registerChangedCallback("font_path_bold", font_setting_changed, NULL); "mono_font_path", "mono_font_path_bold", "mono_font_path_italic",
g_settings->registerChangedCallback("font_path_italic", font_setting_changed, NULL); "mono_font_path_bold_italic",
g_settings->registerChangedCallback("font_path_bolditalic", font_setting_changed, NULL); "fallback_font_path",
g_settings->registerChangedCallback("font_shadow", font_setting_changed, NULL); "screen_dpi", "gui_scaling",
g_settings->registerChangedCallback("font_shadow_alpha", font_setting_changed, NULL); };
g_settings->registerChangedCallback("font_size_divisible_by", font_setting_changed, NULL);
g_settings->registerChangedCallback("fallback_font_path", font_setting_changed, NULL);
}
g_settings->registerChangedCallback("mono_font_path", font_setting_changed, NULL); for (auto name : settings)
g_settings->registerChangedCallback("mono_font_size", font_setting_changed, NULL); g_settings->registerChangedCallback(name, font_setting_changed, NULL);
g_settings->registerChangedCallback("mono_font_size_divisible_by", font_setting_changed, NULL);
g_settings->registerChangedCallback("screen_dpi", font_setting_changed, NULL);
g_settings->registerChangedCallback("gui_scaling", font_setting_changed, NULL);
} }
/******************************************************************************/ /******************************************************************************/
@ -108,16 +98,8 @@ irr::gui::IGUIFont *FontEngine::getFont(FontSpec spec, bool may_fail)
{ {
if (spec.mode == FM_Unspecified) { if (spec.mode == FM_Unspecified) {
spec.mode = m_currentMode; spec.mode = m_currentMode;
} else if (m_currentMode == FM_Simple) {
// Freetype disabled -> Force simple mode
spec.mode = (spec.mode == FM_Mono ||
spec.mode == FM_SimpleMono) ?
FM_SimpleMono : FM_Simple;
// Support for those could be added, but who cares?
spec.bold = false;
spec.italic = false;
} else if (spec.mode == _FM_Fallback) { } else if (spec.mode == _FM_Fallback) {
// Fallback font doesn't support these either // Fallback font doesn't support these
spec.bold = false; spec.bold = false;
spec.italic = false; spec.italic = false;
} }
@ -134,11 +116,7 @@ irr::gui::IGUIFont *FontEngine::getFont(FontSpec spec, bool may_fail)
return it->second; return it->second;
// Font does not yet exist // Font does not yet exist
gui::IGUIFont *font = nullptr; gui::IGUIFont *font = initFont(spec);
if (spec.mode == FM_Simple || spec.mode == FM_SimpleMono)
font = initSimpleFont(spec);
else
font = initFont(spec);
if (!font && !may_fail) { if (!font && !may_fail) {
errorstream << "Minetest cannot continue without a valid font. " errorstream << "Minetest cannot continue without a valid font. "
@ -185,13 +163,6 @@ unsigned int FontEngine::getDefaultFontSize()
unsigned int FontEngine::getFontSize(FontMode mode) unsigned int FontEngine::getFontSize(FontMode mode)
{ {
if (m_currentMode == FM_Simple) {
if (mode == FM_Mono || mode == FM_SimpleMono)
return m_default_size[FM_SimpleMono];
else
return m_default_size[FM_Simple];
}
if (mode == FM_Unspecified) if (mode == FM_Unspecified)
return m_default_size[FM_Standard]; return m_default_size[FM_Standard];
@ -201,7 +172,6 @@ unsigned int FontEngine::getFontSize(FontMode mode)
/******************************************************************************/ /******************************************************************************/
void FontEngine::readSettings() void FontEngine::readSettings()
{ {
if (USE_FREETYPE && g_settings->getBool("freetype")) {
m_default_size[FM_Standard] = g_settings->getU16("font_size"); m_default_size[FM_Standard] = g_settings->getU16("font_size");
m_default_size[_FM_Fallback] = g_settings->getU16("font_size"); m_default_size[_FM_Fallback] = g_settings->getU16("font_size");
m_default_size[FM_Mono] = g_settings->getU16("mono_font_size"); m_default_size[FM_Mono] = g_settings->getU16("mono_font_size");
@ -209,13 +179,6 @@ void FontEngine::readSettings()
m_default_bold = g_settings->getBool("font_bold"); m_default_bold = g_settings->getBool("font_bold");
m_default_italic = g_settings->getBool("font_italic"); m_default_italic = g_settings->getBool("font_italic");
} else {
m_currentMode = FM_Simple;
}
m_default_size[FM_Simple] = g_settings->getU16("font_size");
m_default_size[FM_SimpleMono] = g_settings->getU16("mono_font_size");
cleanCache(); cleanCache();
updateFontCache(); updateFontCache();
updateSkin(); updateSkin();
@ -283,7 +246,6 @@ gui::IGUIFont *FontEngine::initFont(const FontSpec &spec)
Settings::getLayer(SL_DEFAULTS)->get(path_setting) Settings::getLayer(SL_DEFAULTS)->get(path_setting)
}; };
#if USE_FREETYPE
for (const std::string &font_path : fallback_settings) { for (const std::string &font_path : fallback_settings) {
gui::CGUITTFont *font = gui::CGUITTFont::createTTFont(m_env, gui::CGUITTFont *font = gui::CGUITTFont::createTTFont(m_env,
font_path.c_str(), size, true, true, font_shadow, font_path.c_str(), size, true, true, font_shadow,
@ -302,80 +264,5 @@ gui::IGUIFont *FontEngine::initFont(const FontSpec &spec)
} }
return font; return font;
} }
#else
errorstream << "FontEngine: Tried to load TTF font but Minetest was"
" compiled without Freetype." << std::endl;
#endif
return nullptr; return nullptr;
} }
/** initialize a font without freetype */
gui::IGUIFont *FontEngine::initSimpleFont(const FontSpec &spec)
{
assert(spec.mode == FM_Simple || spec.mode == FM_SimpleMono);
assert(spec.size != FONT_SIZE_UNSPECIFIED);
const std::string &font_path = g_settings->get(
(spec.mode == FM_SimpleMono) ? "mono_font_path" : "font_path");
size_t pos_dot = font_path.find_last_of('.');
std::string basename = font_path, ending;
if (pos_dot != std::string::npos)
ending = lowercase(font_path.substr(pos_dot));
if (ending == ".ttf") {
errorstream << "FontEngine: Found font \"" << font_path
<< "\" but freetype is not available." << std::endl;
return nullptr;
}
if (ending == ".xml" || ending == ".png")
basename = font_path.substr(0, pos_dot);
u32 size = std::floor(
RenderingEngine::getDisplayDensity() *
g_settings->getFloat("gui_scaling") *
spec.size);
irr::gui::IGUIFont *font = nullptr;
std::string font_extensions[] = { ".png", ".xml" };
// Find nearest matching font scale
// Does a "zig-zag motion" (positibe/negative), from 0 to MAX_FONT_SIZE_OFFSET
for (s32 zoffset = 0; zoffset < MAX_FONT_SIZE_OFFSET * 2; zoffset++) {
std::stringstream path;
// LSB to sign
s32 sign = (zoffset & 1) ? -1 : 1;
s32 offset = zoffset >> 1;
for (const std::string &ext : font_extensions) {
path.str(""); // Clear
path << basename << "_" << (size + offset * sign) << ext;
if (!fs::PathExists(path.str()))
continue;
font = m_env->getFont(path.str().c_str());
if (font) {
verbosestream << "FontEngine: found font: " << path.str() << std::endl;
break;
}
}
if (font)
break;
}
// try name direct
if (font == NULL) {
if (fs::PathExists(font_path)) {
font = m_env->getFont(font_path.c_str());
if (font)
verbosestream << "FontEngine: found font: " << font_path << std::endl;
}
}
return font;
}

@ -34,8 +34,6 @@ enum FontMode : u8 {
FM_Standard = 0, FM_Standard = 0,
FM_Mono, FM_Mono,
_FM_Fallback, // do not use directly _FM_Fallback, // do not use directly
FM_Simple,
FM_SimpleMono,
FM_MaxMode, FM_MaxMode,
FM_Unspecified FM_Unspecified
}; };
@ -140,9 +138,6 @@ private:
/** initialize a new TTF font */ /** initialize a new TTF font */
gui::IGUIFont *initFont(const FontSpec &spec); gui::IGUIFont *initFont(const FontSpec &spec);
/** initialize a font without freetype */
gui::IGUIFont *initSimpleFont(const FontSpec &spec);
/** update current minetest skin with font changes */ /** update current minetest skin with font changes */
void updateSkin(); void updateSkin();
@ -165,8 +160,8 @@ private:
bool m_default_bold = false; bool m_default_bold = false;
bool m_default_italic = false; bool m_default_italic = false;
/** current font engine mode */ /** default font engine mode (fixed) */
FontMode m_currentMode = FM_Standard; static const FontMode m_currentMode = FM_Standard;
DISABLE_CLASS_COPY(FontEngine); DISABLE_CLASS_COPY(FontEngine);
}; };

@ -18,7 +18,6 @@
#cmakedefine01 USE_GETTEXT #cmakedefine01 USE_GETTEXT
#cmakedefine01 USE_CURL #cmakedefine01 USE_CURL
#cmakedefine01 USE_SOUND #cmakedefine01 USE_SOUND
#cmakedefine01 USE_FREETYPE
#cmakedefine01 USE_CURSES #cmakedefine01 USE_CURSES
#cmakedefine01 USE_LEVELDB #cmakedefine01 USE_LEVELDB
#cmakedefine01 USE_LUAJIT #cmakedefine01 USE_LUAJIT

@ -111,4 +111,3 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/ */
#define TTF_DEFAULT_FONT_SIZE (16) #define TTF_DEFAULT_FONT_SIZE (16)
#define DEFAULT_FONT_SIZE (10)

@ -303,8 +303,7 @@ void set_default_settings()
settings->setDefault("main_menu_path", ""); settings->setDefault("main_menu_path", "");
settings->setDefault("serverlist_file", "favoriteservers.json"); settings->setDefault("serverlist_file", "favoriteservers.json");
#if USE_FREETYPE // General font settings
settings->setDefault("freetype", "true");
settings->setDefault("font_path", porting::getDataPath("fonts" DIR_DELIM "Arimo-Regular.ttf")); settings->setDefault("font_path", porting::getDataPath("fonts" DIR_DELIM "Arimo-Regular.ttf"));
settings->setDefault("font_path_italic", porting::getDataPath("fonts" DIR_DELIM "Arimo-Italic.ttf")); settings->setDefault("font_path_italic", porting::getDataPath("fonts" DIR_DELIM "Arimo-Italic.ttf"));
settings->setDefault("font_path_bold", porting::getDataPath("fonts" DIR_DELIM "Arimo-Bold.ttf")); settings->setDefault("font_path_bold", porting::getDataPath("fonts" DIR_DELIM "Arimo-Bold.ttf"));
@ -322,14 +321,6 @@ void set_default_settings()
settings->setDefault("fallback_font_path", porting::getDataPath("fonts" DIR_DELIM "DroidSansFallbackFull.ttf")); settings->setDefault("fallback_font_path", porting::getDataPath("fonts" DIR_DELIM "DroidSansFallbackFull.ttf"));
std::string font_size_str = std::to_string(TTF_DEFAULT_FONT_SIZE); std::string font_size_str = std::to_string(TTF_DEFAULT_FONT_SIZE);
#else
settings->setDefault("freetype", "false");
settings->setDefault("font_path", porting::getDataPath("fonts" DIR_DELIM "mono_dejavu_sans"));
settings->setDefault("mono_font_path", porting::getDataPath("fonts" DIR_DELIM "mono_dejavu_sans"));
std::string font_size_str = std::to_string(DEFAULT_FONT_SIZE);
#endif
// General font settings
settings->setDefault("font_size", font_size_str); settings->setDefault("font_size", font_size_str);
settings->setDefault("mono_font_size", font_size_str); settings->setDefault("mono_font_size", font_size_str);
settings->setDefault("chat_font_size", "0"); // Default "font_size" settings->setDefault("chat_font_size", "0"); // Default "font_size"

@ -30,11 +30,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/fontengine.h" #include "client/fontengine.h"
#include "log.h" #include "log.h"
#include "gettext.h" #include "gettext.h"
#include <string>
#if USE_FREETYPE
#include "irrlicht_changes/CGUITTFont.h" #include "irrlicht_changes/CGUITTFont.h"
#endif #include <string>
inline u32 clamp_u8(s32 value) inline u32 clamp_u8(s32 value)
{ {
@ -328,19 +325,16 @@ void GUIChatConsole::drawText()
core::rect<s32> destrect( core::rect<s32> destrect(
x, y, x + m_fontsize.X * fragment.text.size(), y + m_fontsize.Y); x, y, x + m_fontsize.X * fragment.text.size(), y + m_fontsize.Y);
#if USE_FREETYPE
if (m_font->getType() == irr::gui::EGFT_CUSTOM) { if (m_font->getType() == irr::gui::EGFT_CUSTOM) {
// Draw colored text if FreeType is enabled // Draw colored text if possible
irr::gui::CGUITTFont *tmp = dynamic_cast<irr::gui::CGUITTFont *>(m_font); gui::CGUITTFont *tmp = static_cast<gui::CGUITTFont*>(m_font);
tmp->draw( tmp->draw(
fragment.text, fragment.text,
destrect, destrect,
false, false,
false, false,
&AbsoluteClippingRect); &AbsoluteClippingRect);
} else } else {
#endif
{
// Otherwise use standard text // Otherwise use standard text
m_font->draw( m_font->draw(
fragment.text.c_str(), fragment.text.c_str(),

@ -17,31 +17,26 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include "IGUIEnvironment.h" #include "guiHyperText.h"
#include "IGUIElement.h"
#include "guiScrollBar.h" #include "guiScrollBar.h"
#include "IGUIFont.h"
#include <vector>
#include <list>
#include <unordered_map>
using namespace irr::gui;
#include "client/fontengine.h" #include "client/fontengine.h"
#include <SColor.h>
#include "client/tile.h" #include "client/tile.h"
#include "IVideoDriver.h" #include "IVideoDriver.h"
#include "client/client.h" #include "client/client.h"
#include "client/renderingengine.h" #include "client/renderingengine.h"
#include "hud.h" #include "hud.h"
#include "guiHyperText.h"
#include "util/string.h" #include "util/string.h"
#include "irrlicht_changes/CGUITTFont.h"
bool check_color(const std::string &str) using namespace irr::gui;
static bool check_color(const std::string &str)
{ {
irr::video::SColor color; irr::video::SColor color;
return parseColorString(str, color, false); return parseColorString(str, color, false);
} }
bool check_integer(const std::string &str) static bool check_integer(const std::string &str)
{ {
if (str.empty()) if (str.empty())
return false; return false;
@ -616,12 +611,10 @@ TextDrawer::TextDrawer(const wchar_t *text, Client *client,
if (e.font) { if (e.font) {
e.dim.Width = e.font->getDimension(e.text.c_str()).Width; e.dim.Width = e.font->getDimension(e.text.c_str()).Width;
e.dim.Height = e.font->getDimension(L"Yy").Height; e.dim.Height = e.font->getDimension(L"Yy").Height;
#if USE_FREETYPE
if (e.font->getType() == irr::gui::EGFT_CUSTOM) { if (e.font->getType() == irr::gui::EGFT_CUSTOM) {
e.baseline = e.dim.Height - 1 - CGUITTFont *tmp = static_cast<CGUITTFont*>(e.font);
((irr::gui::CGUITTFont *)e.font)->getAscender() / 64; e.baseline = e.dim.Height - 1 - tmp->getAscender() / 64;
} }
#endif
} else { } else {
e.dim = {0, 0}; e.dim = {0, 0};
} }

@ -19,16 +19,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#pragma once #pragma once
#include "config.h" // for USE_FREETYPE #include <vector>
#include <list>
#include <unordered_map>
#include <string>
#include "irrlichttypes_extrabloated.h"
using namespace irr; using namespace irr;
class ISimpleTextureSource; class ISimpleTextureSource;
class Client; class Client;
class GUIScrollBar;
#if USE_FREETYPE
#include "irrlicht_changes/CGUITTFont.h"
#endif
class ParsedText class ParsedText
{ {

@ -1,13 +1,8 @@
if (BUILD_CLIENT) if (BUILD_CLIENT)
set(client_irrlicht_changes_SRCS set(client_irrlicht_changes_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/static_text.cpp ${CMAKE_CURRENT_SOURCE_DIR}/static_text.cpp
)
if (USE_FREETYPE)
set(client_irrlicht_changes_SRCS ${client_irrlicht_changes_SRCS}
${CMAKE_CURRENT_SOURCE_DIR}/CGUITTFont.cpp ${CMAKE_CURRENT_SOURCE_DIR}/CGUITTFont.cpp
) )
endif()
# CMake require us to set a local scope and then parent scope # CMake require us to set a local scope and then parent scope
# Else the last set win in parent scope # Else the last set win in parent scope

@ -12,17 +12,12 @@
#include <rect.h> #include <rect.h>
#include <SColor.h> #include <SColor.h>
#if USE_FREETYPE
#include "CGUITTFont.h" #include "CGUITTFont.h"
#endif
#include "util/string.h" #include "util/string.h"
namespace irr namespace irr
{ {
#if USE_FREETYPE
namespace gui namespace gui
{ {
//! constructor //! constructor
@ -108,14 +103,12 @@ void StaticText::draw()
font->getDimension(str.c_str()).Width; font->getDimension(str.c_str()).Width;
} }
#if USE_FREETYPE
if (font->getType() == irr::gui::EGFT_CUSTOM) { if (font->getType() == irr::gui::EGFT_CUSTOM) {
irr::gui::CGUITTFont *tmp = static_cast<irr::gui::CGUITTFont*>(font); CGUITTFont *tmp = static_cast<CGUITTFont*>(font);
tmp->draw(str, tmp->draw(str,
r, HAlign == EGUIA_CENTER, VAlign == EGUIA_CENTER, r, HAlign == EGUIA_CENTER, VAlign == EGUIA_CENTER,
(RestrainTextInside ? &AbsoluteClippingRect : NULL)); (RestrainTextInside ? &AbsoluteClippingRect : NULL));
} else } else
#endif
{ {
// Draw non-colored text // Draw non-colored text
font->draw(str.c_str(), font->draw(str.c_str(),
@ -590,8 +583,6 @@ s32 StaticText::getTextWidth() const
} // end namespace gui } // end namespace gui
#endif // USE_FREETYPE
} // end namespace irr } // end namespace irr

@ -20,7 +20,6 @@
#include "config.h" #include "config.h"
#include <IGUIEnvironment.h> #include <IGUIEnvironment.h>
#if USE_FREETYPE
namespace irr namespace irr
{ {
@ -230,41 +229,6 @@ inline void setStaticText(irr::gui::IGUIStaticText *static_text, const EnrichedS
} }
} }
#else // USE_FREETYPE
namespace irr
{
namespace gui
{
class StaticText
{
public:
static irr::gui::IGUIStaticText *add(
irr::gui::IGUIEnvironment *guienv,
const EnrichedString &text,
const core::rect< s32 > &rectangle,
bool border = false,
bool wordWrap = true,
irr::gui::IGUIElement *parent = NULL,
s32 id = -1,
bool fillBackground = false)
{
return guienv->addStaticText(text.c_str(), rectangle, border, wordWrap, parent, id, fillBackground);
}
};
} // end namespace gui
} // end namespace irr
inline void setStaticText(irr::gui::IGUIStaticText *static_text, const EnrichedString &text)
{
static_text->setText(text.c_str());
}
#endif
inline void setStaticText(irr::gui::IGUIStaticText *static_text, const wchar_t *text) inline void setStaticText(irr::gui::IGUIStaticText *static_text, const wchar_t *text)
{ {
setStaticText(static_text, EnrichedString(text, static_text->getOverrideColor())); setStaticText(static_text, EnrichedString(text, static_text->getOverrideColor()));

@ -37,7 +37,6 @@ const char *g_build_info =
#ifndef SERVER #ifndef SERVER
"USE_GETTEXT=" STR(USE_GETTEXT) "\n" "USE_GETTEXT=" STR(USE_GETTEXT) "\n"
"USE_SOUND=" STR(USE_SOUND) "\n" "USE_SOUND=" STR(USE_SOUND) "\n"
"USE_FREETYPE=" STR(USE_FREETYPE) "\n"
#endif #endif
"STATIC_SHAREDIR=" STR(STATIC_SHAREDIR) "STATIC_SHAREDIR=" STR(STATIC_SHAREDIR)
#if USE_GETTEXT && defined(STATIC_LOCALEDIR) #if USE_GETTEXT && defined(STATIC_LOCALEDIR)

@ -129,7 +129,6 @@ cmake -S $sourcedir -B . \
-DENABLE_SOUND=1 \ -DENABLE_SOUND=1 \
-DENABLE_CURL=1 \ -DENABLE_CURL=1 \
-DENABLE_GETTEXT=1 \ -DENABLE_GETTEXT=1 \
-DENABLE_FREETYPE=1 \
-DENABLE_LEVELDB=1 \ -DENABLE_LEVELDB=1 \
\ \
-DCMAKE_PREFIX_PATH=$libdir/irrlicht \ -DCMAKE_PREFIX_PATH=$libdir/irrlicht \

@ -129,7 +129,6 @@ cmake -S $sourcedir -B . \
-DENABLE_SOUND=1 \ -DENABLE_SOUND=1 \
-DENABLE_CURL=1 \ -DENABLE_CURL=1 \
-DENABLE_GETTEXT=1 \ -DENABLE_GETTEXT=1 \
-DENABLE_FREETYPE=1 \
-DENABLE_LEVELDB=1 \ -DENABLE_LEVELDB=1 \
\ \
-DCMAKE_PREFIX_PATH=$libdir/irrlicht \ -DCMAKE_PREFIX_PATH=$libdir/irrlicht \