MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / FindMissingGlyphs

Method FindMissingGlyphs

src/strings.cpp:2306–2326  ·  view source on GitHub ↗

* Check whether there are glyphs missing in the current language. * @return If glyphs are missing, return \c true, else return \c false. */

Source from the content-addressed store, hash-verified

2304 * @return If glyphs are missing, return \c true, else return \c false.
2305 */
2306bool MissingGlyphSearcher::FindMissingGlyphs()
2307{
2308 FontCache::LoadFontCaches(this->Monospace() ? FontSizes{FS_MONO} : FONTSIZES_REQUIRED);
2309
2310 this->Reset();
2311 for (auto text = this->NextString(); text.has_value(); text = this->NextString()) {
2312 FontSize size = this->DefaultSize();
2313 FontCache *fc = FontCache::Get(size);
2314 for (char32_t c : Utf8View(*text)) {
2315 if (c >= SCC_FIRST_FONT && c <= SCC_LAST_FONT) {
2316 size = (FontSize)(c - SCC_FIRST_FONT);
2317 fc = FontCache::Get(size);
2318 } else if (!IsInsideMM(c, SCC_SPRITE_START, SCC_SPRITE_END) && IsPrintable(c) && !IsTextDirectionChar(c) && fc->MapCharToGlyph(c, false) == 0) {
2319 /* The character is printable, but not in the normal font. This is the case we were testing for. */
2320 Debug(fontcache, 0, "Font is missing glyphs to display char 0x{:X} in {} font size", static_cast<uint32_t>(c), FontSizeToName(size));
2321 return true;
2322 }
2323 }
2324 }
2325 return false;
2326}
2327
2328/** Helper for searching through the language pack. */
2329class LanguagePackGlyphSearcher : public MissingGlyphSearcher {

Callers 4

CheckForMissingGlyphsFunction · 0.80
EnumFontCallbackFunction · 0.80
FindFallbackFontMethod · 0.80

Calls 10

Utf8ViewClass · 0.85
IsInsideMMFunction · 0.85
IsPrintableFunction · 0.85
IsTextDirectionCharFunction · 0.85
FontSizeToNameFunction · 0.85
MonospaceMethod · 0.45
ResetMethod · 0.45
NextStringMethod · 0.45
DefaultSizeMethod · 0.45
MapCharToGlyphMethod · 0.45

Tested by

no test coverage detected