MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / GetCharacter

Method GetCharacter

Source/Engine/Render2D/Font.cpp:37–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37void Font::GetCharacter(Char c, FontCharacterEntry& result, bool enableFallback)
38{
39 // Try to get the character or cache it if cannot be found
40 if (!_characters.TryGet(c, result))
41 {
42 // This thread race condition may happen in editor but in game we usually do all stuff with fonts on main thread (chars caching)
43 ScopeLock lock(_asset->Locker);
44
45 // Handle situation when more than one thread wants to get the same character
46 if (_characters.TryGet(c, result))
47 return;
48
49 // Try to use fallback font if character is missing
50 if (enableFallback && !_asset->ContainsChar(c))
51 {
52 for (int32 fallbackIndex = 0; fallbackIndex < FallbackFonts.Count(); fallbackIndex++)
53 {
54 FontAsset* fallbackFont = FallbackFonts.Get()[fallbackIndex].Get();
55 if (fallbackFont && _asset->GetOptions().RasterMode == FontRasterMode::MSDF)
56 {
57 fallbackFont = fallbackFont->GetMSDF();
58 }
59 if (fallbackFont && fallbackFont->ContainsChar(c))
60 {
61 fallbackFont->CreateFont(GetSize())->GetCharacter(c, result, enableFallback);
62 return;
63 }
64 }
65 }
66
67 // Create character cache
68 FontManager::AddNewEntry(this, c, result);
69 ASSERT(result.Font);
70
71 // Add to the dictionary
72 _characters.Add(c, result);
73 }
74}
75
76int32 Font::GetKerning(Char first, Char second) const
77{

Callers 2

DrawTextMethod · 0.80
UpdateLayoutMethod · 0.80

Calls 9

ContainsCharMethod · 0.80
GetMSDFMethod · 0.80
CreateFontMethod · 0.80
GetSizeFunction · 0.70
TryGetMethod · 0.45
CountMethod · 0.45
GetMethod · 0.45
GetOptionsMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected