mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:47:37 +00:00
LibGfx: Insert pixel and ttf fonts into Typeface structure
This adds a new structure 'Typeface' to the FontDatabase that represents all fonts of the same family and variant. It can contain a list of BitmapFonts with varying size but of the same family and weight or a pointer to a single TTF font for all sizes of this Typeface.
This commit is contained in:
parent
2c4e13f14a
commit
179dba652e
13 changed files with 248 additions and 32 deletions
|
@ -31,15 +31,21 @@
|
|||
#include <AK/RefPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Types.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/Size.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
// FIXME: Make a MutableGlyphBitmap buddy class for FontEditor instead?
|
||||
class GlyphBitmap {
|
||||
friend class BitmapFont;
|
||||
|
||||
public:
|
||||
GlyphBitmap() = default;
|
||||
GlyphBitmap(const unsigned* rows, IntSize size)
|
||||
: m_rows(rows)
|
||||
, m_size(size)
|
||||
{
|
||||
}
|
||||
|
||||
const unsigned* rows() const { return m_rows; }
|
||||
unsigned row(unsigned index) const { return m_rows[index]; }
|
||||
|
||||
|
@ -58,14 +64,29 @@ public:
|
|||
int height() const { return m_size.height(); }
|
||||
|
||||
private:
|
||||
GlyphBitmap(const unsigned* rows, IntSize size)
|
||||
: m_rows(rows)
|
||||
, m_size(size)
|
||||
const unsigned* m_rows { nullptr };
|
||||
IntSize m_size { 0, 0 };
|
||||
};
|
||||
|
||||
class Glyph {
|
||||
public:
|
||||
Glyph(const GlyphBitmap& glyph_bitmap)
|
||||
: m_glyph_bitmap(glyph_bitmap)
|
||||
{
|
||||
}
|
||||
|
||||
const unsigned* m_rows { nullptr };
|
||||
IntSize m_size;
|
||||
Glyph(RefPtr<Bitmap> bitmap)
|
||||
: m_bitmap(bitmap)
|
||||
{
|
||||
}
|
||||
|
||||
bool is_glyph_bitmap() const { return !m_bitmap; }
|
||||
GlyphBitmap glyph_bitmap() const { return m_glyph_bitmap; }
|
||||
RefPtr<Bitmap> bitmap() const { return m_bitmap; }
|
||||
|
||||
private:
|
||||
GlyphBitmap m_glyph_bitmap;
|
||||
RefPtr<Bitmap> m_bitmap;
|
||||
};
|
||||
|
||||
class Font : public RefCounted<Font> {
|
||||
|
@ -78,7 +99,7 @@ public:
|
|||
virtual u8 presentation_size() const = 0;
|
||||
|
||||
virtual u16 weight() const = 0;
|
||||
virtual GlyphBitmap glyph_bitmap(u32 code_point) const = 0;
|
||||
virtual Glyph glyph(u32 code_point) const = 0;
|
||||
|
||||
virtual u8 glyph_width(size_t ch) const = 0;
|
||||
virtual int glyph_or_emoji_width(u32 code_point) const = 0;
|
||||
|
@ -96,7 +117,7 @@ public:
|
|||
virtual int width(const Utf8View&) const = 0;
|
||||
virtual int width(const Utf32View&) const = 0;
|
||||
|
||||
virtual const String& name() const = 0;
|
||||
virtual String name() const = 0;
|
||||
|
||||
virtual bool is_fixed_width() const = 0;
|
||||
|
||||
|
@ -104,7 +125,8 @@ public:
|
|||
|
||||
virtual int glyph_count() const = 0;
|
||||
|
||||
virtual const String& family() const = 0;
|
||||
virtual String family() const = 0;
|
||||
virtual String variant() const = 0;
|
||||
|
||||
virtual String qualified_name() const = 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue