Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly handle local sources for CSS3 fonts #9149

Merged
merged 2 commits into from Jan 8, 2016
Merged

Conversation

@adrianheine
Copy link
Contributor

adrianheine commented Jan 4, 2016

Currently, servo panics for me when loading something like this:

@font-face {
  font-family: "test family";
  src: local(test font face);
}

That's due to a bug in FontCacheTask. FontCacheTask tries to get the value for the key
"test font face" from self.web_families, but previously initialized a value for the key "test family".

These two commits add an awkward test and fix the bug by not shadowing the variable family_name. Since the argument to local() should explicitly not be the name of a font family, the previous variable name was wrong and misleading anyways.

Review on Reviewable

adrianheine added 2 commits Jan 4, 2016
This test tries to add a web font to the `FontCacheTask`. The added web font
corresponds to the following CSS font definition:

```
@font-face {
  font-family: "test family";
  src: local(test font face);
}
```

This test fails, since `FontCacheTask` tries to get the value for the key
"test font face" from `self.web_families`, but previously initialized
a value for the key "test family".
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.
@jdm
Copy link
Member

jdm commented Jan 4, 2016

r? @glennw

@glennw
Copy link
Member

glennw commented Jan 7, 2016

@bors-servo r+

Thanks!

@bors-servo
Copy link
Contributor

bors-servo commented Jan 7, 2016

📌 Commit 4069645 has been approved by glennw

@bors-servo
Copy link
Contributor

bors-servo commented Jan 7, 2016

Testing commit 4069645 with merge 8e75a05...

bors-servo added a commit that referenced this pull request Jan 7, 2016
Correctly handle local sources for CSS3 fonts

Currently, servo panics for me when loading something like this:

```
@font-face {
  font-family: "test family";
  src: local(test font face);
}
```

That's due to a bug in `FontCacheTask`. `FontCacheTask` tries to get the value for the key
"test font face" from `self.web_families`, but previously initialized a value for the key "test family".

These two commits add an awkward test and fix the bug by not shadowing the variable `family_name`. Since the argument to `local()` should explicitly not be the name of a font family, the previous variable name was wrong and misleading anyways.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9149)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jan 7, 2016

💔 Test failed - linux-rel

@KiChjang
Copy link
Member

KiChjang commented Jan 8, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Jan 8, 2016

Previous build results for android, gonk, mac-dev-ref-unit, mac-rel-css, mac-rel-wpt are reusable. Rebuilding only linux-dev, linux-rel...

@bors-servo
Copy link
Contributor

bors-servo commented Jan 8, 2016

💔 Test failed - linux-rel

@KiChjang
Copy link
Member

KiChjang commented Jan 8, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Jan 8, 2016

Previous build results for android, gonk, linux-dev, mac-dev-ref-unit, mac-rel-css, mac-rel-wpt are reusable. Rebuilding only linux-rel...

@bors-servo
Copy link
Contributor

bors-servo commented Jan 8, 2016

@bors-servo bors-servo merged commit 4069645 into servo:master Jan 8, 2016
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@adrianheine adrianheine deleted the adrianheine:webFonts branch Jan 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

7 participants
You can’t perform that action at this time.