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

LibTTF: Use ByteBuffer::copy() since wrap() was removed

This commit is contained in:
Stephan Unverwerth 2020-12-29 16:12:19 +01:00 committed by Andreas Kling
parent 222b7f6c87
commit 9689d914b4
3 changed files with 3 additions and 5 deletions

View file

@ -90,8 +90,7 @@ Optional<Cmap::Subtable> Cmap::subtable(u32 index) const
u16 encoding_id = be_u16(m_slice.offset_pointer(record_offset + (u32)Offsets::EncodingRecord_EncodingID));
u32 subtable_offset = be_u32(m_slice.offset_pointer(record_offset + (u32)Offsets::EncodingRecord_Offset));
ASSERT(subtable_offset < m_slice.size());
// HACK: added const_cast because of new ByteBuffer::wrap behavior, should probably find another workaround
auto subtable_slice = ByteBuffer::wrap(const_cast<u8*>(m_slice.offset_pointer(subtable_offset)), m_slice.size() - subtable_offset);
auto subtable_slice = ByteBuffer::copy(m_slice.offset_pointer(subtable_offset), m_slice.size() - subtable_offset);
return Subtable(subtable_slice, platform_id, encoding_id);
}

View file

@ -271,7 +271,7 @@ RefPtr<Font> Font::load_from_offset(ByteBuffer&& buffer, u32 offset)
dbg() << "Font file too small";
return nullptr;
}
auto buffer_here = ByteBuffer::wrap(buffer.offset_pointer(table_offset), table_length);
auto buffer_here = ByteBuffer::copy(buffer.offset_pointer(table_offset), table_length);
// Get the table offsets we need.
if (tag == tag_from_str("head")) {

View file

@ -502,8 +502,7 @@ Glyf::Glyph Glyf::glyph(u32 offset) const
i16 ymin = be_i16(m_slice.offset_pointer(offset + (u32)Offsets::YMin));
i16 xmax = be_i16(m_slice.offset_pointer(offset + (u32)Offsets::XMax));
i16 ymax = be_i16(m_slice.offset_pointer(offset + (u32)Offsets::YMax));
// HACK: added const_cast because of new wrap behavior
auto slice = ByteBuffer::wrap(const_cast<u8*>(m_slice.offset_pointer(offset + (u32)Sizes::GlyphHeader)), m_slice.size() - offset - (u32)Sizes::GlyphHeader);
auto slice = ByteBuffer::copy(m_slice.offset_pointer(offset + (u32)Sizes::GlyphHeader), m_slice.size() - offset - (u32)Sizes::GlyphHeader);
return Glyph(slice, xmin, ymin, xmax, ymax, num_contours);
}