mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 23:48:11 +00:00
LibGfx: Move MultiLocalizedUnicodeRawRecord to BinaryFormat.h
This commit is contained in:
parent
4e72a35398
commit
4a62cf35fc
2 changed files with 11 additions and 10 deletions
|
@ -130,4 +130,13 @@ struct CLUTHeader {
|
|||
};
|
||||
static_assert(AssertSize<CLUTHeader, 20>());
|
||||
|
||||
// ICC v4, 10.15 multiLocalizedUnicodeType
|
||||
struct MultiLocalizedUnicodeRawRecord {
|
||||
BigEndian<u16> language_code;
|
||||
BigEndian<u16> country_code;
|
||||
BigEndian<u32> string_length_in_bytes;
|
||||
BigEndian<u32> string_offset_in_bytes;
|
||||
};
|
||||
static_assert(AssertSize<MultiLocalizedUnicodeRawRecord, 12>());
|
||||
|
||||
}
|
||||
|
|
|
@ -686,7 +686,7 @@ ErrorOr<NonnullRefPtr<MultiLocalizedUnicodeTagData>> MultiLocalizedUnicodeTagDat
|
|||
// of each record. Any code that needs to access the nth record should determine the record’s offset by multiplying
|
||||
// n by the contents of this size field and adding 16. This minor extra effort allows for future expansion of the record
|
||||
// encoding, should the need arise, without having to define a new tag type."
|
||||
if (record_size < 12)
|
||||
if (record_size < sizeof(MultiLocalizedUnicodeRawRecord))
|
||||
return Error::from_string_literal("ICC::Profile: multiLocalizedUnicodeType record size too small");
|
||||
if (bytes.size() < 16 + number_of_records * record_size)
|
||||
return Error::from_string_literal("ICC::Profile: multiLocalizedUnicodeType not enough data for records");
|
||||
|
@ -699,17 +699,9 @@ ErrorOr<NonnullRefPtr<MultiLocalizedUnicodeTagData>> MultiLocalizedUnicodeTagDat
|
|||
// and should not be NULL terminated."
|
||||
auto& utf_16be_decoder = *TextCodec::decoder_for("utf-16be"sv);
|
||||
|
||||
struct RawRecord {
|
||||
BigEndian<u16> language_code;
|
||||
BigEndian<u16> country_code;
|
||||
BigEndian<u32> string_length_in_bytes;
|
||||
BigEndian<u32> string_offset_in_bytes;
|
||||
};
|
||||
static_assert(AssertSize<RawRecord, 12>());
|
||||
|
||||
for (u32 i = 0; i < number_of_records; ++i) {
|
||||
size_t offset = 16 + i * record_size;
|
||||
RawRecord record = *bit_cast<RawRecord const*>(bytes.data() + offset);
|
||||
auto record = *bit_cast<MultiLocalizedUnicodeRawRecord const*>(bytes.data() + offset);
|
||||
|
||||
records[i].iso_639_1_language_code = record.language_code;
|
||||
records[i].iso_3166_1_country_code = record.country_code;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue