summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/Font
diff options
context:
space:
mode:
authorJulian Offenhäuser <offenhaeuser@protonmail.com>2023-01-13 17:05:13 +0100
committerAndreas Kling <kling@serenityos.org>2023-01-27 10:59:52 +0100
commit22b1e1076ace9e094feb0e152de1bdeb21153bb8 (patch)
treeea0053e341b8356bc0c0a0f87173bdfa5419b7dc /Userland/Libraries/LibGfx/Font
parentddbdeb3ca0fe2d84e6c28f8f287f6a24f365c884 (diff)
downloadserenity-22b1e1076ace9e094feb0e152de1bdeb21153bb8.zip
LibGfx: Make OTF prefer Cmap tables of the Windows platform again
As the different Cmap encoding records are guaranteed to be sorted by their platform ID, we would previously prefer the Macintosh platform because of its lower ID value. However, this platform is split up into a lot of encoding formats for different languages, and usually only English is included. This meant that we could not handle most unicode characters anymore. The Windows platform now takes precedence again, as it can handle arbitrary code points in its supported encodings. This solution is still far from perfect, but it makes this regression disappear for now.
Diffstat (limited to 'Userland/Libraries/LibGfx/Font')
-rw-r--r--Userland/Libraries/LibGfx/Font/OpenType/Font.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGfx/Font/OpenType/Font.cpp b/Userland/Libraries/LibGfx/Font/OpenType/Font.cpp
index 8095721ba3..eb5dbf44e6 100644
--- a/Userland/Libraries/LibGfx/Font/OpenType/Font.cpp
+++ b/Userland/Libraries/LibGfx/Font/OpenType/Font.cpp
@@ -517,6 +517,9 @@ ErrorOr<NonnullRefPtr<Font>> Font::try_load_from_offset(ReadonlyBytes buffer, u3
if (!platform.has_value())
return Error::from_string_literal("Invalid Platform ID");
+ /* 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 (subtable.encoding_id() == (u16)Cmap::Subtable::WindowsEncoding::UnicodeFullRepertoire) {
cmap.set_active_index(i);
@@ -528,7 +531,6 @@ ErrorOr<NonnullRefPtr<Font>> Font::try_load_from_offset(ReadonlyBytes buffer, u3
}
} else if (platform.value() == Cmap::Subtable::Platform::Macintosh) {
cmap.set_active_index(i);
- break;
}
}