diff --git a/Userland/Libraries/LibGfx/Font/OpenType/Tables.cpp b/Userland/Libraries/LibGfx/Font/OpenType/Tables.cpp index 706d8dc08f..2b2b4c471c 100644 --- a/Userland/Libraries/LibGfx/Font/OpenType/Tables.cpp +++ b/Userland/Libraries/LibGfx/Font/OpenType/Tables.cpp @@ -124,15 +124,15 @@ ErrorOr Maxp::from_slice(ReadonlyBytes slice) Version16Dot16 const& version = *bit_cast(slice.data()); if (version.major == 0 && version.minor == 5) { - if (slice.size() < sizeof(MaximumProfileVersion0_5)) + if (slice.size() < sizeof(Version0_5)) return Error::from_string_literal("Could not load Maxp: Not enough data"); - return Maxp(bit_cast(slice.data())); + return Maxp(bit_cast(slice.data())); } if (version.major == 1 && version.minor == 0) { - if (slice.size() < sizeof(MaximumProfileVersion1_0)) + if (slice.size() < sizeof(Version1_0)) return Error::from_string_literal("Could not load Maxp: Not enough data"); - return Maxp(bit_cast(slice.data())); + return Maxp(bit_cast(slice.data())); } return Error::from_string_literal("Could not load Maxp: Unrecognized version"); diff --git a/Userland/Libraries/LibGfx/Font/OpenType/Tables.h b/Userland/Libraries/LibGfx/Font/OpenType/Tables.h index 57d3696e90..535f6047c1 100644 --- a/Userland/Libraries/LibGfx/Font/OpenType/Tables.h +++ b/Userland/Libraries/LibGfx/Font/OpenType/Tables.h @@ -176,15 +176,13 @@ public: u16 num_glyphs() const; private: - struct [[gnu::packed]] MaximumProfileVersion0_5 { + struct [[gnu::packed]] Version0_5 { Version16Dot16 version; BigEndian num_glyphs; }; - static_assert(AssertSize()); + static_assert(AssertSize()); - struct [[gnu::packed]] MaximumProfileVersion1_0 { - Version16Dot16 version; - BigEndian num_glyphs; + struct [[gnu::packed]] Version1_0 : Version0_5 { BigEndian max_points; BigEndian max_contours; BigEndian max_composite_points; @@ -199,16 +197,16 @@ private: BigEndian max_component_elements; BigEndian max_component_depths; }; - static_assert(AssertSize()); + static_assert(AssertSize()); - Maxp(Variant data) + Maxp(Variant data) : m_data(move(data)) { VERIFY(m_data.visit([](auto const* any) { return any != nullptr; })); } // NOTE: Whichever pointer is present is non-null, but Variant can't contain references. - Variant m_data; + Variant m_data; }; struct GlyphHorizontalMetrics { @@ -325,15 +323,13 @@ private: }; static_assert(AssertSize()); - struct [[gnu::packed]] Version1 { - Version0 version0; + struct [[gnu::packed]] Version1 : Version0 { BigEndian ul_code_page_range1; BigEndian ul_code_page_range2; }; static_assert(AssertSize()); - struct [[gnu::packed]] Version2 { - Version1 version1; + struct [[gnu::packed]] Version2 : Version1 { BigEndian sx_height; BigEndian s_cap_height; BigEndian us_default_char; @@ -698,14 +694,14 @@ static_assert(AssertSize()); class GPOS { public: // https://learn.microsoft.com/en-us/typography/opentype/spec/gpos#gpos-header - struct [[gnu::packed]] GPOSHeader { + struct [[gnu::packed]] Version1_0 { BigEndian major_version; BigEndian minor_version; Offset16 script_list_offset; Offset16 feature_list_offset; Offset16 lookup_list_offset; }; - static_assert(AssertSize()); + static_assert(AssertSize()); // https://learn.microsoft.com/en-us/typography/opentype/spec/gpos#pair-adjustment-positioning-format-1-adjustments-for-glyph-pairs struct [[gnu::packed]] PairPosFormat1 { @@ -755,7 +751,7 @@ public: Y_ADVANCE_DEVICE = 0x0080, }; - GPOSHeader const& header() const { return *bit_cast(m_slice.data()); } + Version1_0 const& header() const { return *bit_cast(m_slice.data()); } Optional glyph_kerning(u16 left_glyph_id, u16 right_glyph_id) const;