@@ -98,8 +98,8 @@ namespace
98
98
bool InitFont (FT_Library ft_library, const ImFontConfig& cfg, unsigned int extra_user_flags); // Initialize from an external data buffer. Doesn't copy data, and you must ensure it stays valid up to this object lifetime.
99
99
void CloseFont ();
100
100
void SetPixelHeight (int pixel_height); // Change font pixel size. All following calls to RasterizeGlyph() will use this size
101
- const FT_Glyph_Metrics* LoadGlyph (uint32_t in_codepoint, uint32_t * out_glyph_index );
102
- const FT_Bitmap* RenderGlyphAndGetInfo (uint32_t in_glyph_index, GlyphInfo* out_glyph_info);
101
+ const FT_Glyph_Metrics* LoadGlyph (uint32_t in_codepoint);
102
+ const FT_Bitmap* RenderGlyphAndGetInfo (GlyphInfo* out_glyph_info);
103
103
void BlitGlyph (const FT_Bitmap* ft_bitmap, uint8_t * dst, uint32_t dst_pitch, unsigned char * multiply_table = NULL );
104
104
~FreeTypeFont () { CloseFont (); }
105
105
@@ -177,21 +177,15 @@ namespace
177
177
Info.MaxAdvanceWidth = (float )FT_CEIL (metrics.max_advance );
178
178
}
179
179
180
- const FT_Glyph_Metrics* FreeTypeFont::LoadGlyph (uint32_t codepoint, uint32_t * out_glyph_index )
180
+ const FT_Glyph_Metrics* FreeTypeFont::LoadGlyph (uint32_t codepoint)
181
181
{
182
- if (out_glyph_index)
183
- *out_glyph_index = 0 ;
184
-
185
182
uint32_t glyph_index = FT_Get_Char_Index (Face, codepoint);
186
183
if (glyph_index == 0 )
187
184
return NULL ;
188
185
FT_Error error = FT_Load_Glyph (Face, glyph_index, LoadFlags);
189
186
if (error)
190
187
return NULL ;
191
188
192
- if (out_glyph_index)
193
- *out_glyph_index = glyph_index;
194
-
195
189
// Need an outline for this to work
196
190
FT_GlyphSlot slot = Face->glyph ;
197
191
IM_ASSERT (slot->format == FT_GLYPH_FORMAT_OUTLINE);
@@ -211,25 +205,12 @@ namespace
211
205
return &slot->metrics ;
212
206
}
213
207
214
- const FT_Bitmap* FreeTypeFont::RenderGlyphAndGetInfo (uint32_t in_glyph_index, GlyphInfo* out_glyph_info)
208
+ const FT_Bitmap* FreeTypeFont::RenderGlyphAndGetInfo (GlyphInfo* out_glyph_info)
215
209
{
216
- IM_ASSERT (in_glyph_index != 0 );
217
- FT_Error error = FT_Load_Glyph (Face, in_glyph_index, LoadFlags);
218
- if (error)
219
- return NULL ;
220
-
221
- // Need an outline for this to work
222
210
FT_GlyphSlot slot = Face->glyph ;
223
- IM_ASSERT (slot->format == FT_GLYPH_FORMAT_OUTLINE);
224
-
225
- if (UserFlags & ImGuiFreeType::Bold)
226
- FT_GlyphSlot_Embolden (slot);
227
- if (UserFlags & ImGuiFreeType::Oblique)
228
- FT_GlyphSlot_Oblique (slot);
229
-
230
- error = FT_Render_Glyph (slot, FT_RENDER_MODE_NORMAL);
211
+ FT_Error error = FT_Render_Glyph (slot, FT_RENDER_MODE_NORMAL);
231
212
if (error != 0 )
232
- return false ;
213
+ return NULL ;
233
214
234
215
FT_Bitmap* ft_bitmap = &Face->glyph ->bitmap ;
235
216
out_glyph_info->Width = (int )ft_bitmap->width ;
@@ -272,7 +253,6 @@ struct ImFontBuildSrcGlyphFT
272
253
{
273
254
GlyphInfo Info;
274
255
uint32_t Codepoint;
275
- uint32_t GlyphIndex; // Index in font (to avoid calling FT_Get_Char_Index multiple times)
276
256
unsigned char * BitmapData; // Point within one of the dst_tmp_bitmap_buffers[] array
277
257
};
278
258
@@ -446,13 +426,13 @@ bool ImFontAtlasBuildWithFreeType(FT_Library ft_library, ImFontAtlas* atlas, uns
446
426
{
447
427
ImFontBuildSrcGlyphFT& src_glyph = src_tmp.GlyphsList [glyph_i];
448
428
449
- const FT_Glyph_Metrics* metrics = src_tmp.Font .LoadGlyph (src_glyph.Codepoint , &src_glyph. GlyphIndex );
429
+ const FT_Glyph_Metrics* metrics = src_tmp.Font .LoadGlyph (src_glyph.Codepoint );
450
430
IM_ASSERT (metrics != NULL );
451
431
if (metrics == NULL )
452
432
continue ;
453
433
454
434
// Render glyph into a bitmap (currently held by FreeType)
455
- const FT_Bitmap* ft_bitmap = src_tmp.Font .RenderGlyphAndGetInfo (src_glyph. GlyphIndex , &src_glyph.Info );
435
+ const FT_Bitmap* ft_bitmap = src_tmp.Font .RenderGlyphAndGetInfo (&src_glyph.Info );
456
436
IM_ASSERT (ft_bitmap);
457
437
458
438
// Allocate new temporary chunk if needed
0 commit comments