Change: Support side-by-side fallback FontCaches instead of hierarchical. (#13303)
The text layouter system can now support using different fonts for different glyphs, including mixing scalable and sprite glyphs.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#ifndef STRINGS_FUNC_H
|
||||
#define STRINGS_FUNC_H
|
||||
|
||||
#include "fontcache.h"
|
||||
#include "strings_type.h"
|
||||
#include "string_type.h"
|
||||
#include "gfx_type.h"
|
||||
@@ -158,9 +159,33 @@ EncodedString GetEncodedString(StringID string, const Args&... args)
|
||||
*/
|
||||
class MissingGlyphSearcher {
|
||||
public:
|
||||
FontSizes fontsizes; ///< Font sizes to search for.
|
||||
|
||||
MissingGlyphSearcher(FontSizes fontsizes) : fontsizes(fontsizes) {}
|
||||
|
||||
/** Make sure everything gets destructed right. */
|
||||
virtual ~MissingGlyphSearcher() = default;
|
||||
|
||||
/**
|
||||
* Test if any glyphs are missing.
|
||||
* @return Font sizes which have missing glyphs.
|
||||
*/
|
||||
FontSizes FindMissingGlyphs();
|
||||
|
||||
virtual FontLoadReason GetLoadReason() = 0;
|
||||
|
||||
/**
|
||||
* Get set of glyphs required for the current language.
|
||||
* @param fontsizes Font sizes to test.
|
||||
* @return Set of required glyphs.
|
||||
**/
|
||||
virtual std::set<char32_t> GetRequiredGlyphs(FontSizes fontsizes) = 0;
|
||||
};
|
||||
|
||||
class BaseStringMissingGlyphSearcher : public MissingGlyphSearcher {
|
||||
public:
|
||||
BaseStringMissingGlyphSearcher(FontSizes fontsizes) : MissingGlyphSearcher(fontsizes) {}
|
||||
|
||||
/**
|
||||
* Get the next string to search through.
|
||||
* @return The next string or nullopt if there is none.
|
||||
@@ -178,23 +203,11 @@ public:
|
||||
*/
|
||||
virtual void Reset() = 0;
|
||||
|
||||
/**
|
||||
* Whether to search for a monospace font or not.
|
||||
* @return True if searching for monospace.
|
||||
*/
|
||||
virtual bool Monospace() = 0;
|
||||
FontLoadReason GetLoadReason() override { return FontLoadReason::LanguageFallback; }
|
||||
|
||||
/**
|
||||
* Set the right font names.
|
||||
* @param settings The settings to modify.
|
||||
* @param font_name The new font name.
|
||||
* @param os_data Opaque pointer to OS-specific data.
|
||||
*/
|
||||
virtual void SetFontNames(struct FontCacheSettings *settings, std::string_view font_name, const void *os_data = nullptr) = 0;
|
||||
|
||||
bool FindMissingGlyphs();
|
||||
std::set<char32_t> GetRequiredGlyphs(FontSizes fontsizes) override;
|
||||
};
|
||||
|
||||
void CheckForMissingGlyphs(MissingGlyphSearcher *search = nullptr);
|
||||
void CheckForMissingGlyphs(MissingGlyphSearcher *searcher = nullptr);
|
||||
|
||||
#endif /* STRINGS_FUNC_H */
|
||||
|
||||
Reference in New Issue
Block a user