@@ -207,15 +207,13 @@ FT2Font::get_path(std::vector<double> &vertices, std::vector<unsigned char> &cod
207
207
}
208
208
209
209
FT2Font::FT2Font (long hinting_factor_, std::vector<FT2Font *> &fallback_list,
210
- FT2Font::WarnFunc warn, bool warn_if_used)
211
- : ft_glyph_warn(warn), warn_if_used(warn_if_used), image({1 , 1 }), face(nullptr ),
210
+ bool warn_if_used)
211
+ : warn_if_used(warn_if_used), image({1 , 1 }), face(nullptr ), fallbacks(fallback_list ),
212
212
hinting_factor(hinting_factor_),
213
213
// set default kerning factor to 0, i.e., no kerning manipulation
214
214
kerning_factor(0 )
215
215
{
216
216
clear ();
217
- // Set fallbacks
218
- std::copy (fallback_list.begin (), fallback_list.end (), std::back_inserter (fallbacks));
219
217
}
220
218
221
219
FT2Font::~FT2Font ()
@@ -234,7 +232,8 @@ void FT2Font::open(FT_Open_Args &open_args)
234
232
void FT2Font::close ()
235
233
{
236
234
// This should be idempotent, in case a user manually calls close before the
237
- // destructor does.
235
+ // destructor does. Note for example, that PyFT2Font _does_ call this before the
236
+ // base destructor to ensure internal pointers are cleared early enough.
238
237
239
238
for (auto & glyph : glyphs) {
240
239
FT_Done_Glyph (glyph);
@@ -544,21 +543,19 @@ FT_UInt FT2Font::get_char_index(FT_ULong charcode, bool fallback = false)
544
543
return FT_Get_Char_Index (ft_object->get_face (), charcode);
545
544
}
546
545
547
- void FT2Font::get_width_height ( long *width , long *height )
546
+ std::tuple< long , long > FT2Font::get_width_height ( )
548
547
{
549
- *width = advance;
550
- *height = bbox.yMax - bbox.yMin ;
548
+ return {advance, bbox.yMax - bbox.yMin };
551
549
}
552
550
553
551
long FT2Font::get_descent ()
554
552
{
555
553
return -bbox.yMin ;
556
554
}
557
555
558
- void FT2Font::get_bitmap_offset ( long *x , long *y )
556
+ std::tuple< long , long > FT2Font::get_bitmap_offset ( )
559
557
{
560
- *x = bbox.xMin ;
561
- *y = 0 ;
558
+ return {bbox.xMin , 0 };
562
559
}
563
560
564
561
void FT2Font::draw_glyphs_to_bitmap (bool antialiased)
@@ -607,8 +604,11 @@ void FT2Font::draw_glyph_to_bitmap(
607
604
draw_bitmap (im, &bitmap->bitmap , x + bitmap->left , y);
608
605
}
609
606
610
- void FT2Font::get_glyph_name (unsigned int glyph_number, std::string &buffer )
607
+ std::string FT2Font::get_glyph_name (unsigned int glyph_number)
611
608
{
609
+ std::string buffer;
610
+ buffer.resize (128 );
611
+
612
612
if (!FT_HAS_GLYPH_NAMES (face)) {
613
613
/* Note that this generated name must match the name that
614
614
is generated by ttconv in ttfont_CharStrings_getname. */
@@ -625,6 +625,8 @@ void FT2Font::get_glyph_name(unsigned int glyph_number, std::string &buffer)
625
625
buffer.resize (len);
626
626
}
627
627
}
628
+
629
+ return buffer;
628
630
}
629
631
630
632
long FT2Font::get_name_index (char *name)
0 commit comments