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

Method GetKerning

Source/Engine/Render2D/Font.cpp:76–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76int32 Font::GetKerning(Char first, Char second) const
77{
78 int32 kerning = 0;
79 const uint32 key = (uint32)first << 16 | second;
80 if (_hasKerning && !_kerningTable.TryGet(key, kerning))
81 {
82 // This thread race condition may happen in editor but in game we usually do all stuff with fonts on main thread (chars caching)
83 ScopeLock lock(_asset->Locker);
84
85 // Handle situation when more than one thread wants to get the same character
86 if (!_kerningTable.TryGet(key, kerning))
87 {
88 const FT_Face face = _asset->GetFTFace();
89 ASSERT(face);
90
91 FlushFaceSize();
92
93 FT_Vector vec;
94 const FT_UInt firstIndex = FT_Get_Char_Index(face, first);
95 const FT_UInt secondIndex = FT_Get_Char_Index(face, second);
96 FT_Get_Kerning(face, firstIndex, secondIndex, FT_KERNING_DEFAULT, &vec);
97 kerning = vec.x >> 6;
98
99 _kerningTable.Add(key, kerning);
100 }
101 }
102
103 return kerning;
104}
105
106void Font::CacheText(const StringView& text)
107{

Callers 5

DrawTextMethod · 0.80
ProcessTextMethod · 0.80
HitTestTextMethod · 0.80
GetCharPositionMethod · 0.80
UpdateLayoutMethod · 0.80

Calls 2

TryGetMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected