19#include <utils/gp_vec.h>
22#define GPF_NAME_MAX 64
24#define GPF_YEARS_MAX 32
27#define GPF_MIN(a, b) ((a) < (b) ? (a) : (b))
29#define GPF_MAX(a, b) ((a) > (b) ? (a) : (b))
362 int size,
int ascent,
int descent,
int advance);
413 return gp_vec_len(self->
glyphs);
529 const char *name,
const char *email);
612 unsigned int w,
unsigned int h,
624 unsigned int x,
unsigned int y)
const char * gpf_variant_name(enum gpf_variant_id id)
Returns the name of a variant.
static int gpf_glyph_pixel(const struct gpf_glyph *self, unsigned int x, unsigned int y)
Returns a glyph ink pixel.
struct gpf_author * gpf_authors_dup(const struct gpf_author *authors)
Copies a gp_vec of authors.
void gpf_glyph_clear(struct gpf_glyph *self)
Frees the ink and zeroes the glyph, keeping only the code.
void gpf_family_meta_guess(struct gpf_family_meta *meta, const char *family, int size, int ascent, int descent, int advance)
Fills in metadata for a font that is only being started.
int gpf_family_meta_same(const struct gpf_family_meta *a, const struct gpf_family_meta *b)
Compares two sets of font metadata.
int gpf_variant_by_name(const char *name, enum gpf_variant_id *id)
Looks up a variant by its on-disk name.
struct gpf_glyph * gpf_variant_glyph_add(struct gpf_variant *self, uint32_t code)
Adds a glyph to a variant.
void gpf_font_free(struct gpf_font *self)
Frees a font with all its variants and glyphs.
enum gpf_variant_id gpf_variant_parent(enum gpf_variant_id id)
Returns the variant a variant derives its missing glyphs from.
const char * gpf_author_invalid(const char *years, const char *name, const char *email)
Checks the fields of an author.
unsigned int gpf_font_block_clear(struct gpf_font *self, uint32_t min, uint32_t max)
Deletes every glyph in a range, in all variants.
unsigned int gpf_font_range_glyphs(struct gpf_font *self, uint32_t min, uint32_t max)
Counts glyph entries in a range, in all variants.
#define GPF_YEARS_MAX
Size of the author years buffer, including the terminating zero.
#define GPF_NAME_MAX
Size of the name buffers, including the terminating zero.
void gpf_font_clear_modified(struct gpf_font *self)
Clears the modified flag of all glyphs in all variants.
void gpf_authors_del(struct gpf_author **authors, size_t idx)
Removes an author from a gp_vec of authors.
int gpf_font_block_declared(struct gpf_font *self, uint32_t min)
Checks whether a block is declared.
void gpf_variant_glyph_del(struct gpf_variant *self, uint32_t code)
Removes a glyph from a variant.
int gpf_authors_same(const struct gpf_author *a, const struct gpf_author *b)
Compares two gp_vecs of authors, NULL being the same as empty.
struct gpf_variant * gpf_font_variant(struct gpf_font *self, enum gpf_variant_id id, int create)
Returns a font variant.
static size_t gpf_variant_glyphs(const struct gpf_variant *self)
Returns the number of glyph entries in a variant.
gpf_variant_id
Font face variant.
@ GPF_BOLD_MONO
Bold monospace glyphs.
@ GPF_NO_PARENT
What gpf_variant_parent() returns for the base variant.
@ GPF_VARIANTS
Number of font variants.
@ GPF_MONO
Monospace glyphs, the base variant.
@ GPF_REGULAR
Proportional glyphs, "regular" on disk.
struct gpf_font * gpf_font_new(void)
Allocates an empty font.
struct gpf_glyph * gpf_variant_glyph(struct gpf_variant *self, uint32_t code)
Looks up a glyph in a variant.
uint32_t * gpf_font_codes(struct gpf_font *self)
Returns every codepoint the font mentions, in any variant.
int gpf_font_block_add(struct gpf_font *self, uint32_t min, uint32_t max, const char *name)
Declares a unicode block.
gpf_glyph_kind
A glyph entry type.
@ GPF_GLYPH_INK
Glyph with ink.
@ GPF_GLYPH_COMPOSE
Glyph is composed from base + accent.
@ GPF_GLYPH_METRICS
Glyph with metrics.
void gpf_font_ink_extent(struct gpf_font *self, int *top, int *bottom)
Returns how far the ink of the whole font reaches.
int gpf_authors_add(struct gpf_author **authors, const char *years, const char *name, const char *email)
Appends an author to a gp_vec of authors.
int gpf_glyph_set_bits(struct gpf_glyph *self, const uint8_t *bits, unsigned int w, unsigned int h, int bearing_x, int bearing_y)
Stores the glyph ink.
struct gpf_font * gpf_font_create(const struct gpf_family_meta *meta, int advance)
Creates a new font.
void gpf_font_block_del(struct gpf_font *self, uint32_t min)
Removes a block declaration.
A font author, one author line of the family file.
char years[32]
Copyright years, e.g. "2024", "2019-2024" or "2019,2023".
char email[64]
The author's email, without the angle brackets.
char name[64]
The author's name.
A declared unicode block.
char name[64]
The block name.
uint32_t max
The last codepoint of the block, inclusive.
uint32_t min
The first codepoint of the block.
struct gpf_author * authors
Font authors.
struct gpf_variant * variants[GPF_VARIANTS]
Variants indexed by gpf_variant_id, NULL when missing.
struct gpf_family_meta meta
Font meta data.
struct gpf_block_decl * blocks
Declared unicode blocks.
char * comments
Font comments.
uint8_t kind
enum gpf_glyph_kind
int bearing_y
Glyph bearing y.
uint8_t has_advance
The entry carries an advance.
int shift_x
How far the inherited ink is moved, positive right and up.
int dx
Accent offset, positive right and up, compose only.
uint8_t has_shift
The entry moves the inherited ink, GPF_GLYPH_METRICS only.
uint32_t base
Base glyph, GPF_GLYPH_COMPOSE only.
uint32_t accent
Accent to be combined with the base, GPF_GLYPH_COMPOSE only.
uint8_t has_bearing
The entry carries both bearings, see has_advance.
unsigned int height
Glyph ink height.
unsigned int width
Glyph ink width.
int advance
Glyph advance.
uint8_t modified
Glyph was modified flag.
int bearing_x
Glyph bearing x.
uint32_t code
Unicode code point.
int advance
Advance for all glyphs.
int derive_embolden
Glyphs not drawn here are emboldened from the parent.
enum gpf_variant_id id
Font variant e.g. GPF_REGULAR, GPF_MONO, etc.
int spacing_mono
Every glyph has the same advance.
struct gpf_glyph * glyphs
Glyphs.
char * comments
Comments above the first glyph block.