LibPDF: Use more appropriate standard 14 replacement fonts

The mapping of standard font to replacement now looks like this:

Times New Roman -> Liberation Serif
Courier -> Liberation Mono
Helvetica, Arial -> Liberation Sans
This commit is contained in:
Julian Offenhäuser 2023-02-09 14:15:46 +01:00 committed by Andreas Kling
parent d470df1c6a
commit 152a8c5c43
Notes: sideshowbarker 2024-07-17 10:16:43 +09:00

View file

@ -89,8 +89,17 @@ PDFErrorOr<NonnullRefPtr<PDFFont>> PDFFont::create(Document* document, NonnullRe
Tuple<DeprecatedString, DeprecatedString> PDFFont::replacement_for_standard_latin_font(StringView name)
{
bool is_bold = name.contains("bold"sv);
bool is_italic = name.contains("italic"sv);
bool is_bold = name.contains("bold"sv, CaseSensitivity::CaseInsensitive);
bool is_italic = name.contains("italic"sv, CaseSensitivity::CaseInsensitive);
DeprecatedString font_family;
if (name.contains("times"sv, CaseSensitivity::CaseInsensitive)) {
font_family = "Liberation Serif";
} else if (name.contains("courier"sv, CaseSensitivity::CaseInsensitive)) {
font_family = "Liberation Mono";
} else {
font_family = "Liberation Sans";
}
DeprecatedString font_variant;
@ -104,7 +113,7 @@ Tuple<DeprecatedString, DeprecatedString> PDFFont::replacement_for_standard_lati
font_variant = "Regular";
}
return { "Liberation Serif", font_variant };
return { font_family, font_variant };
}
}