mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:07:46 +00:00
LibPDF: Add glyph drawing and type info methods to PDFFont
A PDFFont can now be asked for its specific type and whether it is part of the standard 14 fonts. It now also contains a method to draw a glyph, which is stubbed-out for now. This will be useful for the renderer to take into consideration when drawing text, since we don't include replacements for the standard set of fonts yet, but still want to make use of embedded fonts when available.
This commit is contained in:
parent
36f83cecab
commit
e6f29302a7
5 changed files with 30 additions and 1 deletions
|
@ -6,18 +6,33 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibPDF/Document.h>
|
||||
|
||||
namespace PDF {
|
||||
|
||||
class PDFFont : public RefCounted<PDFFont> {
|
||||
public:
|
||||
enum class Type {
|
||||
Type0,
|
||||
Type1,
|
||||
TrueType
|
||||
};
|
||||
|
||||
static PDFErrorOr<NonnullRefPtr<PDFFont>> create(Document*, NonnullRefPtr<DictObject>);
|
||||
|
||||
virtual ~PDFFont() = default;
|
||||
|
||||
virtual u32 char_code_to_code_point(u16 char_code) const = 0;
|
||||
virtual float get_char_width(u16 char_code, float font_size) const = 0;
|
||||
|
||||
virtual void draw_glyph(Gfx::Painter& painter, Gfx::IntPoint const& point, float width, u32 code_point, Color color) = 0;
|
||||
|
||||
virtual bool is_standard_font() const { return m_is_standard_font; }
|
||||
virtual Type type() const = 0;
|
||||
|
||||
protected:
|
||||
bool m_is_standard_font { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue