mirror of https://github.com/OpenTTD/OpenTTD
Add: FontSearcher interface.
parent
b991a399ef
commit
895c0b254e
|
@ -230,6 +230,22 @@ void UninitFontCache()
|
|||
#endif /* WITH_FREETYPE */
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the FontSearcher instance. There can be only one font searcher, which depends on platform.
|
||||
*/
|
||||
FontSearcher::FontSearcher()
|
||||
{
|
||||
FontSearcher::instance = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deregister this FontSearcher.
|
||||
*/
|
||||
FontSearcher::~FontSearcher()
|
||||
{
|
||||
FontSearcher::instance = nullptr;
|
||||
}
|
||||
|
||||
#if !defined(_WIN32) && !defined(__APPLE__) && !defined(WITH_FONTCONFIG) && !defined(WITH_COCOA)
|
||||
|
||||
bool SetFallbackFont(FontCacheSettings *, const std::string &, int, MissingGlyphSearcher *) { return false; }
|
||||
|
|
|
@ -39,4 +39,45 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face);
|
|||
*/
|
||||
bool SetFallbackFont(struct FontCacheSettings *settings, const std::string &language_isocode, int winlangid, class MissingGlyphSearcher *callback);
|
||||
|
||||
struct FontFamily {
|
||||
std::string family;
|
||||
std::string style;
|
||||
int32_t slant;
|
||||
int32_t weight;
|
||||
|
||||
FontFamily(std::string_view family, std::string_view style, int32_t slant, int32_t weight) : family(family), style(style), slant(slant), weight(weight) {}
|
||||
};
|
||||
|
||||
class FontSearcher {
|
||||
public:
|
||||
FontSearcher();
|
||||
virtual ~FontSearcher();
|
||||
|
||||
/**
|
||||
* Get the active FontSearcher instance.
|
||||
* @return FontSearcher instance, or nullptr if not present.
|
||||
*/
|
||||
static inline FontSearcher *GetFontSearcher() { return FontSearcher::instance; }
|
||||
|
||||
/**
|
||||
* List available fonts.
|
||||
* @param language_isocode the language, e.g. en_GB.
|
||||
* @param winlangid the language ID windows style.
|
||||
* @return vector containing font family names.
|
||||
*/
|
||||
virtual std::vector<std::string> ListFamilies(const std::string &language_isocode, int winlangid) = 0;
|
||||
|
||||
/**
|
||||
* List available styles for a font family.
|
||||
* @param language_isocode the language, e.g. en_GB.
|
||||
* @param winlangid the language ID windows style.
|
||||
* @param font_family The font family to list.
|
||||
* @return vector containing style information for the family.
|
||||
*/
|
||||
virtual std::vector<FontFamily> ListStyles(const std::string &language_isocode, int winlangid, std::string_view font_family) = 0;
|
||||
|
||||
private:
|
||||
static inline FontSearcher *instance = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue