1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:27:45 +00:00

LibGfx: Remove bit casting in OpenType CBDT table after construction

This commit is contained in:
Sam Atkins 2023-11-02 12:49:26 +00:00 committed by Andreas Kling
parent 4e944e676b
commit 21f2f09df4
2 changed files with 6 additions and 3 deletions

View file

@ -506,7 +506,8 @@ ErrorOr<CBDT> CBDT::from_slice(ReadonlyBytes slice)
{ {
if (slice.size() < sizeof(CbdtHeader)) if (slice.size() < sizeof(CbdtHeader))
return Error::from_string_literal("CBDT table too small"); return Error::from_string_literal("CBDT table too small");
return CBDT { slice }; auto const& header = *bit_cast<CbdtHeader*>(slice.data());
return CBDT { slice, header };
} }
ErrorOr<GPOS> GPOS::from_slice(ReadonlyBytes slice) ErrorOr<GPOS> GPOS::from_slice(ReadonlyBytes slice)

View file

@ -586,15 +586,17 @@ public:
static ErrorOr<CBDT> from_slice(ReadonlyBytes); static ErrorOr<CBDT> from_slice(ReadonlyBytes);
ReadonlyBytes bytes() const { return m_slice; } ReadonlyBytes bytes() const { return m_slice; }
CbdtHeader const& header() const { return *bit_cast<CbdtHeader const*>(m_slice.data()); } CbdtHeader const& header() const { return m_header; }
private: private:
explicit CBDT(ReadonlyBytes slice) explicit CBDT(ReadonlyBytes slice, CbdtHeader const& header)
: m_slice(slice) : m_slice(slice)
, m_header(header)
{ {
} }
ReadonlyBytes m_slice; ReadonlyBytes m_slice;
CbdtHeader const& m_header;
}; };
// https://learn.microsoft.com/en-us/typography/opentype/spec/chapter2#feature-list-table // https://learn.microsoft.com/en-us/typography/opentype/spec/chapter2#feature-list-table