Skip to content

Try to fix the font rendering issue on redit on Windows - #15937

Closed
codec-abc wants to merge 1 commit into
servo:masterfrom
codec-abc:fix-windows-reddit
Closed

codec-abc wants to merge 1 commit into
servo:masterfrom
codec-abc:fix-windows-reddit

Conversation

@codec-abc

@codec-abc codec-abc commented Mar 14, 2017 •

Copy link
Copy Markdown

This is quick "fix" for #15698. I am quite sure that the fix only fix the effect and not the cause. As such the PR serve more as a discussion as jonathandturner suggested. I suggest reviewer to start reading the short issue's history first.

About the test I do not have one but I was able to reproduce the issue with the following :

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   </head>
   <body>
        <div>a</div>
        <div>b</div>
        <div>c</div>
   </body>
</html>

Whereas in FF and Chrome each character a,b and c are one below the others, in Servo on Windows they are overlapping.
So if the problem come from the line gap with the default font I think that we can add some test to ensure that line gaps for default font are not 0.


This change is Reviewable

EDIT : issue number

@highfive

Copy link
Copy Markdown

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @KiChjang (or someone else) soon.

@highfive

Copy link
Copy Markdown

warning Warning warning

  • These commits modify gfx code, but no tests are modified. Please consider adding a test!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Mar 14, 2017
@KiChjang

Copy link
Copy Markdown
Contributor

r? @emilio

@highfive highfive assigned emilio and unassigned KiChjang Mar 14, 2017
@nox

nox commented Mar 14, 2017

Copy link
Copy Markdown
Contributor

I've removed @jonathandturner's mention from the PR message to avoid too numerous email notifications when this gets propagated back into Gecko's repositories.

@emilio

emilio commented Mar 14, 2017

Copy link
Copy Markdown
Member

@vvuk does this PR look reasonable to you? I think it's really wallpaper-ish.

@codec-abc

Copy link
Copy Markdown
Author

I copied and paste the wrong issue number when creating the pull request. Sorry about that.

@codec-abc

codec-abc commented Mar 14, 2017 •

Copy link
Copy Markdown
Author

Working on another bug related to fonts in Windows I think I understand the problem better. If we take a look at the integration of freetype we can see that the line_gap value is the height value coming from freetype. This comment says 'leading' is supposed to be the vertical distance between two baselines, reflected by the height attribute in freetype. While the DirectWrite Documentation state in the lineGap paragraph that "The recommended line spacing (baseline-to-baseline distance) is the sum of ascent, descent, and lineGap". To sump up I think the variables names does not match across the APIs and the line_gap value (for the FontMetrics) for Windows should be computed as dm.ascent + dm.descent+ dm.lineGap. I have yet to test this and will do tomorrow.

@sophiajt

Copy link
Copy Markdown

@codec-abc - I tried your suggestion, doing something like:

-            line_gap:         au_from_du(dm.lineGap as i32),
+            line_gap:         au_from_du((dm.ascent + dm.descent + dm.lineGap as u16) as i32),

Which gives:

reddit_with_font

Not sure if that's correct (the gap looks a little bigger than the equiv in firefox), but it does look better.

@codec-abc

codec-abc commented Mar 16, 2017 •

Copy link
Copy Markdown
Author

Nice! I think the best thing to do now is to run servo on simple web page (like the one provided with the first comment of this PR) under Linux and Windows and compare the values of the structures coming from FreeType and DirectWrite. If the settings are the same (same font, same display dpi, etc...) we should get the same results and we should be able to find out the correct maths.

Random notes:

  • After more thinking It is weird that if the problem come from the baseline to baseline being wrong on Windows, it only break the layout on Reddit. I expect that any page having text to be messed up.
  • Is the font spacing on Linux and MacOS matching the ones in FF & Chrome ?
  • On a Totally not related subject, I cannot find a way to print debug instruction in Servo which make the debugging a bit more difficult. I suspect the standard output being redirected but I have found nothing about it in the wiki. Am I missing something obvious?

@jdm

jdm commented Mar 16, 2017

Copy link
Copy Markdown
Member

@codec-abc println! goes directly to the terminal. What are you trying that does not work?

@codec-abc

Copy link
Copy Markdown
Author

@jdm I think I was fooled by the debugger (Visual Studio). I set a println! instruction before a line were a breakpoint was hit each time but I got nothing on the console. Thus I infer it did not worked. Putting println! instruction elsewhere worked. So I think that Visual Studio hit breakpoint on parts on code that are not actually run through at runtime.

@sophiajt

Copy link
Copy Markdown

@codec-abc - I looked at the font metrics for macos and windows, but it's too difficult to line up the numbers to see where one is different. There are dozens of log messages just for font metrics alone for opening reddit.

Like I said, it looks close. Perhaps we can land it and then tweak.

@codec-abc

Copy link
Copy Markdown
Author

I think it should be manageable is you use something like that because you should get only one value for the FontMetric struct.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   </head>
   <body style="font-family:'Times New Roman';">
<div>A line</div>
<div>Another line</div>
   </body>
</html>

When rendering this simple web page on Servo I got the 2nd line on top on the first, which is I believe the exact same thing happening on Reddit.

For debugging the other font issues on Windows I usually use http-server or live-server to serve a tiny web page. That way I can easily focus on the part that I want while not being overwhelmed by data.

Concerning the pull request it may be better the to be sure to have the math right changing the code as it will surely reduce the risk to have to deal with many other issues later.

@sophiajt

Copy link
Copy Markdown

I'm not sure I'll have time to keep looking into this until possibly sometime next week, but please do keep going. I'd be interested to see if you can get the platforms lining up.

@sophiajt sophiajt mentioned this pull request Mar 20, 2017
4 of 5 tasks
bors-servo pushed a commit that referenced this pull request Mar 21, 2017
Fix Windows UI and font squishing

<!-- Please describe your changes on the following line: -->

This PR:

* updates the browserhtml dep (fixes #15255)
* updates the Windows font metric calculation (fixes #15698, based on codec-abc #15937 (comment))
* may address #15933.  With this PR, I was not able to repro

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because change are to UI/visual results of font drawing

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/16034)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #16034) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Mar 21, 2017
@jdm

jdm commented Mar 21, 2017

Copy link
Copy Markdown
Member

#16034 has resolved this. Thanks for investigating this @codec-abc!

@jdm jdm closed this Mar 21, 2017
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Mar 21, 2017
…ndturner:fix_font); r=metajack

<!-- Please describe your changes on the following line: -->

This PR:

* updates the browserhtml dep (fixes servo/servo#15255)
* updates the Windows font metric calculation (fixes servo/servo#15698, based on codec-abc servo/servo#15937 (comment))
* may address servo/servo#15933.  With this PR, I was not able to repro

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because change are to UI/visual results of font drawing

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: cea1760eb7689d88b18525fac7d53f9a12fdb8a1

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : e9654e401876e04082919212e16f185c2992cdc9
Manishearth pushed a commit to Manishearth/gecko-dev that referenced this pull request Mar 28, 2017
…ndturner:fix_font); r=metajack

<!-- Please describe your changes on the following line: -->

This PR:

* updates the browserhtml dep (fixes servo/servo#15255)
* updates the Windows font metric calculation (fixes servo/servo#15698, based on codec-abc servo/servo#15937 (comment))
* may address servo/servo#15933.  With this PR, I was not able to repro

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because change are to UI/visual results of font drawing

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: cea1760eb7689d88b18525fac7d53f9a12fdb8a1
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 1, 2019
…ndturner:fix_font); r=metajack

<!-- Please describe your changes on the following line: -->

This PR:

* updates the browserhtml dep (fixes servo/servo#15255)
* updates the Windows font metric calculation (fixes servo/servo#15698, based on codec-abc servo/servo#15937 (comment))
* may address servo/servo#15933.  With this PR, I was not able to repro

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because change are to UI/visual results of font drawing

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: cea1760eb7689d88b18525fac7d53f9a12fdb8a1

UltraBlame original commit: fad072f940ccdfb70bb1799bb256841070e0993c
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 1, 2019
…ndturner:fix_font); r=metajack

<!-- Please describe your changes on the following line: -->

This PR:

* updates the browserhtml dep (fixes servo/servo#15255)
* updates the Windows font metric calculation (fixes servo/servo#15698, based on codec-abc servo/servo#15937 (comment))
* may address servo/servo#15933.  With this PR, I was not able to repro

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because change are to UI/visual results of font drawing

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: cea1760eb7689d88b18525fac7d53f9a12fdb8a1

UltraBlame original commit: fad072f940ccdfb70bb1799bb256841070e0993c
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 1, 2019
…ndturner:fix_font); r=metajack

<!-- Please describe your changes on the following line: -->

This PR:

* updates the browserhtml dep (fixes servo/servo#15255)
* updates the Windows font metric calculation (fixes servo/servo#15698, based on codec-abc servo/servo#15937 (comment))
* may address servo/servo#15933.  With this PR, I was not able to repro

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because change are to UI/visual results of font drawing

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: cea1760eb7689d88b18525fac7d53f9a12fdb8a1

UltraBlame original commit: fad072f940ccdfb70bb1799bb256841070e0993c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-review There is new code that needs to be reviewed. S-needs-rebase There are merge conflict errors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows Servo renders reddit text squished

8 participants