How exactly does this "fallback font" thing work??

Post Reply
User avatar
ExeterDad
Member
Posts: 1717
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad
Location: New Hampshire U.S.A

How exactly does this "fallback font" thing work??

by ExeterDad » Post

Minetest allows three font paths set.
font_path: defaults to Arimo-Regular.ttf
mono_font_path: defaults to Cousine-Regular.ttf
fallback_font_path: defaults to DroidSansFallbackFull.ttf

Arimo-Regula handles enough languages for the most part, but lacks Asian fonts so changing your main font_path to DroidSansFallbackFull.ttf is needed to see any kind of Asian output in chat. If not, it appears the players are spamming the chat with empty chat messages.

But how come those Asian fonts aren't visible as they are included with the fallback_font_path??
Isn't that the purpose of a fallback font? To have a fallback font to show if the needed glyph isn't included with your main font?
A fallback font is a reserve typeface containing symbols for as many Unicode characters as possible. When a display system encounters a character that is not part of the repertoire of any of the other available fonts, a symbol from a fallback font is used instead.
https://en.wikipedia.org/wiki/Fallback_font
Minetest as it is now, isn't capable of using the players likely massive collection of system fonts. So we need to manually include a main font in hopes it covers all of the languages we may encounter on a server. But we can't have a "Super Font" that covers them all as True Type Fonts are limited to 65,535 glyphs within them. But in theory, if we have our main font covering the languages we do now, and the fallback font covering a good chunk of the rest, the two fonts would do a pretty good job for all users.
To test this. I've tried outputting strings containing Unicode "wing ding-like" characters in chat and in formspec via lua. I've found I can not get fonts that are confirmed to be in DroidSansFallbackFull.ttf unless I add the path to the font file in my main font_path.
Is the fallback_font_path broken? Or am I confused about how this is used? Does the UI only honor it?
I see in the source that is should be used: fontengine.cpp

Code: Select all

		if (is_yes(gettext("needs_fallback_font"))) {
			m_currentMode = FM_Fallback;
		}
		else {
			m_currentMode = FM_Standard;
		}
so it shows gettext is using it somehow. And it's asking if "needs_fallback_font" is in the translation files (.po)
In fontengine.cpp I also see a comment that only the default font is initialized others are initialized on demand.

Code: Select all

void FontEngine::updateFontCache()
{
	/* the only font to be initialized is default one,
	 * all others are re-initialized on demand */
	initFont(m_default_size[m_currentMode], m_currentMode);

	/* reset font quick access */
	m_lastMode = FM_Unspecified;
	m_lastSize = 0;
	m_lastFont = NULL;
}
What can we do to trigger this "demand" if it isn't taken care of by default? I don't need a translation. I just need access to a charactor within a font that I know most players have bundled with Minetest.
Please help if you can. I've many hours mapping these darn characters for a mod I've been working on... and it's just broken. Unless I can convince everyone to use the fallback font as the main font when they play. Likely that would never happen lol

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests