New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up and fix freetype=false crashes #8641
Conversation
return; | ||
|
||
if ((mode == FM_Simple) || (mode == FM_SimpleMono)) { | ||
initSimpleFont(basesize, mode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to getFont
for a saner call structure.
|
||
std::string font_path = g_settings->get(font_config_prefix + "font_path"); | ||
std::string fallback_settings[] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same functionality, just shorter code.
std::stringstream fontsize_plus_xml; | ||
fontsize_plus_xml << basename << "_" << (size + offset) << ".xml"; | ||
// Find nearest matching font scale | ||
// Does a "zig-zag motion" (positibe/negative), from 0 to MAX_FONT_SIZE_OFFSET |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also same functionality here. Positive offset it checked first, then goes from 0 to -MAX_FONT_SIZE_OFFSET and +MAX_FONT_SIZE_OFFSET
@@ -112,15 +112,6 @@ class FontEngine | |||
/** current font engine mode */ | |||
FontMode m_currentMode = FM_Standard; | |||
|
|||
/** font mode of last request */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced by replacing several m_font_cache[mode]
lookups in getFont()
. Roughly the same performance, I guess.
A IGUIFont of type bitmap/vector cannot be converted to CGUITTFont Fixes various segfaults in gameplay Shorter font cache code, cleaned up (?)
c5d300d
to
a06fa6c
Compare
Forgive my incompetence. Any usage scenario? MT is built with freetype support, but the user turns off freetype. What for? This should not work in principle. |
@MoNTE48 Using bitmaps to render text gives you a few FPS more on old (real old) hardware. This PR is just one of the performance tweaks I wrote to make the game playable even on my worst rig. PS: One other part was to disable the stars in the sky, it took more than 10ms to draw. |
Comparison: Freetype enabled on the right side. StatisticsThe time spent for drawing is roughly proportional to the amount of characters drawn on screen.
|
Wow, I didn’t know that Freetype reduced performance so much. Try this font, please. Just wondering |
Relative gains from using bitmaps is minimal with small font. By the way, why does MT use DroidSansFallbackFull.ttf? There is DroidSansFallback.ttf, which is less than 1 MB, but has no differences, as far as I could find in Google. |
@MoNTE48 I updated the older post with some comparisons I made. What matters is not the file size, but the amount of characters drawn on screen. |
@SmallJoker I understand, thank you. |
@@ -211,20 +176,17 @@ unsigned int FontEngine::getDefaultFontSize() | |||
/******************************************************************************/ | |||
void FontEngine::readSettings() | |||
{ | |||
#if USE_FREETYPE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SmallJoker, by removing this #ifdef
you broke possibility to build minetest without freetype and gettext:
Right now I'm trying to build the very minimal configuration and I've set ENABLE_FREETYPE=OFF
and ENABLE_GETTEXT=OFF
and I see the following error:
minetest\src\client\fontengine.cpp(184): error C3861: 'gettext': identifier not found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explain further. This preprocessor checks against USE_FREETYPE
, not USE_GETTEXT
.
There's a dummy function available for gettext()
if gettext is not available:
Line 38 in 008b80f
#define gettext(String) String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot, this fixes the build!
A IGUIFont of type bitmap/vector cannot be converted to CGUITTFont
Fixes various segfaults in gameplay
Shorter font cache code, cleaned up (?)
This was broken since colored text became a thing. Tracking down this bug took a horrible long time, but now it finally works.
Test 1: USE_FREETYPE=1,
freetype = true
Compiled-in TTF support. Same functionality as in master.
font_path
and/ormono_font_path
to invalid pathsTest 2 Bitmap: USE_FREETYPE=1,
freetype = false
TTF support, but using images. Works in PR, does not in master.
font_path
andmono_font_path
Test 3 Vectors: USE_FREETYPE=1,
freetype = false
TTF support, but using xml files. Works in PR, does not in master.
font_path = fonts/mono_dejavu_sans.xml
mono_font_path = fonts/mono_dejavu_sans.xml
USE_FREETYPE=0
Requires many guiFormSpecMenu changes, thus it should be fixed in a later PR. There's yet no client option without freetype built-in.