The Birdfont Source Code


All Repositories / birdfont.git / blobdiff – RSS feed

Fix memory leak

Changes made to libbirdfont/Renderer/Text.vala

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
--- libbirdfont/Renderer/Text.vala +++ libbirdfont/Renderer/Text.vala @@ -113,7 +113,8 @@ index = 0; while (text.get_next_char (ref index, out c)) { name = (!) c.to_string (); - g = cached_font.get_glyph_by_name (name); + g = cached_font.get_glyph_by_name (name); + gs.glyph.add (g); glyph_names.add (name); } @@ -131,6 +132,7 @@ GlyphRange? gr_left, gr_right; GlyphSequence word; KerningClasses kc; + Font empty = new Font (); glyph = new Glyph.no_lines ("", '\0'); @@ -140,7 +142,7 @@ word = glyph_sequence; wi = 0; - + if (cached_font.font != null) { word_with_ligatures = word.process_ligatures ((!) cached_font.font); } else { @@ -153,9 +155,9 @@ if (cached_font.font != null) { kc = ((!) cached_font.font).get_kerning_classes (); } else { - kc = new KerningClasses (new Font ()); + kc = new KerningClasses (empty); } - + for (int i = 0; i < word_with_ligatures.glyph.size; i++) { g = word_with_ligatures.glyph.get (i); @@ -172,7 +174,7 @@ } // process glyph - if (g == null) { + if (g == null && (0 <= i < glyph_names.size)) { g = cached_font.get_glyph_by_name (glyph_names.get (i)); } @@ -180,6 +182,7 @@ iter (glyph, kern, i + 1 == word_with_ligatures.glyph.size); prev = g; wi++; + } } @@ -351,10 +354,10 @@ if (truncated_width > 0 && end - px > truncated_width) { return; } - + draw_chached (cr, glyph, kerning, last, x, y, cc_y, ratio, cacheid); - + x = end; }); } else {