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

Implement font rendering on Windows (MSVC) #13371

Closed
aochagavia opened this issue Sep 22, 2016 · 9 comments
Closed

Implement font rendering on Windows (MSVC) #13371

aochagavia opened this issue Sep 22, 2016 · 9 comments

Comments

@aochagavia
Copy link
Contributor

@aochagavia aochagavia commented Sep 22, 2016

The dummy implementation in components/gfx/platform/mod.rs should be replaced by a real one:

#[cfg(all(target_os = "windows", target_env = "msvc"))]
pub use platform::dummy::{font, font_context, font_list, font_template};

Currently, the lack of a proper implementation causes Servo to show a blank screen upon being launched (see #13257).

@aochagavia
Copy link
Contributor Author

@aochagavia aochagavia commented Sep 23, 2016

I wold like to help with this but have no idea where to begin. Would it be possible to use FreeType on (Windows, MSVC)? What are other browsers out there doing?

@aochagavia aochagavia mentioned this issue Sep 23, 2016
11 of 11 tasks complete
@retep998
Copy link

@retep998 retep998 commented Sep 23, 2016

Other browsers, such as Firefox Chrome IE Edge are all using DirectWrite to render text. It is possible to use freetype, but it's not recommended.

@aochagavia
Copy link
Contributor Author

@aochagavia aochagavia commented Sep 27, 2016

After investigating a little bit, I think I don't have enough time to implement this in the short term. The main problem I see is that I would need to get familiar with font rendering in the first place, which seems to be a very complex topic.

For anyone trying to implement this, maybe the directwrite crate can be a starting point.

@aochagavia
Copy link
Contributor Author

@aochagavia aochagavia commented Sep 30, 2016

Today I investigated a little bit more and implemented some functionality on top of the directwrite crate (you can check out the diff). This seems to be the way to go. Take a look at the examples directory to see the new code in action.

So far, two big blockers are:

  1. I have never used the Windows API before
  2. I have never used COM objects before

This means that, though the current implementation seems to work, I am unsure about memory safety and absence of memory leaks. Feel free to take a look at it and point out any issues (it would actually be great for someone to mentor)

@Boddlnagg
Copy link

@Boddlnagg Boddlnagg commented Sep 30, 2016

@aochagavia The link you provided seems to be wrong ...

@aochagavia
Copy link
Contributor Author

@aochagavia aochagavia commented Sep 30, 2016

@Boddlnagg Thanks for the heads up! I just fixed the link.

@metajack
Copy link
Contributor

@metajack metajack commented Oct 3, 2016

You might be interested in this: https://gist.github.com/metajack/e75da24fa22d7bbbc6d454513161f8c5

I wrote this quite a while ago, but shows how to use COM from Rust (including implementing your own objects) and implements some of the functionality needed by webrender.

@lygstate
Copy link

@lygstate lygstate commented Oct 12, 2016

Is this the sole blocker for msvc?

@llde
Copy link

@llde llde commented Oct 20, 2016

What about using RustType for font rendering?

bors-servo added a commit that referenced this issue Nov 10, 2016
Add support for DirectWrite font rendering on Windows

<!-- Please describe your changes on the following line: -->
This PR adds support for DirectWrite text rendering using a thin wrapper for dwrite, as well as similar functionality added to WebRender.  In doing so it removes the FreeType dep from the Windows build.

There is still work to be done here, but this is a good starting point for future cleanup and fixes.

---
<!-- 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
- [ ] `./mach test-tidy` does not report any errors
- [X] These changes fix #13371 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because they are already tested by other tests

<!-- 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/14153)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Nov 10, 2016
Add support for DirectWrite font rendering on Windows

<!-- Please describe your changes on the following line: -->
This PR adds support for DirectWrite text rendering using a thin wrapper for dwrite, as well as similar functionality added to WebRender.  In doing so it removes the FreeType dep from the Windows build.

There is still work to be done here, but this is a good starting point for future cleanup and fixes.

---
<!-- 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
- [ ] `./mach test-tidy` does not report any errors
- [X] These changes fix #13371 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because they are already tested by other tests

<!-- 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/14153)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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