mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
LibGfx/OpenType: Support cmaps with format Unicode
Some fonts only contain unicode tables. This makes them work.
This commit is contained in:
parent
54ab6fe5b9
commit
21ffb118af
|
@ -34,6 +34,16 @@ public:
|
|||
ManyToOneRange = 13,
|
||||
UnicodeVariationSequences = 14,
|
||||
};
|
||||
enum class UnicodeEncoding {
|
||||
DeprecatedUnicode1_0 = 0,
|
||||
DeprecatedUnicode1_1 = 1,
|
||||
DeprecatedISO10646 = 2,
|
||||
Unicode2_0_BMP_Only = 3,
|
||||
Unicode2_0_FullRepertoire = 4,
|
||||
UnicodeVariationSequences = 5, // "for use with subtable format 14"
|
||||
UnicodeFullRepertoire = 6, // "for use with subtable format 13"
|
||||
};
|
||||
|
||||
enum class WindowsEncoding {
|
||||
UnicodeBMP = 1,
|
||||
UnicodeFullRepertoire = 10,
|
||||
|
|
|
@ -236,7 +236,18 @@ ErrorOr<NonnullRefPtr<Font>> Font::try_load_from_offset(ReadonlyBytes buffer, u3
|
|||
/* NOTE: The encoding records are sorted first by platform ID, then by encoding ID.
|
||||
This means that the Windows platform will take precedence over Macintosh, which is
|
||||
usually what we want here. */
|
||||
if (platform.value() == Cmap::Subtable::Platform::Windows) {
|
||||
if (platform.value() == Cmap::Subtable::Platform::Unicode) {
|
||||
if (subtable.encoding_id() == (u16)Cmap::Subtable::UnicodeEncoding::Unicode2_0_FullRepertoire) {
|
||||
// "Encoding ID 3 should be used in conjunction with 'cmap' subtable formats 4 or 6."
|
||||
cmap.set_active_index(i);
|
||||
break;
|
||||
}
|
||||
if (subtable.encoding_id() == (u16)Cmap::Subtable::UnicodeEncoding::Unicode2_0_BMP_Only) {
|
||||
// "Encoding ID 4 should be used in conjunction with subtable formats 10 or 12."
|
||||
cmap.set_active_index(i);
|
||||
break;
|
||||
}
|
||||
} else if (platform.value() == Cmap::Subtable::Platform::Windows) {
|
||||
if (subtable.encoding_id() == (u16)Cmap::Subtable::WindowsEncoding::UnicodeFullRepertoire) {
|
||||
cmap.set_active_index(i);
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue