-
Notifications
You must be signed in to change notification settings - Fork 54
Add Tag::into_u32 method
#1630
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
base: main
Are you sure you want to change the base?
Add Tag::into_u32 method
#1630
Conversation
Signed-off-by: Nico Burns <nico@nicoburns.com>
dfrg
left a comment
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.
LGTM with a couple changes requested.
| Self::from_be_bytes(src.to_be_bytes()) | ||
| } | ||
|
|
||
| /// Convert a `Tag` into a big-endian `u32` |
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.
| /// Convert a `Tag` into a big-endian `u32` | |
| /// Convert a `Tag` into a big-endian `u32`. |
| /// | ||
| /// This is provided as a convenience method for interop with code that | ||
| /// stores tags as big-endian u32s. | ||
| pub const fn into_u32(self) -> u32 { |
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.
I know a conversion consuming self should have an into_ prefix but the vast majority of the methods in this crate use to_ so I'd prefer to_u32 here for consistency.
|
Holding off on this until I can determine whether there a consistent byte order used to represent opentype tags as u32. It is looking possible that macOS and Windows both use u32 but with swapped byte order. |
Please add one that reads it as big-endian, like the rest of the most of the font. I think you are right that Windows uses the opposite order. |
Motivation is exactly the same as the
from_u32method: it allows interop with systems that represent tag in this format (HarfBuzz, CoreText, etc).