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

Method AddNewEntry

Source/Engine/Render2D/FontManager.cpp:116–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114}
115
116bool FontManager::AddNewEntry(Font* font, Char c, FontCharacterEntry& entry)
117{
118 ScopeLock lock(Locker);
119
120 const FontAsset* asset = font->GetAsset();
121 const FontOptions& options = asset->GetOptions();
122 const FT_Face face = asset->GetFTFace();
123 ASSERT(face != nullptr);
124 font->FlushFaceSize();
125
126 // Set load flags
127 uint32 glyphFlags = FT_LOAD_NO_BITMAP;
128 const bool useAA = EnumHasAnyFlags(options.Flags, FontFlags::AntiAliasing);
129 if (options.RasterMode == FontRasterMode::MSDF)
130 {
131 glyphFlags |= FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING;
132 }
133 else if (useAA)
134 {
135 switch (options.Hinting)
136 {
137 case FontHinting::Auto:
138 glyphFlags |= FT_LOAD_FORCE_AUTOHINT;
139 break;
140 case FontHinting::AutoLight:
141 glyphFlags |= FT_LOAD_TARGET_LIGHT;
142 break;
143 case FontHinting::Monochrome:
144 glyphFlags |= FT_LOAD_TARGET_MONO;
145 break;
146 case FontHinting::None:
147 glyphFlags |= FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING;
148 break;
149 case FontHinting::Default:
150 default:
151 glyphFlags |= FT_LOAD_TARGET_NORMAL;
152 break;
153 }
154 }
155 else
156 {
157 glyphFlags |= FT_LOAD_TARGET_MONO | FT_LOAD_FORCE_AUTOHINT;
158 }
159
160 // Get the index to the glyph in the font face
161 const FT_UInt glyphIndex = FT_Get_Char_Index(face, c);
162#if !BUILD_RELEASE
163 if (glyphIndex == 0 && c >= '!')
164 {
165 LOG(Warning, "Font `{}` doesn't contain character `\\u{:x}`, consider choosing another font.", String(face->family_name), c);
166 }
167#endif
168
169 // Init the character data
170 Platform::MemoryClear(&entry, sizeof(entry));
171 entry.Character = c;
172 entry.Font = font;
173 entry.IsValid = false;

Callers

nothing calls this directly

Calls 15

EnumHasAnyFlagsFunction · 0.85
MemoryClearFunction · 0.85
GetAssetMethod · 0.80
FlushFaceSizeMethod · 0.80
StringClass · 0.50
GetOptionsMethod · 0.45
ClearMethod · 0.45
ResizeMethod · 0.45
IsEmptyMethod · 0.45
CountMethod · 0.45
GetFormatMethod · 0.45
AddEntryMethod · 0.45

Tested by

no test coverage detected