Skip to content

Commit f7ee09b

Browse files
committed
Fix memory leak and render tofu
1 parent c687e53 commit f7ee09b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/ft2font.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,10 @@ FT2Font::~FT2Font()
377377
if (face) {
378378
FT_Done_Face(face);
379379
}
380+
381+
for (size_t i = 0; i < fallbacks.size(); i++) {
382+
Py_DECREF(fallbacks[i]->get_pyfont());
383+
}
380384
}
381385

382386
void FT2Font::clear()
@@ -508,15 +512,20 @@ void FT2Font::set_text(
508512
FT_BBox glyph_bbox;
509513
FT_Pos last_advance;
510514

511-
FT_UInt final_glyph_index;
515+
FT_UInt final_glyph_index = 0;
512516
FT_Error charcode_error, glyph_error;
513517
FT2Font *ft_object_with_glyph = this;
514518
bool was_found = load_char_with_fallback(ft_object_with_glyph, final_glyph_index, glyphs,
515519
char_to_font, glyph_to_font, codepoints[n], flags,
516520
charcode_error, glyph_error, false);
517521
if (!was_found) {
518522
ft_glyph_warn((FT_ULong)codepoints[n]);
519-
continue;
523+
524+
// render tofu
525+
// ft_object_with_glyph == this
526+
char_to_font[codepoints[n]] = ft_object_with_glyph;
527+
glyph_to_font[final_glyph_index] = ft_object_with_glyph;
528+
ft_object_with_glyph->load_glyph(final_glyph_index, flags, ft_object_with_glyph, false);
520529
}
521530

522531
glyph_index = final_glyph_index;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy