From 40696457299e66e58522875838e99961ed9bdf1e Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Sun, 3 Jan 2016 18:23:03 +0100 Subject: [PATCH] Don't shadow family_name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The argument to `local()` is not a font family, but the name of a »single font face within a larger family« according to http://www.w3.org/TR/css3-fonts/#src-desc. The previous implementation of `FontCache::run` would panic if the argument to `local()` would not be the name of a font family present in `self.web_families`. That happened since `FontCacheTask` tried to use the argument to `local()` as a key for `self.web_families`, although it previously correctly initialized a value for the `family` field of the `AddWebFont` command. --- components/gfx/font_cache_task.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/gfx/font_cache_task.rs b/components/gfx/font_cache_task.rs index cfa53a3d119..bba52ade3cb 100644 --- a/components/gfx/font_cache_task.rs +++ b/components/gfx/font_cache_task.rs @@ -152,7 +152,7 @@ impl FontCache { let family_name = LowercaseString::new(family.name()); if !self.web_families.contains_key(&family_name) { let templates = FontTemplates::new(); - self.web_families.insert(family_name, templates); + self.web_families.insert(family_name.clone(), templates); } match src { @@ -208,10 +208,10 @@ impl FontCache { } }); } - Source::Local(ref family) => { - let family_name = LowercaseString::new(family.name()); + Source::Local(ref font) => { + let font_face_name = LowercaseString::new(font.name()); let templates = &mut self.web_families.get_mut(&family_name).unwrap(); - for_each_variation(&family_name, |path| { + for_each_variation(&font_face_name, |path| { templates.add_template(Atom::from(&*path), None); }); result.send(()).unwrap();