diff options
author | Joe Wilm <joe@jwilm.com> | 2017-02-25 16:13:52 -0800 |
---|---|---|
committer | Joe Wilm <jwilm@users.noreply.github.com> | 2017-03-01 22:07:14 -0800 |
commit | 4b4a187fbd0cd47cdf6be5614ccfa473f356dac0 (patch) | |
tree | 178a2f8963a3ee3d5b0b5488fc2d5e47e29b8a51 | |
parent | 28700ed3dc35bc5d725d98a5f58fcbeb2eabedce (diff) | |
download | alacritty-4b4a187fbd0cd47cdf6be5614ccfa473f356dac0.tar.gz alacritty-4b4a187fbd0cd47cdf6be5614ccfa473f356dac0.zip |
Fix fc::Pattern::add_charset
The lifetime constraints didn't do what I thought, and such constraints
turn out to be unnecessary anyhow.
-rw-r--r-- | font/src/ft/list_fonts.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/font/src/ft/list_fonts.rs b/font/src/ft/list_fonts.rs index cedd0c5e..3867611e 100644 --- a/font/src/ft/list_fonts.rs +++ b/font/src/ft/list_fonts.rs @@ -376,9 +376,11 @@ pub mod fc { /// Add charset to the pattern /// - /// The lifetimes here ensure that the charset is alive at least as long - /// as the pattern. - pub fn add_charset<'b, 'a: 'b>(&'b self, charset: &'a CharSetRef) -> bool { + /// The referenced charset is copied by fontconfig internally using + /// FcValueSave so that no references to application provided memory are + /// retained. That is, the CharSet can be safely dropped immediately + /// after being added to the pattern. + pub unsafe fn add_charset(&self, charset: &CharSetRef) -> bool { unsafe { FcPatternAddCharSet( self.as_ptr(), @@ -565,6 +567,7 @@ mod tests { charset.add('💖'); let mut pattern = fc::Pattern::new(); pattern.add_charset(&charset); + drop(charset); let config = fc::Config::get_current(); let fonts = fc::font_sort(config, &mut pattern).expect("font_sort"); @@ -581,4 +584,4 @@ mod tests { println!(""); } } -} + |