diff --git a/Libraries/LibTTF/Cmap.cpp b/Libraries/LibTTF/Cmap.cpp index a1206d6969..7fb6deda64 100644 --- a/Libraries/LibTTF/Cmap.cpp +++ b/Libraries/LibTTF/Cmap.cpp @@ -90,8 +90,7 @@ Optional 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(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); } diff --git a/Libraries/LibTTF/Font.cpp b/Libraries/LibTTF/Font.cpp index 5ef910fbd3..5a1bde6145 100644 --- a/Libraries/LibTTF/Font.cpp +++ b/Libraries/LibTTF/Font.cpp @@ -271,7 +271,7 @@ RefPtr 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")) { diff --git a/Libraries/LibTTF/Glyf.cpp b/Libraries/LibTTF/Glyf.cpp index aa75a2e4e7..2bcaf669a5 100644 --- a/Libraries/LibTTF/Glyf.cpp +++ b/Libraries/LibTTF/Glyf.cpp @@ -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(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); }