Skip to content

Commit

Permalink
LibGfx: Use to_underlying() to compare ValueFormat enum values
Browse files Browse the repository at this point in the history
This means we no longer do a bitwise and of a u16 and i16, which feels a
little sketchy.
  • Loading branch information
AtkinsSJ authored and awesomekling committed Nov 8, 2023
1 parent 74e5fff commit 4e944e6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Userland/Libraries/LibGfx/Font/OpenType/Tables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,21 +534,21 @@ Optional<i16> GPOS::glyph_kerning(u16 left_glyph_id, u16 right_glyph_id) const
{
auto read_value_record = [&](u16 value_format, FixedMemoryStream& stream) -> ValueRecord {
ValueRecord value_record;
if (value_format & static_cast<i16>(ValueFormat::X_PLACEMENT))
if (value_format & to_underlying(ValueFormat::X_PLACEMENT))
value_record.x_placement = stream.read_value<BigEndian<i16>>().release_value_but_fixme_should_propagate_errors();
if (value_format & static_cast<i16>(ValueFormat::Y_PLACEMENT))
if (value_format & to_underlying(ValueFormat::Y_PLACEMENT))
value_record.y_placement = stream.read_value<BigEndian<i16>>().release_value_but_fixme_should_propagate_errors();
if (value_format & static_cast<i16>(ValueFormat::X_ADVANCE))
if (value_format & to_underlying(ValueFormat::X_ADVANCE))
value_record.x_advance = stream.read_value<BigEndian<i16>>().release_value_but_fixme_should_propagate_errors();
if (value_format & static_cast<i16>(ValueFormat::Y_ADVANCE))
if (value_format & to_underlying(ValueFormat::Y_ADVANCE))
value_record.y_advance = stream.read_value<BigEndian<i16>>().release_value_but_fixme_should_propagate_errors();
if (value_format & static_cast<i16>(ValueFormat::X_PLACEMENT_DEVICE))
if (value_format & to_underlying(ValueFormat::X_PLACEMENT_DEVICE))
value_record.x_placement_device_offset = stream.read_value<Offset16>().release_value_but_fixme_should_propagate_errors();
if (value_format & static_cast<i16>(ValueFormat::Y_PLACEMENT_DEVICE))
if (value_format & to_underlying(ValueFormat::Y_PLACEMENT_DEVICE))
value_record.y_placement_device_offset = stream.read_value<Offset16>().release_value_but_fixme_should_propagate_errors();
if (value_format & static_cast<i16>(ValueFormat::X_ADVANCE_DEVICE))
if (value_format & to_underlying(ValueFormat::X_ADVANCE_DEVICE))
value_record.x_advance_device_offset = stream.read_value<Offset16>().release_value_but_fixme_should_propagate_errors();
if (value_format & static_cast<i16>(ValueFormat::Y_ADVANCE_DEVICE))
if (value_format & to_underlying(ValueFormat::Y_ADVANCE_DEVICE))
value_record.y_advance_device_offset = stream.read_value<Offset16>().release_value_but_fixme_should_propagate_errors();
return value_record;
};
Expand Down

0 comments on commit 4e944e6

Please sign in to comment.