-
Notifications
You must be signed in to change notification settings - Fork 24
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
Conversation
Add implementations for the "managing the graphics state" group of TrueType instructions. See https://learn.microsoft.com/en-us/typography/opentype/spec/tt_instructions#managing-the-graphics-state
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
self.graphics_state.zp0 = n.try_into()?; | ||
Ok(()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could just,
self.graphics_state.zp0 = n.try_into()?; | |
Ok(()) | |
self.graphics_state.zp0 = n.try_into() |
I imagine?
There was a problem hiding this comment.
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<(), _>
:(
if !(1..=3).contains(&selector) || (value != 0 && value != selector_flag) { | ||
return Ok(()); | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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).