Add some basic code for font objects

This parses the font object to return the address of the bitmap data.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This commit is contained in:
Christophe de Dinechin 2022-10-23 01:16:26 +02:00
parent 431c633512
commit 6e3557ace4
4 changed files with 37 additions and 1 deletions

View file

@ -87,7 +87,8 @@ CXX_SOURCES += \
src/rplstring.cc \
src/symbol.cc \
src/algebraic.cc \
src/arithmetic.cc
src/arithmetic.cc \
src/font.cc
# Generate the sized variants of decimal128
src/decimal-%.cc: src/decimal128.cc src/decimal-%.h

View file

@ -51,6 +51,7 @@ SOURCES += \
../src/symbol.cc \
../src/algebraic.cc \
../src/arithmetic.cc \
../src/font.cc \
../src/tests.cc
HEADERS += \

View file

@ -32,15 +32,47 @@
#include "object.h"
struct font : object
// ----------------------------------------------------------------------------
// Shared by all font objects
// ----------------------------------------------------------------------------
{
font(id type): object(type) { }
byte *bitmap(uint codepoint, uint *x, uint *y, uint *w, uint *h, uint *adv);
OBJECT_HANDLER(font);
OBJECT_PARSER(font);
OBJECT_RENDERER(font);
};
struct sparse_font : font
// ----------------------------------------------------------------------------
// An object representing a sparse font (one bitmap per character)
// ----------------------------------------------------------------------------
{
sparse_font(id type = ID_sparse_font): font(type) {}
byte *bitmap(uint codepoint, uint *x, uint *y, uint *w, uint *h, uint *adv);
};
struct dense_font : font
// ----------------------------------------------------------------------------
// An object representing a dense font (a single bitmap for all characters)
// ----------------------------------------------------------------------------
{
dense_font(id type = ID_dense_font): font(type) {}
byte *bitmap(uint codepoint, uint *x, uint *y, uint *w, uint *h, uint *adv);
};
struct dmcp_font : font
// ----------------------------------------------------------------------------
// An object accessing the DMCP built-in fonts (and remapping to Unicode)
// ----------------------------------------------------------------------------
{
dmcp_font(id type = ID_dense_font): font(type) {}
byte *bitmap(uint codepoint, uint *x, uint *y, uint *w, uint *h, uint *adv);
};
#endif // FONT_H

View file

@ -80,8 +80,10 @@ NAMED(inv, "Invert")
// Special objects
ID(font)
ID(dense_font)
ID(sparse_font)
ID(dmcp_font)
#undef ID
#undef OP