LibGfx/ICC: Add another version of the Apple P3 profile to quirks list

Improves appearance of page 6 of
https://fredrikbk.com/publications/copy-and-patch.pdf
This commit is contained in:
Nico Weber 2024-02-20 10:51:56 -05:00 committed by Andreas Kling
parent 0160f737e2
commit 275542aaf8
Notes: sideshowbarker 2024-07-17 04:01:41 +09:00

View file

@ -760,6 +760,10 @@ ErrorOr<void> Profile::check_tag_types()
// (The macOS 13.1 /System/Library/ColorSync/Profiles/Display\ P3.icc file no longer has this quirk.)
static constexpr Crypto::Hash::MD5::DigestType apple_p3_2015_id = { 0xe5, 0xbb, 0x0e, 0x98, 0x67, 0xbd, 0x46, 0xcd, 0x4b, 0xbe, 0x44, 0x6e, 0xbd, 0x1b, 0x75, 0x98 };
// Profile ID of the "Display P3" profile in object 881 in https://fredrikbk.com/publications/copy-and-patch.pdf
// (The macOS 13.1 /System/Library/ColorSync/Profiles/Display\ P3.icc file no longer has this quirk.)
static constexpr Crypto::Hash::MD5::DigestType apple_p3_2017_id = { 0xca, 0x1a, 0x95, 0x82, 0x25, 0x7f, 0x10, 0x4d, 0x38, 0x99, 0x13, 0xd5, 0xd1, 0xea, 0x15, 0x82 };
auto has_type = [&](auto tag, std::initializer_list<TagTypeSignature> types, std::initializer_list<TagTypeSignature> v4_types) {
if (auto type = m_tag_table.get(tag); type.has_value()) {
auto type_matches = [&](auto wanted_type) { return type.value()->type() == wanted_type; };
@ -914,7 +918,7 @@ ErrorOr<void> Profile::check_tag_types()
// The v4 spec requires multiLocalizedUnicodeType for this, but I'm aware of a single file
// that still uses the v2 'text' type here: /System/Library/ColorSync/Profiles/ITU-2020.icc on macOS 13.1.
// https://openradar.appspot.com/radar?id=5529765549178880
bool has_v2_cprt_type_in_v4_file_quirk = id() == apple_itu_2020_id || id() == apple_p3_2015_id;
bool has_v2_cprt_type_in_v4_file_quirk = id() == apple_itu_2020_id || id() == apple_p3_2015_id || id() == apple_p3_2017_id;
if (is_v4() && type.value()->type() != MultiLocalizedUnicodeTagData::Type && (!has_v2_cprt_type_in_v4_file_quirk || type.value()->type() != TextTagData::Type))
return Error::from_string_literal("ICC::Profile: copyrightTag has unexpected v4 type");
if (is_v2() && type.value()->type() != TextTagData::Type)
@ -1103,7 +1107,7 @@ ErrorOr<void> Profile::check_tag_types()
// The v4 spec requires multiLocalizedUnicodeType for this, but I'm aware of a single file
// that still uses the v2 'desc' type here: /System/Library/ColorSync/Profiles/ITU-2020.icc on macOS 13.1.
// https://openradar.appspot.com/radar?id=5529765549178880
bool has_v2_desc_type_in_v4_file_quirk = id() == apple_itu_2020_id || id() == apple_p3_2015_id;
bool has_v2_desc_type_in_v4_file_quirk = id() == apple_itu_2020_id || id() == apple_p3_2015_id || id() == apple_p3_2017_id;
if (is_v4() && type.value()->type() != MultiLocalizedUnicodeTagData::Type && (!has_v2_desc_type_in_v4_file_quirk || type.value()->type() != TextDescriptionTagData::Type))
return Error::from_string_literal("ICC::Profile: profileDescriptionTag has unexpected v4 type");
if (is_v2() && type.value()->type() != TextDescriptionTagData::Type)