1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:07:45 +00:00

LibPDF: Give Type0 CIDFontType2 a ScaledFont instead of a Font

...with the same reasoning as the previous commit.

No behavior change.
This commit is contained in:
Nico Weber 2024-03-01 08:19:25 -05:00 committed by Andreas Kling
parent f374ad50a1
commit c3980eda9e

View file

@ -121,12 +121,12 @@ public:
virtual void set_font_size(float) override; virtual void set_font_size(float) override;
private: private:
CIDFontType2(RefPtr<Gfx::Font> font) CIDFontType2(RefPtr<Gfx::ScaledFont> font)
: m_font(move(font)) : m_font(move(font))
{ {
} }
RefPtr<Gfx::Font> m_font; RefPtr<Gfx::ScaledFont> m_font;
}; };
static PDFErrorOr<NonnullOwnPtr<OpenType::CharCodeToGlyphIndex>> create_cid_to_gid_map(Document* document, NonnullRefPtr<DictObject> const& dict) static PDFErrorOr<NonnullOwnPtr<OpenType::CharCodeToGlyphIndex>> create_cid_to_gid_map(Document* document, NonnullRefPtr<DictObject> const& dict)
@ -179,7 +179,7 @@ PDFErrorOr<NonnullOwnPtr<CIDFontType2>> CIDFontType2::create(Document* document,
auto cid_to_gid_map = TRY(create_cid_to_gid_map(document, descendant)); auto cid_to_gid_map = TRY(create_cid_to_gid_map(document, descendant));
RefPtr<Gfx::Font> font; RefPtr<Gfx::ScaledFont> font;
if (descriptor->contains(CommonNames::FontFile2)) { if (descriptor->contains(CommonNames::FontFile2)) {
auto font_file_stream = TRY(descriptor->get_stream(document, CommonNames::FontFile2)); auto font_file_stream = TRY(descriptor->get_stream(document, CommonNames::FontFile2));
float point_size = (font_size * POINTS_PER_INCH) / DEFAULT_DPI; float point_size = (font_size * POINTS_PER_INCH) / DEFAULT_DPI;
@ -231,7 +231,7 @@ PDFErrorOr<void> CIDFontType2::draw_glyph(Gfx::Painter& painter, Gfx::FloatPoint
void CIDFontType2::set_font_size(float font_size) void CIDFontType2::set_font_size(float font_size)
{ {
m_font = m_font->with_size((font_size * POINTS_PER_INCH) / DEFAULT_DPI); m_font = m_font->scaled_with_size((font_size * POINTS_PER_INCH) / DEFAULT_DPI);
} }
Type0Font::Type0Font() = default; Type0Font::Type0Font() = default;