Use Tag type from font-types crate to represent opentype tags (#38870)

The `font-types` crate is the tiny type-only base crate of `fontations`.
This uses a strongly typed representation of open type tags, and allows
us to remove our custom macro for creating them.

---------

Signed-off-by: Nico Burns <nico@nicoburns.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Nico Burns 2025-08-23 21:32:47 +01:00 committed by GitHub
parent 0a8146143a
commit 1fc857865f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 31 additions and 57 deletions

View file

@ -26,7 +26,7 @@ use winapi::shared::minwindef::{BOOL, FALSE};
use super::font_list::LocalFontIdentifier;
use crate::{
FontData, FontIdentifier, FontMetrics, FontTableMethods, FontTableTag, FontTemplateDescriptor,
FontData, FontIdentifier, FontMetrics, FontTableMethods, FontTemplateDescriptor,
FractionalPixel, GlyphId, PlatformFontMethods,
};
@ -282,12 +282,12 @@ impl PlatformFontMethods for PlatformFont {
metrics
}
fn table_for_tag(&self, tag: FontTableTag) -> Option<FontTable> {
fn table_for_tag(&self, tag: Tag) -> Option<FontTable> {
// dwrote (and presumably the Windows APIs) accept a reversed version of the table
// tag bytes, which means that `u32::swap_bytes` must be called here in order to
// use a byte order compatible with the rest of Servo.
self.face
.font_table(u32::swap_bytes(tag))
.font_table(u32::from_be_bytes(tag.to_be_bytes()).swap_bytes())
.ok()
.flatten()
.map(|bytes| FontTable { data: bytes })