1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 14:57:34 +00:00

LibTTF: Make TTF::Font loading API return error strings

This commit is contained in:
Andreas Kling 2021-07-04 19:06:39 +02:00
parent 9321d9d83d
commit 560109bd42
4 changed files with 58 additions and 88 deletions

View file

@ -46,8 +46,8 @@ class Font : public RefCounted<Font> {
AK_MAKE_NONCOPYABLE(Font);
public:
static RefPtr<Font> load_from_file(String path, unsigned index = 0);
static RefPtr<Font> load_from_memory(ByteBuffer&, unsigned index = 0);
static Result<NonnullRefPtr<Font>, String> try_load_from_file(String path, unsigned index = 0);
static Result<NonnullRefPtr<Font>, String> try_load_from_memory(ByteBuffer&, unsigned index = 0);
ScaledFontMetrics metrics(float x_scale, float y_scale) const;
ScaledGlyphMetrics glyph_metrics(u32 glyph_id, float x_scale, float y_scale) const;
@ -72,7 +72,7 @@ private:
TableRecord = 16,
};
static RefPtr<Font> load_from_offset(ByteBuffer&&, unsigned index = 0);
static Result<NonnullRefPtr<Font>, String> try_load_from_offset(ByteBuffer&&, unsigned index = 0);
Font(ByteBuffer&& buffer, Head&& head, Name&& name, Hhea&& hhea, Maxp&& maxp, Hmtx&& hmtx, Cmap&& cmap, Loca&& loca, Glyf&& glyf)
: m_buffer(move(buffer))
, m_head(move(head))