Skip to content

Fix FontTemplateDescriptor under FreeType - #19928

Merged
bors-servo merged 2 commits into
servo:masterfrom
jonleighton:issue-17321
Feb 8, 2018
Merged

bors-servo merged 2 commits into
servo:masterfrom
jonleighton:issue-17321

Conversation

@jonleighton

@jonleighton jonleighton commented Feb 1, 2018 •

Copy link
Copy Markdown
Contributor

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 highfive added the S-awaiting-review There is new code that needs to be reviewed. label Feb 1, 2018
@highfive

highfive commented Feb 1, 2018

Copy link
Copy Markdown

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
Copy Markdown
Contributor Author

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

jdm commented Feb 1, 2018

Copy link
Copy Markdown
Member

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 pushed 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 pushed 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
Copy Markdown
Contributor Author

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 Tests with a "font" meta flag are marked as manual 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

jdm commented Feb 4, 2018

Copy link
Copy Markdown
Member

A unit test sounds sensible, in that case.

@jonleighton

Copy link
Copy Markdown
Contributor Author

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.

use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use platform::font::FontHandle;
use platform::font_context::FontContextHandle;
pub use platform::font_context::FontContextHandle;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 issue-17321 branch 2 times, most recently from fd68b22 to ecf441d Compare February 5, 2018 18:03
@jonleighton

Copy link
Copy Markdown
Contributor Author

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

@jonleighton

Copy link
Copy Markdown
Contributor Author

@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

metajack commented Feb 6, 2018

Copy link
Copy Markdown
Collaborator

The license is fine.

@jdm

jdm commented Feb 6, 2018

Copy link
Copy Markdown
Member

@bors-servo r=emilio,jack

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit ecf441d has been approved by emilio,jack

@highfive highfive assigned emilio and unassigned metajack Feb 6, 2018
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Feb 6, 2018
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit ecf441d with merge b03899e...

bors-servo pushed 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
Copy Markdown
Contributor

💔 Test failed - mac-dev-unit

bors-servo pushed 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
Copy Markdown
Contributor

💔 Test failed - mac-dev-unit

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Feb 7, 2018
Issue servo#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.
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Feb 7, 2018
@jdm

jdm commented Feb 8, 2018

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 446b0e4 has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Feb 8, 2018
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 446b0e4 with merge 2032b46...

bors-servo pushed 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
Copy Markdown
Contributor

💔 Test failed - linux-dev

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Feb 8, 2018
@jdm

jdm commented Feb 8, 2018

Copy link
Copy Markdown
Member

@bors-servo retry

  • freed up space on servo-linux6

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 446b0e4 with merge 1ed6010...

bors-servo pushed 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 -->
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Feb 8, 2018
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel-wpt

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Feb 8, 2018
@bors-servo

Copy link
Copy Markdown
Contributor

⚡ Previous build results for android, arm32, arm64, linux-dev, linux-rel-css, mac-dev-unit, mac-rel-css1, mac-rel-wpt4, windows-msvc-dev are reusable. Rebuilding only linux-rel-wpt, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3...

@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev
Approved by: jdm
Pushing 1ed6010 to master...

@bors-servo
bors-servo merged commit 446b0e4 into servo:master Feb 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-tests-failed The changes caused existing tests to fail.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants