Don't shadow family_name

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.
This commit is contained in:
Adrian Heine 2016-01-03 18:23:03 +01:00
parent 3f61d63e72
commit 4069645729

View file

@ -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();