@@ -231,6 +231,8 @@ bool PangoFontInfo::CoversUTF8Text(const char* utf8_text, int byte_length) const
231
231
return false ;
232
232
}
233
233
}
234
+ pango_coverage_unref (coverage);
235
+ g_object_unref (font);
234
236
return true ;
235
237
}
236
238
@@ -293,6 +295,8 @@ int PangoFontInfo::DropUncoveredChars(string* utf8_text) const {
293
295
my_strnmove (out, utf8_char, utf8_len);
294
296
out += utf8_len;
295
297
}
298
+ pango_coverage_unref (coverage);
299
+ g_object_unref (font);
296
300
utf8_text->resize (out - utf8_text->c_str ());
297
301
return num_dropped_chars;
298
302
}
@@ -316,6 +320,7 @@ bool PangoFontInfo::GetSpacingProperties(const string& utf8_char,
316
320
reinterpret_cast <PangoFcFont*>(font), *it);
317
321
if (!glyph_index) {
318
322
// Glyph for given unicode character doesn't exist in font.
323
+ g_object_unref (font);
319
324
return false ;
320
325
}
321
326
// Find the ink glyph extents for the glyph
@@ -332,6 +337,7 @@ bool PangoFontInfo::GetSpacingProperties(const string& utf8_char,
332
337
}
333
338
*x_bearing = min_bearing;
334
339
*x_advance = total_advance;
340
+ g_object_unref (font);
335
341
return true ;
336
342
}
337
343
@@ -612,9 +618,11 @@ void FontUtils::GetAllRenderableCharacters(std::vector<bool>* unichar_bitmap) {
612
618
void FontUtils::GetAllRenderableCharacters (const string& font_name,
613
619
std::vector<bool >* unichar_bitmap) {
614
620
PangoFontInfo font_info (font_name);
615
- PangoCoverage* coverage =
616
- pango_font_get_coverage (font_info. ToPangoFont () , nullptr );
621
+ PangoFont* font = font_info. ToPangoFont ();
622
+ PangoCoverage* coverage = pango_font_get_coverage (font , nullptr );
617
623
CharCoverageMapToBitmap (coverage, unichar_bitmap);
624
+ pango_coverage_unref (coverage);
625
+ g_object_unref (font);
618
626
}
619
627
620
628
/* static */
@@ -625,10 +633,12 @@ void FontUtils::GetAllRenderableCharacters(const std::vector<string>& fonts,
625
633
tlog (1 , " Processing %u fonts\n " , static_cast <unsigned >(fonts.size ()));
626
634
for (unsigned i = 0 ; i < fonts.size (); ++i) {
627
635
PangoFontInfo font_info (fonts[i]);
628
- PangoCoverage* coverage =
629
- pango_font_get_coverage (font_info. ToPangoFont () , nullptr );
636
+ PangoFont* font = font_info. ToPangoFont ();
637
+ PangoCoverage* coverage = pango_font_get_coverage (font , nullptr );
630
638
// Mark off characters that any font can render.
631
639
pango_coverage_max (all_coverage, coverage);
640
+ pango_coverage_unref (coverage);
641
+ g_object_unref (font);
632
642
}
633
643
CharCoverageMapToBitmap (all_coverage, unichar_bitmap);
634
644
pango_coverage_unref (all_coverage);
@@ -667,6 +677,8 @@ int FontUtils::FontScore(const std::unordered_map<char32, inT64>& ch_map,
667
677
ch_flags->push_back (covered);
668
678
}
669
679
}
680
+ pango_coverage_unref (coverage);
681
+ g_object_unref (font);
670
682
return ok_chars;
671
683
}
672
684
0 commit comments