summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorJulian Offenhäuser <offenhaeuser@protonmail.com>2023-03-24 22:28:57 +0100
committerAndrew Kaster <andrewdkaster@gmail.com>2023-03-25 16:27:30 -0600
commitbdd5f36121701c79522ffd617a4ae64f172285d8 (patch)
tree86d7a1e8faa18780570e0b0d8b2b5796e1b4574c /Userland/Libraries
parent5deac3a7f509d98b9c936e37272fb0605daffba3 (diff)
downloadserenity-bdd5f36121701c79522ffd617a4ae64f172285d8.zip
LibPDF: Load replacements for TrueTypeFonts without an embedded font
This previously only happened for Type 1 fonts.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibPDF/Fonts/TrueTypeFont.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/Userland/Libraries/LibPDF/Fonts/TrueTypeFont.cpp b/Userland/Libraries/LibPDF/Fonts/TrueTypeFont.cpp
index a35680bd51..48772a58aa 100644
--- a/Userland/Libraries/LibPDF/Fonts/TrueTypeFont.cpp
+++ b/Userland/Libraries/LibPDF/Fonts/TrueTypeFont.cpp
@@ -17,6 +17,7 @@ PDFErrorOr<void> TrueTypeFont::initialize(Document* document, NonnullRefPtr<Dict
{
TRY(SimpleFont::initialize(document, dict, font_size));
+ // If there's an embedded font program we use that; otherwise we try to find a replacement font
if (dict->contains(CommonNames::FontDescriptor)) {
auto descriptor = MUST(dict->get_dict(document, CommonNames::FontDescriptor));
if (descriptor->contains(CommonNames::FontFile2)) {
@@ -26,7 +27,11 @@ PDFErrorOr<void> TrueTypeFont::initialize(Document* document, NonnullRefPtr<Dict
m_font = adopt_ref(*new Gfx::ScaledFont(*ttf_font, point_size, point_size));
}
}
+ if (!m_font) {
+ m_font = TRY(replacement_for(base_font_name().to_lowercase(), font_size));
+ }
+ VERIFY(m_font);
return {};
}