mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-07 00:19:27 +00:00
LibGfx: Remove bit casting in OpenType Hhea table after construction
This commit is contained in:
parent
dcbe302f83
commit
e4b3ee09e2
|
@ -87,32 +87,33 @@ ErrorOr<Hhea> Hhea::from_slice(ReadonlyBytes slice)
|
|||
if (slice.size() < sizeof(HorizontalHeaderTable))
|
||||
return Error::from_string_literal("Could not load Hhea: Not enough data");
|
||||
|
||||
return Hhea(slice);
|
||||
auto const& horizontal_header_table = *bit_cast<HorizontalHeaderTable const*>(slice.data());
|
||||
return Hhea(horizontal_header_table);
|
||||
}
|
||||
|
||||
i16 Hhea::ascender() const
|
||||
{
|
||||
return header().ascender;
|
||||
return m_data.ascender;
|
||||
}
|
||||
|
||||
i16 Hhea::descender() const
|
||||
{
|
||||
return header().descender;
|
||||
return m_data.descender;
|
||||
}
|
||||
|
||||
i16 Hhea::line_gap() const
|
||||
{
|
||||
return header().line_gap;
|
||||
return m_data.line_gap;
|
||||
}
|
||||
|
||||
u16 Hhea::advance_width_max() const
|
||||
{
|
||||
return header().advance_width_max;
|
||||
return m_data.advance_width_max;
|
||||
}
|
||||
|
||||
u16 Hhea::number_of_h_metrics() const
|
||||
{
|
||||
return header().number_of_h_metrics;
|
||||
return m_data.number_of_h_metrics;
|
||||
}
|
||||
|
||||
ErrorOr<Maxp> Maxp::from_slice(ReadonlyBytes slice)
|
||||
|
|
|
@ -159,14 +159,12 @@ private:
|
|||
};
|
||||
static_assert(AssertSize<HorizontalHeaderTable, 36>());
|
||||
|
||||
HorizontalHeaderTable const& header() const { return *bit_cast<HorizontalHeaderTable const*>(m_slice.data()); }
|
||||
|
||||
Hhea(ReadonlyBytes slice)
|
||||
: m_slice(slice)
|
||||
Hhea(HorizontalHeaderTable const& horizontal_header_table)
|
||||
: m_data(horizontal_header_table)
|
||||
{
|
||||
}
|
||||
|
||||
ReadonlyBytes m_slice;
|
||||
HorizontalHeaderTable const& m_data;
|
||||
};
|
||||
|
||||
// https://learn.microsoft.com/en-us/typography/opentype/spec/maxp
|
||||
|
|
Loading…
Reference in a new issue