mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:57:35 +00:00
LibGfx: TrueTypeFont cleanup
No functional changes.
This commit is contained in:
parent
b17fb76ace
commit
c0513999d6
2 changed files with 8 additions and 10 deletions
|
@ -121,13 +121,13 @@ u32 Cmap::Subtable::glyph_id_for_code_point_table_12(u32 code_point) const
|
|||
VERIFY(m_slice.size() >= (u32)Table12Sizes::Header + (u32)Table12Sizes::Record * num_groups);
|
||||
for (u32 offset = 0; offset < num_groups * (u32)Table12Sizes::Record; offset += (u32)Table12Sizes::Record) {
|
||||
u32 start_code_point = be_u32(m_slice.offset_pointer((u32)Table12Offsets::Record_StartCode + offset));
|
||||
if (code_point < start_code_point) {
|
||||
if (code_point < start_code_point)
|
||||
break;
|
||||
}
|
||||
|
||||
u32 end_code_point = be_u32(m_slice.offset_pointer((u32)Table12Offsets::Record_EndCode + offset));
|
||||
if (code_point > end_code_point) {
|
||||
if (code_point > end_code_point)
|
||||
continue;
|
||||
}
|
||||
|
||||
u32 glyph_offset = be_u32(m_slice.offset_pointer((u32)Table12Offsets::Record_StartGlyph + offset));
|
||||
return code_point - start_code_point + glyph_offset;
|
||||
}
|
||||
|
@ -137,18 +137,17 @@ u32 Cmap::Subtable::glyph_id_for_code_point_table_12(u32 code_point) const
|
|||
u32 Cmap::glyph_id_for_code_point(u32 code_point) const
|
||||
{
|
||||
auto opt_subtable = subtable(m_active_index);
|
||||
if (!opt_subtable.has_value()) {
|
||||
if (!opt_subtable.has_value())
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto subtable = opt_subtable.value();
|
||||
return subtable.glyph_id_for_code_point(code_point);
|
||||
}
|
||||
|
||||
Optional<Cmap> Cmap::from_slice(ReadonlyBytes slice)
|
||||
{
|
||||
if (slice.size() < (size_t)Sizes::TableHeader) {
|
||||
if (slice.size() < (size_t)Sizes::TableHeader)
|
||||
return {};
|
||||
}
|
||||
return Cmap(slice);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <AK/Try.h>
|
||||
#include <AK/Utf32View.h>
|
||||
#include <AK/Utf8View.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibGfx/TrueTypeFont/Cmap.h>
|
||||
#include <LibGfx/TrueTypeFont/Font.h>
|
||||
|
@ -429,7 +428,7 @@ ErrorOr<NonnullRefPtr<Font>> Font::try_load_from_offset(ReadonlyBytes buffer, u3
|
|||
u32 table_length = be_u32(buffer.offset_pointer(record_offset + (u32)Offsets::TableRecord_Length));
|
||||
|
||||
if (Checked<u32>::addition_would_overflow(table_offset, table_length))
|
||||
return Error::from_string_literal("Invalid table offset/length in font."sv);
|
||||
return Error::from_string_literal("Invalid table offset or length in font"sv);
|
||||
|
||||
if (buffer.size() < table_offset + table_length)
|
||||
return Error::from_string_literal("Font file too small"sv);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue