LibGfx: Add pure virtual fallible clone() for Fonts

This commit is contained in:
thankyouverycool 2022-08-15 06:26:56 -04:00 committed by Andreas Kling
parent d9fb838cf6
commit 1be830e3c6
Notes: sideshowbarker 2024-07-17 09:56:35 +09:00
3 changed files with 4 additions and 2 deletions

View File

@ -21,7 +21,7 @@ namespace Gfx {
class BitmapFont final : public Font {
public:
virtual NonnullRefPtr<Font> clone() const override;
ErrorOr<NonnullRefPtr<Font>> try_clone() const;
ErrorOr<NonnullRefPtr<Font>> try_clone() const override;
static NonnullRefPtr<BitmapFont> create(u8 glyph_height, u8 glyph_width, bool fixed, size_t glyph_count);
static ErrorOr<NonnullRefPtr<BitmapFont>> try_create(u8 glyph_height, u8 glyph_width, bool fixed, size_t glyph_count);

View File

@ -112,6 +112,7 @@ public:
};
virtual NonnullRefPtr<Font> clone() const = 0;
virtual ErrorOr<NonnullRefPtr<Font>> try_clone() const = 0;
virtual ~Font() {};
virtual FontPixelMetrics pixel_metrics() const = 0;

View File

@ -33,7 +33,8 @@ public:
RefPtr<Gfx::Bitmap> rasterize_glyph(u32 glyph_id) const;
// ^Gfx::Font
virtual NonnullRefPtr<Font> clone() const override { return *this; } // FIXME: clone() should not need to be implemented
virtual NonnullRefPtr<Font> clone() const override { return MUST(try_clone()); } // FIXME: clone() should not need to be implemented
virtual ErrorOr<NonnullRefPtr<Font>> try_clone() const override { return *this; }
virtual u8 presentation_size() const override { return m_point_height; }
virtual int pixel_size() const override { return m_point_height * 1.33333333f; }
virtual float point_size() const override { return m_point_height; }