15#define GPF_COMPOSE_DEPTH_MAX 8
17static const char *provenance_names[] = {
27 return provenance_names[prov];
33 memset(self, 0,
sizeof(*self));
73 if (entry->has_advance)
74 glyph->
advance = entry->advance;
76 if (entry->has_shift) {
96static int entry_has_ink(
const struct gpf_glyph *entry)
115 return glyph_copy(&res->
glyph, entry);
118 if (depth >= GPF_COMPOSE_DEPTH_MAX)
121 if (resolve(font,
id, entry->base, &base, depth + 1))
124 if (resolve(font,
id, entry->accent, &accent, depth + 1)) {
129 ret = gpf_compose(&res->
glyph, &base.
glyph, &accent.glyph,
130 entry->
dx, entry->dy);
146static int resolve_mono(
struct gpf_font *font, uint32_t code,
154 if (entry_has_ink(entry))
155 return materialize(font,
GPF_MONO, entry, res, depth);
184 if (entry_has_ink(entry))
193static int resolve_regular(
struct gpf_font *font, uint32_t
code,
199 if (entry_has_ink(entry))
200 return materialize(font,
GPF_REGULAR, entry, res, depth);
204 if (def && !materialize(font,
GPF_REGULAR, def, res, depth)) {
205 apply_metrics(&res->
glyph, entry);
209 if (resolve_mono(font,
code, res, depth))
215 apply_metrics(&res->
glyph, entry);
221static int mono_cell(
struct gpf_font *font)
231static int resolve_bold_mono(
struct gpf_font *font, uint32_t code,
237 if (entry_has_ink(entry))
243 if (def && !materialize(font,
GPF_BOLD_MONO, def, res, depth)) {
244 apply_metrics(&res->
glyph, entry);
248 if (resolve_mono(font,
code, res, depth))
252 if (gpf_embolden(&res->
glyph, mono_cell(font))) {
253 gpf_resolved_clear(res);
260 apply_metrics(&res->
glyph, entry);
281static int regular_overrides_ink(
const struct gpf_glyph *regular_entry,
284 if (!entry_has_ink(regular_entry))
290 return !ink_eq(regular_entry, mono);
297static int resolve_bold(
struct gpf_font *font, uint32_t
code,
303 int has_mono, widen = 0;
306 if (entry_has_ink(entry))
307 return materialize(font,
GPF_BOLD, entry, res, depth);
314 regular_entry = gpf_compose_def(font,
GPF_REGULAR, code);
317 !materialize(font,
GPF_BOLD, regular_entry, res, depth)) {
318 apply_metrics(&res->
glyph, entry);
322 if (resolve_regular(font, code, ®ular, depth))
325 has_mono = !resolve_mono(font, code, &mono, depth);
327 regular_entry = entry_get(font,
GPF_REGULAR, code);
329 if (regular_overrides_ink(regular_entry,
330 has_mono ? &mono.glyph : NULL)) {
335 if (gpf_embolden(&res->
glyph, 0)) {
348 if (resolve_bold_mono(font, code, &bold_mono, depth)) {
383 apply_metrics(&res->
glyph, entry);
396 return resolve_mono(font, code, res, depth);
398 return resolve_regular(font, code, res, depth);
400 return resolve_bold_mono(font, code, res, depth);
402 return resolve_bold(font, code, res, depth);
421 return gpf_resolve(font,
id,
code, res);
426 entry->has_advance = 0;
427 entry->has_shift = 0;
429 ret = gpf_resolve(font,
id,
code, res);
445 memset(out, 0,
sizeof(*out));
455 if (gpf_resolve_derived(font,
id, glyph->
code, &
base))
462 memcmp(glyph->
bits,
base.glyph.bits,
484 gpf_resolved_clear(&
base);
524 memset(res, 0,
sizeof(*res));
526 if (resolve(font,
id,
code, res, 0)) {
527 gpf_resolved_clear(res);
539 static const uint32_t codes[] = {
Accented letters: the decomposition table and accent composition.
enum gpf_variant_id gpf_variant_parent(enum gpf_variant_id id)
Returns the variant a variant derives its missing glyphs from.
void gpf_variant_glyph_del(struct gpf_variant *self, uint32_t code)
Removes a glyph from a 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_glyph * gpf_variant_glyph(struct gpf_variant *self, uint32_t code)
Looks up a glyph in a variant.
@ GPF_GLYPH_INK
Glyph with ink.
@ GPF_GLYPH_COMPOSE
Glyph is composed from base + accent.
@ GPF_GLYPH_METRICS
Glyph with metrics.
The glyph variant lattice.
gpf_entry_form
The smallest form an entry can be written in on save.
@ GPF_ENTRY_METRICS
The ink is the parent's, only numbers differ.
@ GPF_ENTRY_INK
The ink differs, it has to be saved.
@ GPF_ENTRY_NONE
Identical to what the variant would derive, no entry needed.
int gpf_resolve_derived(struct gpf_font *font, enum gpf_variant_id id, uint32_t code, struct gpf_resolved *res)
Resolves a derived glyph variant metric and ink.
gpf_measure
The family metrics that are measured off the glyphs.
@ GPF_MEASURE_CH_WIDTH
The advance of the '0' glyph.
@ GPF_MEASURE_CAP_HEIGHT
The top of the 'H' ink above the baseline.
@ GPF_MEASURE_X_HEIGHT
The top of the 'x' ink above the baseline.
void gpf_resolved_clear(struct gpf_resolved *self)
Clears the resolved glyph.
int gpf_resolve(struct gpf_font *font, enum gpf_variant_id id, uint32_t code, struct gpf_resolved *res)
Resolves a glyph variant metric and ink.
gpf_provenance
Glyph provenance.
@ GPF_PROV_EMBOLDENED
The parent's ink, emboldened.
@ GPF_PROV_COMPOSED
Built from a base glyph and an accent.
@ GPF_PROV_BOLD_MONO
Bold taking a hand fixed glyph from bold-mono.
@ GPF_PROV_INHERITED
The parent's ink, the metrics may still be overridden.
@ GPF_PROV_STORED
The ink is stored in the variant itself.
struct gpf_variant * variants[GPF_VARIANTS]
Variants indexed by gpf_variant_id, NULL when missing.
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.
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.
int bearing_x
Glyph bearing x.
uint32_t code
Unicode code point.
A resolved glyph and where it was drawn from.
enum gpf_variant_id ink_from
The variant the ink came from.
enum gpf_provenance prov
Where the glyph came from.
struct gpf_glyph glyph
Freshly allocated glyph with copied/generated ink.
int advance
Advance for all glyphs.
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.