@@ -253,7 +253,6 @@ void FT2Font::clear()
253253 }
254254
255255 glyphs.clear ();
256- glyph_to_font.clear ();
257256 char_to_font.clear ();
258257
259258 for (auto & fallback : fallbacks) {
@@ -287,35 +286,13 @@ void FT2Font::select_charmap(unsigned long i)
287286 FT_CHECK (FT_Select_Charmap, face, (FT_Encoding)i);
288287}
289288
290- int FT2Font::get_kerning (FT_UInt left, FT_UInt right, FT_Kerning_Mode mode,
291- bool fallback = false )
292- {
293- if (fallback && glyph_to_font.find (left) != glyph_to_font.end () &&
294- glyph_to_font.find (right) != glyph_to_font.end ()) {
295- FT2Font *left_ft_object = glyph_to_font[left];
296- FT2Font *right_ft_object = glyph_to_font[right];
297- if (left_ft_object != right_ft_object) {
298- // we do not know how to do kerning between different fonts
299- return 0 ;
300- }
301- // if left_ft_object is the same as right_ft_object,
302- // do the exact same thing which set_text does.
303- return right_ft_object->get_kerning (left, right, mode, false );
304- }
305- else
306- {
307- FT_Vector delta;
308- return get_kerning (left, right, mode, delta);
309- }
310- }
311-
312- int FT2Font::get_kerning (FT_UInt left, FT_UInt right, FT_Kerning_Mode mode,
313- FT_Vector &delta)
289+ int FT2Font::get_kerning (FT_UInt left, FT_UInt right, FT_Kerning_Mode mode)
314290{
315291 if (!FT_HAS_KERNING (face)) {
316292 return 0 ;
317293 }
318294
295+ FT_Vector delta;
319296 if (!FT_Get_Kerning (face, left, right, mode, &delta)) {
320297 return (int )(delta.x ) / (hinting_factor << kerning_factor);
321298 } else {
@@ -364,16 +341,15 @@ void FT2Font::set_text(
364341 std::set<FT_String*> glyph_seen_fonts;
365342 FT2Font *ft_object_with_glyph = this ;
366343 bool was_found = load_char_with_fallback (ft_object_with_glyph, glyph_index, glyphs,
367- char_to_font, glyph_to_font, codepoint, flags,
344+ char_to_font, codepoint, flags,
368345 charcode_error, glyph_error, glyph_seen_fonts, false );
369346 if (!was_found) {
370347 ft_glyph_warn ((FT_ULong)codepoint, glyph_seen_fonts);
371348 // render missing glyph tofu
372349 // come back to top-most font
373350 ft_object_with_glyph = this ;
374351 char_to_font[codepoint] = ft_object_with_glyph;
375- glyph_to_font[glyph_index] = ft_object_with_glyph;
376- ft_object_with_glyph->load_glyph (glyph_index, flags, ft_object_with_glyph, false );
352+ ft_object_with_glyph->load_glyph (glyph_index, flags);
377353 } else if (ft_object_with_glyph->warn_if_used ) {
378354 ft_glyph_warn ((FT_ULong)codepoint, glyph_seen_fonts);
379355 }
@@ -383,8 +359,7 @@ void FT2Font::set_text(
383359 ft_object_with_glyph->has_kerning () && // if the font knows how to kern
384360 previous && glyph_index // and we really have 2 glyphs
385361 ) {
386- FT_Vector delta;
387- pen.x += ft_object_with_glyph->get_kerning (previous, glyph_index, FT_KERNING_DEFAULT, delta);
362+ pen.x += ft_object_with_glyph->get_kerning (previous, glyph_index, FT_KERNING_DEFAULT);
388363 }
389364
390365 // extract glyph image and store it in our table
@@ -434,7 +409,7 @@ void FT2Font::load_char(long charcode, FT_Int32 flags, FT2Font *&ft_object, bool
434409 FT_Error charcode_error, glyph_error;
435410 FT2Font *ft_object_with_glyph = this ;
436411 bool was_found = load_char_with_fallback (ft_object_with_glyph, final_glyph_index,
437- glyphs, char_to_font, glyph_to_font,
412+ glyphs, char_to_font,
438413 charcode, flags, charcode_error, glyph_error,
439414 glyph_seen_fonts, true );
440415 if (!was_found) {
@@ -493,7 +468,6 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
493468 FT_UInt &final_glyph_index,
494469 std::vector<FT_Glyph> &parent_glyphs,
495470 std::unordered_map<long , FT2Font *> &parent_char_to_font,
496- std::unordered_map<FT_UInt, FT2Font *> &parent_glyph_to_font,
497471 long charcode,
498472 FT_Int32 flags,
499473 FT_Error &charcode_error,
@@ -523,7 +497,6 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
523497 // need to store this for anytime a character is loaded from a parent
524498 // FT2Font object or to generate a mapping of individual characters to fonts
525499 ft_object_with_glyph = this ;
526- parent_glyph_to_font[final_glyph_index] = this ;
527500 parent_char_to_font[charcode] = this ;
528501 parent_glyphs.push_back (thisGlyph);
529502 return true ;
@@ -532,7 +505,7 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
532505 for (auto & fallback : fallbacks) {
533506 bool was_found = fallback->load_char_with_fallback (
534507 ft_object_with_glyph, final_glyph_index, parent_glyphs,
535- parent_char_to_font, parent_glyph_to_font, charcode, flags,
508+ parent_char_to_font, charcode, flags,
536509 charcode_error, glyph_error, glyph_seen_fonts, override );
537510 if (was_found) {
538511 return true ;
@@ -542,21 +515,6 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
542515 }
543516}
544517
545- void FT2Font::load_glyph (FT_UInt glyph_index,
546- FT_Int32 flags,
547- FT2Font *&ft_object,
548- bool fallback = false )
549- {
550- // cache is only for parent FT2Font
551- if (fallback && glyph_to_font.find (glyph_index) != glyph_to_font.end ()) {
552- ft_object = glyph_to_font[glyph_index];
553- } else {
554- ft_object = this ;
555- }
556-
557- ft_object->load_glyph (glyph_index, flags);
558- }
559-
560518void FT2Font::load_glyph (FT_UInt glyph_index, FT_Int32 flags)
561519{
562520 FT_CHECK (FT_Load_Glyph, face, glyph_index, flags);
@@ -644,15 +602,8 @@ void FT2Font::draw_glyph_to_bitmap(
644602 draw_bitmap (im, &bitmap->bitmap , x + bitmap->left , y);
645603}
646604
647- void FT2Font::get_glyph_name (unsigned int glyph_number, std::string &buffer,
648- bool fallback = false )
605+ void FT2Font::get_glyph_name (unsigned int glyph_number, std::string &buffer)
649606{
650- if (fallback && glyph_to_font.find (glyph_number) != glyph_to_font.end ()) {
651- // cache is only for parent FT2Font
652- FT2Font *ft_object = glyph_to_font[glyph_number];
653- ft_object->get_glyph_name (glyph_number, buffer, false );
654- return ;
655- }
656607 if (!FT_HAS_GLYPH_NAMES (face)) {
657608 /* Note that this generated name must match the name that
658609 is generated by ttconv in ttfont_CharStrings_getname. */
0 commit comments