@@ -253,7 +253,6 @@ void FT2Font::clear()
253
253
}
254
254
255
255
glyphs.clear ();
256
- glyph_to_font.clear ();
257
256
char_to_font.clear ();
258
257
259
258
for (auto & fallback : fallbacks) {
@@ -287,35 +286,13 @@ void FT2Font::select_charmap(unsigned long i)
287
286
FT_CHECK (FT_Select_Charmap, face, (FT_Encoding)i);
288
287
}
289
288
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)
314
290
{
315
291
if (!FT_HAS_KERNING (face)) {
316
292
return 0 ;
317
293
}
318
294
295
+ FT_Vector delta;
319
296
if (!FT_Get_Kerning (face, left, right, mode, &delta)) {
320
297
return (int )(delta.x ) / (hinting_factor << kerning_factor);
321
298
} else {
@@ -364,16 +341,15 @@ void FT2Font::set_text(
364
341
std::set<FT_String*> glyph_seen_fonts;
365
342
FT2Font *ft_object_with_glyph = this ;
366
343
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,
368
345
charcode_error, glyph_error, glyph_seen_fonts, false );
369
346
if (!was_found) {
370
347
ft_glyph_warn ((FT_ULong)codepoint, glyph_seen_fonts);
371
348
// render missing glyph tofu
372
349
// come back to top-most font
373
350
ft_object_with_glyph = this ;
374
351
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);
377
353
} else if (ft_object_with_glyph->warn_if_used ) {
378
354
ft_glyph_warn ((FT_ULong)codepoint, glyph_seen_fonts);
379
355
}
@@ -383,8 +359,7 @@ void FT2Font::set_text(
383
359
ft_object_with_glyph->has_kerning () && // if the font knows how to kern
384
360
previous && glyph_index // and we really have 2 glyphs
385
361
) {
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);
388
363
}
389
364
390
365
// 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
434
409
FT_Error charcode_error, glyph_error;
435
410
FT2Font *ft_object_with_glyph = this ;
436
411
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,
438
413
charcode, flags, charcode_error, glyph_error,
439
414
glyph_seen_fonts, true );
440
415
if (!was_found) {
@@ -493,7 +468,6 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
493
468
FT_UInt &final_glyph_index,
494
469
std::vector<FT_Glyph> &parent_glyphs,
495
470
std::unordered_map<long , FT2Font *> &parent_char_to_font,
496
- std::unordered_map<FT_UInt, FT2Font *> &parent_glyph_to_font,
497
471
long charcode,
498
472
FT_Int32 flags,
499
473
FT_Error &charcode_error,
@@ -523,7 +497,6 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
523
497
// need to store this for anytime a character is loaded from a parent
524
498
// FT2Font object or to generate a mapping of individual characters to fonts
525
499
ft_object_with_glyph = this ;
526
- parent_glyph_to_font[final_glyph_index] = this ;
527
500
parent_char_to_font[charcode] = this ;
528
501
parent_glyphs.push_back (thisGlyph);
529
502
return true ;
@@ -532,7 +505,7 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
532
505
for (auto & fallback : fallbacks) {
533
506
bool was_found = fallback->load_char_with_fallback (
534
507
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,
536
509
charcode_error, glyph_error, glyph_seen_fonts, override );
537
510
if (was_found) {
538
511
return true ;
@@ -542,21 +515,6 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
542
515
}
543
516
}
544
517
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
-
560
518
void FT2Font::load_glyph (FT_UInt glyph_index, FT_Int32 flags)
561
519
{
562
520
FT_CHECK (FT_Load_Glyph, face, glyph_index, flags);
@@ -644,15 +602,8 @@ void FT2Font::draw_glyph_to_bitmap(
644
602
draw_bitmap (im, &bitmap->bitmap , x + bitmap->left , y);
645
603
}
646
604
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)
649
606
{
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
- }
656
607
if (!FT_HAS_GLYPH_NAMES (face)) {
657
608
/* Note that this generated name must match the name that
658
609
is generated by ttconv in ttfont_CharStrings_getname. */
0 commit comments