Skip to content

add support for creating variation fonts #20

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

Merged
merged 2 commits into from
Sep 21, 2018

Conversation

lsalzman
Copy link

This is necessary to fix downstream Gecko bug https://bugzilla.mozilla.org/show_bug.cgi?id=1441323

src/font_face.rs Outdated

pub fn has_variations(&self) -> bool {
unsafe {
let face5: Option<ComPtr<IDWriteFontFace5>> = (*self.native.get()).query_interface(&IDWriteFontFace5::uuidof());
Copy link
Member

Choose a reason for hiding this comment

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

nit: can just match on it

&self,
simulations: DWRITE_FONT_SIMULATIONS,
axis_values: &[DWRITE_FONT_AXIS_VALUE],
) -> Option<FontFace> {
Copy link
Member

Choose a reason for hiding this comment

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

can we have some sort of an error code here (and return Result)?

src/font_face.rs Outdated
axis_values: &[DWRITE_FONT_AXIS_VALUE],
) -> Option<FontFace> {
unsafe {
let face5: Option<ComPtr<IDWriteFontFace5>> = (*self.native.get()).query_interface(&IDWriteFontFace5::uuidof());
Copy link
Member

Choose a reason for hiding this comment

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

is this how extension methods are discovered in dwrote? I wonder if the query_interface would be better to call at the construction site and just cache this ComPtr<IDWriteFontFace5> somewhere.

@lsalzman
Copy link
Author

I added support for caching the FontFace5 on demand - I don't want to impose the cost of querying it on all fonts, just the ones that need it for variations.

As for errors, the errors are mostly dealt with ahead of time in Gecko, and we just need a pass or fail here with Option being what is most consistent with dwrote. This is a niche case where I do not believe having to construct a new error type just for it would add any value, since it would require decoding HRESULTs and other nastiness. And I don't know there's anything we can do with the HRESULT either.

@kvark
Copy link
Member

kvark commented Sep 21, 2018

I don't want to impose the cost of querying it on all fonts, just the ones that need it for variations.

Is it really going to show up in any profiles though? I imagine we do hundreds of COM calls on a font, so querying the interface at load time shouldn't be a concern.

@lsalzman
Copy link
Author

lsalzman commented Sep 21, 2018 via email

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

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

Would be great if somebody from regular reviewers would also take a look before merging.

@kvark
Copy link
Member

kvark commented Sep 21, 2018

hmm, doesn't look like there are permanent reviewers
@bors-servo r+

@bors-servo
Copy link

📌 Commit 8dbd988 has been approved by kvark

@bors-servo
Copy link

⌛ Testing commit 8dbd988 with merge 2b012d3...

bors-servo pushed a commit that referenced this pull request Sep 21, 2018
add support for creating variation fonts

This is necessary to fix downstream Gecko bug https://bugzilla.mozilla.org/show_bug.cgi?id=1441323
@bors-servo
Copy link

☀️ Test successful - status-appveyor
Approved by: kvark
Pushing 2b012d3 to master...

@bors-servo bors-servo merged commit 8dbd988 into servo:master Sep 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants