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

[skrifa] tthint: managing the graphics state #769

Merged
merged 4 commits into from
Feb 5, 2024
Merged

[skrifa] tthint: managing the graphics state #769

merged 4 commits into from
Feb 5, 2024

Conversation

dfrg
Copy link
Member

@dfrg dfrg commented Feb 5, 2024

Add implementations for the "managing the graphics state" group of TrueType instructions (https://learn.microsoft.com/en-us/typography/opentype/spec/tt_instructions#managing-the-graphics-state).

Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

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

🚢

//!
//! See <https://learn.microsoft.com/en-us/typography/opentype/spec/tt_instructions#managing-the-graphics-state>

// 45 instructions
Copy link
Member

Choose a reason for hiding this comment

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

maybe this can be part of the mod docs?

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense. I'll update the other modules as well.

Comment on lines +281 to +282
self.graphics_state.zp0 = n.try_into()?;
Ok(())
Copy link
Member

Choose a reason for hiding this comment

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

could just,

Suggested change
self.graphics_state.zp0 = n.try_into()?;
Ok(())
self.graphics_state.zp0 = n.try_into()

I imagine?

Copy link
Member Author

Choose a reason for hiding this comment

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

This ends up with a return type of () while the function expects Result<(), _> :(

Comment on lines +560 to +562
if !(1..=3).contains(&selector) || (value != 0 && value != selector_flag) {
return Ok(());
}
Copy link
Member

Choose a reason for hiding this comment

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

what does it mean if the selector is out of this range? Is that an expected condition?

Copy link
Member Author

Choose a reason for hiding this comment

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

Short answer is that we just ignore it.

The long answer is that FreeType has a "pedantic" mode that would fail here but I've never seen it enabled in practice because it breaks real fonts 🤷

This is something I'd like to spend more time investigating in the future... what I'd like to see is a run of the hinter with full error checking and then fall back to an unhinted glyph if it fails. I've also seen real world font bugs where running FT in non-pedantic mode leads to actual visual artifacts.

For now though, we stick with the status quo, for better or worse.

@dfrg dfrg merged commit 33d5533 into main Feb 5, 2024
9 checks passed
@dfrg dfrg deleted the tt-gs-ins branch February 5, 2024 17:30
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.

2 participants