diff options
author | Simon Wanner <skyrising@pvpctutorials.de> | 2022-04-09 10:14:58 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-09 23:48:18 +0200 |
commit | 5136c5ae1aed77ccddab128e9ffd88335a9bfcc4 (patch) | |
tree | cacc56ac5ded41ab95208cd0deb0d1db47aa25ff /Userland/Libraries/LibGfx/Font/VectorFont.h | |
parent | 206d6ece55e44117fd49525eeca5bd28d83ac5eb (diff) | |
download | serenity-5136c5ae1aed77ccddab128e9ffd88335a9bfcc4.zip |
LibGfx: Move ScaledFont and new base class VectorFont out of TTF
Diffstat (limited to 'Userland/Libraries/LibGfx/Font/VectorFont.h')
-rw-r--r-- | Userland/Libraries/LibGfx/Font/VectorFont.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/Font/VectorFont.h b/Userland/Libraries/LibGfx/Font/VectorFont.h new file mode 100644 index 0000000000..4932818f4d --- /dev/null +++ b/Userland/Libraries/LibGfx/Font/VectorFont.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022, the SerenityOS developers. + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include <AK/Noncopyable.h> +#include <AK/RefCounted.h> + +namespace Gfx { + +struct ScaledFontMetrics { + float ascender { 0 }; + float descender { 0 }; + float line_gap { 0 }; + + int height() const + { + return ascender - descender; + } +}; + +struct ScaledGlyphMetrics { + int ascender; + int descender; + int advance_width; + int left_side_bearing; +}; + +class VectorFont : public RefCounted<VectorFont> { +public: + virtual ~VectorFont() { } + virtual ScaledFontMetrics metrics(float x_scale, float y_scale) const = 0; + virtual ScaledGlyphMetrics glyph_metrics(u32 glyph_id, float x_scale, float y_scale) const = 0; + virtual float glyphs_horizontal_kerning(u32 left_glyph_id, u32 right_glyph_id, float x_scale) const = 0; + virtual RefPtr<Gfx::Bitmap> rasterize_glyph(u32 glyph_id, float x_scale, float y_scale) const = 0; + virtual u32 glyph_count() const = 0; + virtual u16 units_per_em() const = 0; + virtual u32 glyph_id_for_code_point(u32 code_point) const = 0; + virtual String family() const = 0; + virtual String variant() const = 0; + virtual u16 weight() const = 0; + virtual u8 slope() const = 0; + virtual bool is_fixed_width() const = 0; +}; + +} |