@@ -199,14 +199,17 @@ static FT_UInt ft_glyph_warn(FT_ULong charcode)
199
199
return 0 ;
200
200
}
201
201
202
- static FT_UInt ft_get_char_index_or_warn (FT_Face face, FT_ULong charcode, bool warn = true )
202
+ static FT_UInt
203
+ ft_get_char_index_or_warn (FT_Face face, FT_ULong charcode, bool warn = true )
203
204
{
204
205
FT_UInt glyph_index = FT_Get_Char_Index (face, charcode);
205
206
if (glyph_index) {
206
207
return glyph_index;
207
208
}
208
- if (warn) return ft_glyph_warn (charcode);
209
- else return 0 ;
209
+ if (warn) {
210
+ return ft_glyph_warn (charcode);
211
+ }
212
+ return 0 ;
210
213
}
211
214
212
215
// ft_outline_decomposer should be passed to FT_Outline_Decompose. On the
@@ -403,7 +406,7 @@ void FT2Font::clear()
403
406
glyph_to_font.clear ();
404
407
char_to_font.clear ();
405
408
406
- for (unsigned int i = 0 ; i < fallbacks.size (); i++) {
409
+ for (size_t i = 0 ; i < fallbacks.size (); i++) {
407
410
fallbacks[i]->clear ();
408
411
}
409
412
}
@@ -418,7 +421,7 @@ void FT2Font::set_size(double ptsize, double dpi)
418
421
FT_Matrix transform = { 65536 / hinting_factor, 0 , 0 , 65536 };
419
422
FT_Set_Transform (face, &transform, 0 );
420
423
421
- for (unsigned int i = 0 ; i < fallbacks.size (); i++) {
424
+ for (size_t i = 0 ; i < fallbacks.size (); i++) {
422
425
fallbacks[i]->set_size (ptsize, dpi);
423
426
}
424
427
}
@@ -488,7 +491,7 @@ int FT2Font::get_kerning(FT_UInt left, FT_UInt right, FT_UInt mode, FT_Vector &d
488
491
void FT2Font::set_kerning_factor (int factor)
489
492
{
490
493
kerning_factor = factor;
491
- for (unsigned int i = 0 ; i < fallbacks.size (); i ++){
494
+ for (size_t i = 0 ; i < fallbacks.size (); i++) {
492
495
fallbacks[i]->set_kerning_factor (factor);
493
496
}
494
497
}
@@ -500,7 +503,7 @@ void FT2Font::set_text(
500
503
501
504
angle = angle / 360.0 * 2 * M_PI;
502
505
503
- // this computes width and height in subpixels so we have to divide by 64
506
+ // this computes width and height in subpixels so we have to multiply by 64
504
507
matrix.xx = (FT_Fixed)(cos (angle) * 0x10000L );
505
508
matrix.xy = (FT_Fixed)(-sin (angle) * 0x10000L );
506
509
matrix.yx = (FT_Fixed)(sin (angle) * 0x10000L );
@@ -514,29 +517,26 @@ void FT2Font::set_text(
514
517
bbox.xMin = bbox.yMin = 32000 ;
515
518
bbox.xMax = bbox.yMax = -32000 ;
516
519
517
- for (unsigned int n = 0 ; n < N; n++) {
518
- FT_UInt glyph_index;
520
+ for (size_t n = 0 ; n < N; n++) {
521
+ FT_UInt glyph_index = 0 ;
519
522
FT_BBox glyph_bbox;
520
523
FT_Pos last_advance;
521
524
522
- FT_UInt final_glyph_index = 0 ;
523
525
FT_Error charcode_error, glyph_error;
524
526
FT2Font *ft_object_with_glyph = this ;
525
- bool was_found = load_char_with_fallback (ft_object_with_glyph, final_glyph_index , glyphs,
527
+ bool was_found = load_char_with_fallback (ft_object_with_glyph, glyph_index , glyphs,
526
528
char_to_font, glyph_to_font, codepoints[n], flags,
527
529
charcode_error, glyph_error, false );
528
530
if (!was_found) {
529
531
ft_glyph_warn ((FT_ULong)codepoints[n]);
530
532
531
- // render tofu
533
+ // render missing glyph tofu
532
534
// ft_object_with_glyph == this
533
535
char_to_font[codepoints[n]] = ft_object_with_glyph;
534
- glyph_to_font[final_glyph_index ] = ft_object_with_glyph;
535
- ft_object_with_glyph->load_glyph (final_glyph_index , flags, ft_object_with_glyph, false );
536
+ glyph_to_font[glyph_index ] = ft_object_with_glyph;
537
+ ft_object_with_glyph->load_glyph (glyph_index , flags, ft_object_with_glyph, false );
536
538
}
537
539
538
- glyph_index = final_glyph_index;
539
-
540
540
// retrieve kerning distance and move pen position
541
541
if (use_kerning && previous && glyph_index) {
542
542
FT_Vector delta;
@@ -594,24 +594,21 @@ void FT2Font::fill_glyphs(
594
594
bbox.xMin = bbox.yMin = 32000 ;
595
595
bbox.xMax = bbox.yMax = -32000 ;
596
596
597
- for (unsigned int n = 0 ; n < N; n++) {
598
- FT_UInt glyph_index;
597
+ for (size_t n = 0 ; n < N; n++) {
598
+ FT_UInt glyph_index = 0 ;
599
599
FT_BBox glyph_bbox;
600
600
FT_Pos last_advance;
601
601
602
- FT_UInt final_glyph_index;
603
602
FT_Error charcode_error, glyph_error;
604
603
FT2Font *ft_object_with_glyph = this ;
605
- bool was_found = load_char_with_fallback (ft_object_with_glyph, final_glyph_index , glyphs,
604
+ bool was_found = load_char_with_fallback (ft_object_with_glyph, glyph_index , glyphs,
606
605
char_to_font, glyph_to_font, codepoints[n], flags,
607
606
charcode_error, glyph_error, false );
608
607
if (!was_found) {
609
608
if (warn) ft_glyph_warn ((FT_ULong)codepoints[n]);
610
609
continue ;
611
610
}
612
611
613
- glyph_index = final_glyph_index;
614
-
615
612
// retrieve kerning distance and move pen position
616
613
if (use_kerning && previous && glyph_index) {
617
614
FT_Vector delta;
@@ -699,12 +696,16 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
699
696
700
697
if (glyph_index || override ) {
701
698
charcode_error = FT_Load_Glyph (face, glyph_index, flags);
699
+ if (charcode_error) {
700
+ return false ;
701
+ }
702
+
702
703
FT_Glyph thisGlyph;
703
704
glyph_error = FT_Get_Glyph (face->glyph , &thisGlyph);
704
-
705
- if (charcode_error || glyph_error) {
705
+ if (glyph_error) {
706
706
return false ;
707
707
}
708
+
708
709
final_glyph_index = glyph_index;
709
710
710
711
// cache the result for future
@@ -718,12 +719,13 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
718
719
}
719
720
720
721
else {
721
- for (unsigned int i = 0 ; i < fallbacks.size (); ++i) {
722
+ for (size_t i = 0 ; i < fallbacks.size (); ++i) {
722
723
bool was_found = fallbacks[i]->load_char_with_fallback (
723
724
ft_object_with_glyph, final_glyph_index, parent_glyphs, parent_char_to_font,
724
725
parent_glyph_to_font, charcode, flags, charcode_error, glyph_error, override );
725
- if (was_found)
726
+ if (was_found) {
726
727
return true ;
728
+ }
727
729
}
728
730
return false ;
729
731
}
0 commit comments