mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 09:49:15 +03:00
LibPDF: Record base font name read from document
This will be useful for debugging, or if we later on want to show all the fonts found in the document in an organised manner.
This commit is contained in:
parent
2552399bcd
commit
bfeca4ebb3
Notes:
sideshowbarker
2024-07-17 01:16:24 +09:00
Author: https://github.com/rtobar Commit: https://github.com/SerenityOS/serenity/commit/bfeca4ebb3 Pull-request: https://github.com/SerenityOS/serenity/pull/17082
@ -33,9 +33,9 @@ static bool is_standard_latin_font(DeprecatedFlyString const& font)
|
||||
|
||||
PDFErrorOr<void> PDFFont::CommonData::load_from_dict(Document* document, NonnullRefPtr<DictObject> dict, float font_size)
|
||||
{
|
||||
auto base_font = TRY(dict->get_name(document, CommonNames::BaseFont))->name();
|
||||
if ((is_standard_font = is_standard_latin_font(base_font))) {
|
||||
auto replacement = replacement_for_standard_latin_font(base_font.to_lowercase());
|
||||
base_font_name = TRY(dict->get_name(document, CommonNames::BaseFont))->name();
|
||||
if ((is_standard_font = is_standard_latin_font(base_font_name))) {
|
||||
auto replacement = replacement_for_standard_latin_font(base_font_name.to_lowercase());
|
||||
font = Gfx::FontDatabase::the().get(replacement.get<0>(), replacement.get<1>(), font_size);
|
||||
VERIFY(font);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ public:
|
||||
|
||||
// This is used both by Type 1 and TrueType fonts.
|
||||
struct CommonData {
|
||||
DeprecatedFlyString base_font_name;
|
||||
RefPtr<Gfx::Font> font;
|
||||
RefPtr<StreamObject> to_unicode;
|
||||
RefPtr<Encoding> encoding;
|
||||
@ -45,6 +46,7 @@ public:
|
||||
|
||||
virtual bool is_standard_font() const { return m_is_standard_font; }
|
||||
virtual Type type() const = 0;
|
||||
virtual DeprecatedFlyString base_font_name() const = 0;
|
||||
|
||||
protected:
|
||||
static Tuple<DeprecatedString, DeprecatedString> replacement_for_standard_latin_font(StringView);
|
||||
|
@ -27,6 +27,7 @@ public:
|
||||
void draw_glyph(Gfx::Painter&, Gfx::FloatPoint, float, u32, Color) override;
|
||||
|
||||
Type type() const override { return PDFFont::Type::TrueType; }
|
||||
DeprecatedFlyString base_font_name() const override { return m_data.base_font_name; }
|
||||
|
||||
private:
|
||||
PDFFont::CommonData m_data;
|
||||
|
@ -30,6 +30,7 @@ public:
|
||||
void draw_glyph(Gfx::Painter&, Gfx::FloatPoint, float, u32, Color) override {};
|
||||
|
||||
Type type() const override { return PDFFont::Type::Type0; }
|
||||
DeprecatedFlyString base_font_name() const override { return ""; }
|
||||
|
||||
private:
|
||||
CIDSystemInfo m_system_info;
|
||||
|
@ -31,6 +31,7 @@ public:
|
||||
void draw_glyph(Gfx::Painter& painter, Gfx::FloatPoint point, float width, u32 char_code, Color color) override;
|
||||
|
||||
Type type() const override { return PDFFont::Type::Type1; }
|
||||
DeprecatedFlyString base_font_name() const override { return m_data.base_font_name; };
|
||||
|
||||
private:
|
||||
Data m_data;
|
||||
|
Loading…
Reference in New Issue
Block a user