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

Fix FontTemplateDescriptor under FreeType #19928

Merged
merged 2 commits into from Feb 8, 2018
Merged

Conversation

@jonleighton
Copy link
Contributor

jonleighton commented Feb 1, 2018

Issue #17321. Under Linux, using "font-family: sans-serif" previously
caused Servo to select the "UltraLight" face (of DejaVu Sans). There were
two reasons for this:

  1. Font weight was only retrieved from the OS/2 table for bold faces.
    This neglected to retrieve the weight information for "lighter than
    normal" weight faces. This meant that the UltraLight face appeared as
    normal weight, and was selected.

  2. Retrieval of font stretch information from the OS/2 table was not
    implemented at all.


This change is Reviewable

@highfive
Copy link

highfive commented Feb 1, 2018

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • These commits modify gfx code, but no tests are modified. Please consider adding a test!
@jonleighton
Copy link
Contributor Author

jonleighton commented Feb 1, 2018

I would like to implement tests for this change, but need some guidance. I asked about this in IRC but got no response:

Hi! I was just looking at a font-related issue and decided to run tests/wpt/web-platform-tests/css/css-fonts on my machine. I got a bunch of failures, and then I realised that these tests are not run on the CI (it's configured in tests/wpt/include.ini). Why is that? What would be the best way to ensure a font-related change is properly tested?

I see two options (or both):

  1. Enable the css-fonts WPT tests
  2. Write unit tests

Advice please!

@jdm
Copy link
Member

jdm commented Feb 1, 2018

Go ahead and enable the tests. They were added when we weren't paying attention; there's no reason I know of not to run them in Servo.

jonleighton added a commit to jonleighton/servo that referenced this pull request Feb 1, 2018
See servo#19928 (comment)

Note that some of these tests require you to install the fonts found in
tests/wpt/web-platform-tests/css/fonts.
bors-servo added a commit that referenced this pull request Feb 1, 2018
Enable css-fonts WPT tests

See #19928 (comment)

Note that some of these tests require you to install the fonts found in
tests/wpt/web-platform-tests/css/fonts.

r? @jdm

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19930)
<!-- Reviewable:end -->
jonleighton added a commit to jonleighton/servo that referenced this pull request Feb 1, 2018
See servo#19928 (comment)

Note that some of these tests require you to install the fonts found in
tests/wpt/web-platform-tests/css/fonts.
bors-servo added a commit that referenced this pull request Feb 1, 2018
Enable css-fonts WPT tests

See #19928 (comment)

Note that some of these tests require you to install the fonts found in
tests/wpt/web-platform-tests/css/fonts.

r? @jdm

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19930)
<!-- Reviewable:end -->
@jonleighton
Copy link
Contributor Author

jonleighton commented Feb 3, 2018

I've been looking into how to test this and have hit several roadblocks after enabling the css-fonts tests.

The change to how the font weight is detected is captured by css/css-fonts/font-weight-normal-001.xht. (I haven't found an existing test which captures the font stretch fix.) However, it doesn't easily show this bug fix for two reasons:

  1. That test is marked as a manual test in WPT, even though it's actually a reftest. Therefore it won't run on the CI. See web-platform-tests/wpt#9374.
  2. That test fails still fails after my fix due to presumably other bugs in how we are implementing the font matching algorithm. The rendering of the test changes, but it still doesn't pass (per my manual testing with and without this patch).

Therefore I propose to write a unit test to encapsulate this change.

@jdm
Copy link
Member

jdm commented Feb 4, 2018

A unit test sounds sensible, in that case.

@jonleighton jonleighton force-pushed the jonleighton:issue-17321 branch from 9f867ac to 38622c7 Feb 4, 2018
@jonleighton
Copy link
Contributor Author

jonleighton commented Feb 4, 2018

OK, I've added a test. I tried to use the existing test fonts in tests/wpt/web-platform-tests/css/fonts/CSSTest/, but there were no condensed/expanded versions to test the font-stretch detection. So I added the DejaVu fonts. The addition of the descriptor() method yielded a nice cleanup for the existing methods which load the descriptor.

@@ -9,7 +9,7 @@ use font_cache_thread::FontCacheThread;
use font_template::FontTemplateDescriptor;
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use platform::font::FontHandle;
use platform::font_context::FontContextHandle;
pub use platform::font_context::FontContextHandle;

This comment has been minimized.

@jonleighton

jonleighton Feb 4, 2018

Author Contributor

I had to do this for the test, which doesn't seem ideal but I struggled to find an alternative. In the existing code, a FontContext instantiates a FontContextHandle, but instantiating a FontContext requires lots of dependencies (some of them external to this crate too).

@jonleighton jonleighton force-pushed the jonleighton:issue-17321 branch 2 times, most recently from fd68b22 to ecf441d Feb 4, 2018
@jonleighton
Copy link
Contributor Author

jonleighton commented Feb 5, 2018

The test I wrote failed on Windows but it's fixed now.

@jonleighton
Copy link
Contributor Author

jonleighton commented Feb 6, 2018

@emilio has reviewed and says he's happy with the code, but he's unsure about whether there are licensing issues caused by the inclusion of the DejaVu fonts for testing: https://mozilla.logbot.info/servo/20180206#c14250864-c14250932

@metajack
Copy link
Contributor

metajack commented Feb 6, 2018

The license is fine.

@jdm
Copy link
Member

jdm commented Feb 6, 2018

@bors-servo r=emilio,jack

@bors-servo
Copy link
Contributor

bors-servo commented Feb 6, 2018

📌 Commit ecf441d has been approved by emilio,jack

@highfive highfive assigned emilio and unassigned metajack Feb 6, 2018
@bors-servo
Copy link
Contributor

bors-servo commented Feb 6, 2018

Testing commit ecf441d with merge b03899e...

bors-servo added a commit that referenced this pull request Feb 6, 2018
Fix FontTemplateDescriptor under FreeType

Issue #17321. Under Linux, using "font-family: sans-serif" previously
caused Servo to select the "UltraLight" face (of DejaVu Sans). There were
two reasons for this:

1. Font weight was only retrieved from the OS/2 table for bold faces.
   This neglected to retrieve the weight information for "lighter than
   normal" weight faces. This meant that the UltraLight face appeared as
   normal weight, and was selected.

2. Retrieval of font stretch information from the OS/2 table was not
   implemented at all.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19928)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Feb 6, 2018

💔 Test failed - mac-dev-unit

bors-servo added a commit to servo/saltfs that referenced this pull request Feb 7, 2018
Add my SSH key

In servo/servo#19928 @metajack suggested that I could use one of the builders to work on Mac-specific code and @jdm requested I submit my key in a PR here.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/saltfs/795)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Feb 7, 2018

💔 Test failed - mac-dev-unit

Issue #17321. Under Linux, using "font-family: sans-serif" previously
caused Servo to select the "UltraLight" face (of DejaVu Sans). There
were two reasons for this:

1. Font weight was only retrieved from the OS/2 table for bold faces.
   This neglected to retrieve the weight information for "lighter than
   normal" weight faces. This meant that the UltraLight face appeared as
   normal weight, and was selected.

2. Retrieval of font stretch information from the OS/2 table was not
   implemented at all.
@jonleighton jonleighton force-pushed the jonleighton:issue-17321 branch from ae1020f to 446b0e4 Feb 7, 2018
@jdm
Copy link
Member

jdm commented Feb 8, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Feb 8, 2018

📌 Commit 446b0e4 has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Feb 8, 2018

Testing commit 446b0e4 with merge 2032b46...

bors-servo added a commit that referenced this pull request Feb 8, 2018
Fix FontTemplateDescriptor under FreeType

Issue #17321. Under Linux, using "font-family: sans-serif" previously
caused Servo to select the "UltraLight" face (of DejaVu Sans). There were
two reasons for this:

1. Font weight was only retrieved from the OS/2 table for bold faces.
   This neglected to retrieve the weight information for "lighter than
   normal" weight faces. This meant that the UltraLight face appeared as
   normal weight, and was selected.

2. Retrieval of font stretch information from the OS/2 table was not
   implemented at all.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19928)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Feb 8, 2018

💔 Test failed - linux-dev

@jdm
Copy link
Member

jdm commented Feb 8, 2018

@bors-servo retry

  • freed up space on servo-linux6
@bors-servo
Copy link
Contributor

bors-servo commented Feb 8, 2018

Testing commit 446b0e4 with merge 1ed6010...

bors-servo added a commit that referenced this pull request Feb 8, 2018
Fix FontTemplateDescriptor under FreeType

Issue #17321. Under Linux, using "font-family: sans-serif" previously
caused Servo to select the "UltraLight" face (of DejaVu Sans). There were
two reasons for this:

1. Font weight was only retrieved from the OS/2 table for bold faces.
   This neglected to retrieve the weight information for "lighter than
   normal" weight faces. This meant that the UltraLight face appeared as
   normal weight, and was selected.

2. Retrieval of font stretch information from the OS/2 table was not
   implemented at all.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19928)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Feb 8, 2018

💔 Test failed - linux-rel-wpt

@jdm
Copy link
Member

jdm commented Feb 8, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Feb 8, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Feb 8, 2018

@bors-servo bors-servo merged commit 446b0e4 into servo:master Feb 8, 2018
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
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.