aboutsummaryrefslogtreecommitdiff
path: root/font/src/lib.rs
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2017-10-14 18:58:19 -0700
committerJoe Wilm <joe@jwilm.com>2017-10-14 19:07:43 -0700
commite8f5ab89ee0b6810649f76c6dbd15ee1105554e8 (patch)
treef9ba9fa4e23f99b3b9ecfde84d32bce03730f7a4 /font/src/lib.rs
parent8a0b1d9c3f5a9ddb98469a340bbcd06374d4a24e (diff)
downloadalacritty-e8f5ab89ee0b6810649f76c6dbd15ee1105554e8.tar.gz
alacritty-e8f5ab89ee0b6810649f76c6dbd15ee1105554e8.zip
Fix memory leak from font resizing
The source of the leak was loading up multiple copies of the FT_face even when not necessary. Fonts are now appropriately cached for FreeType when going through the `Rasterize::load_font` API. Additionally, textures in the glyph cache are now reused. The result of this is that resizing to already loaded fonts is free from a memory consumption perspective.
Diffstat (limited to 'font/src/lib.rs')
-rw-r--r--font/src/lib.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/font/src/lib.rs b/font/src/lib.rs
index 181fd88c..513dacdd 100644
--- a/font/src/lib.rs
+++ b/font/src/lib.rs
@@ -172,6 +172,14 @@ impl Size {
}
}
+impl ::std::ops::Add for Size {
+ type Output = Size;
+
+ fn add(self, other: Size) -> Size {
+ Size(self.0.saturating_add(other.0))
+ }
+}
+
pub struct RasterizedGlyph {
pub c: char,
pub width: i32,