Repository navigation
Add support for the STAT table. - #166
Conversation
|
Thanks! Looks pretty good to me. |
|
It looks like we can update the table in the readme. |
|
@yisibl good call! |
|
Ok, 1.51 compatibility is broken, but we're good otherwise. |
|
Ok – I've rolled up a few other minor changes. I've also set up a few functions to abstract over getting the value and flags. If that seems in scope for this PR I can push those as well. |
Sure, let's take a look. |
|
I'm not sure how far down the rabbit hole it's worth going with providing a higher level API. What I've exposed so far should be useful for both dynamic (e.g. For instance: fn is_stat_italic() -> bool {
if let Some(stat) = face.tables().stat {
if let Some(subtable) = stat.subtable_for_axis(Tag::from_bytes(b"ital"), None) {
if subtable.contains(Fixed(1.0)) {
return true;
}
}
}
return false
}fn is_bold() -> bool {
if let Some(stat) = face.tables().stat {
if let Some(subtable) = stat.subtable_for_axis(Tag::from_bytes(b"wght"), None) {
if let Some(value) = subtable.value() {
let named_weight = Weight::from(value.0 as u16);
if named_weight == Weight::Bold {
return true;
}
}
}
}
return false
} |
|
If you think it's good enough I'm fine with merging it. |
|
Works for me. |
https://learn.microsoft.com/en-us/typography/opentype/spec/stat
This PR adds support for parsing the
STATtable and its related data types. It's a pretty simple table but as in #87 the issues of testing and API design deserve some consideration.Additionally, should this be placed behind a feature?