gpforge
An advanced bitmap font editor
Loading...
Searching...
No Matches
resolve.h File Reference

The glyph variant lattice. More...

#include "font.h"

Go to the source code of this file.

Data Structures

struct  gpf_resolved
 A resolved glyph and where it was drawn from. More...

Enumerations

enum  gpf_provenance {
  GPF_PROV_STORED , GPF_PROV_COMPOSED , GPF_PROV_INHERITED , GPF_PROV_EMBOLDENED ,
  GPF_PROV_BOLD_MONO
}
 Glyph provenance. More...
enum  gpf_entry_form { GPF_ENTRY_NONE , GPF_ENTRY_METRICS , GPF_ENTRY_INK }
 The smallest form an entry can be written in on save. More...
enum  gpf_measure { GPF_MEASURE_X_HEIGHT , GPF_MEASURE_CAP_HEIGHT , GPF_MEASURE_CH_WIDTH }
 The family metrics that are measured off the glyphs. More...

Functions

const char * gpf_provenance_name (enum gpf_provenance prov)
 Returns provenance name.
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.
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.
void gpf_resolved_clear (struct gpf_resolved *self)
 Clears the resolved glyph.
enum gpf_entry_form gpf_entry_form (struct gpf_font *font, enum gpf_variant_id id, const struct gpf_glyph *glyph, struct gpf_glyph *out)
 Computes what should be saved to disk for a glyph variant.
void gpf_font_simplify (struct gpf_font *font)
 Simplifies a font.
int gpf_measure (struct gpf_font *font, enum gpf_variant_id id, enum gpf_measure what, int *val)
 Measures a font metric.

Detailed Description

The glyph variant lattice.

Definition in file resolve.h.

Enumeration Type Documentation

◆ gpf_entry_form

The smallest form an entry can be written in on save.

Enumerator
GPF_ENTRY_NONE 

Identical to what the variant would derive, no entry needed.

GPF_ENTRY_METRICS 

The ink is the parent's, only numbers differ.

GPF_ENTRY_INK 

The ink differs, it has to be saved.

Definition at line 101 of file resolve.h.

◆ gpf_measure

The family metrics that are measured off the glyphs.

Enumerator
GPF_MEASURE_X_HEIGHT 

The top of the 'x' ink above the baseline.

GPF_MEASURE_CAP_HEIGHT 

The top of the 'H' ink above the baseline.

GPF_MEASURE_CH_WIDTH 

The advance of the '0' glyph.

Definition at line 154 of file resolve.h.

◆ gpf_provenance

Glyph provenance.

Where the ink of a resolved glyph came from. The editor shows this per glyph, it answers "why does this glyph look like that".

Enumerator
GPF_PROV_STORED 

The ink is stored in the variant itself.

GPF_PROV_COMPOSED 

Built from a base glyph and an accent.

GPF_PROV_INHERITED 

The parent's ink, the metrics may still be overridden.

GPF_PROV_EMBOLDENED 

The parent's ink, emboldened.

GPF_PROV_BOLD_MONO 

Bold taking a hand fixed glyph from bold-mono.

Definition at line 20 of file resolve.h.

Function Documentation

◆ gpf_entry_form()

enum gpf_entry_form gpf_entry_form ( struct gpf_font * font,
enum gpf_variant_id id,
const struct gpf_glyph * glyph,
struct gpf_glyph * out )

Computes what should be saved to disk for a glyph variant.

Compares the entry against gpf_resolve_derived(). Only an ink entry in a variant with a parent can shrink, anything else is GPF_ENTRY_INK.

Parameters
fontA font.
idA glyph variant e.g. GPF_REGULAR, GPF_MONO, etc.
glyphA glyph entry to be saved.
outA numbers only entry, filled with the numbers that differ, meaningful for GPF_ENTRY_METRICS.
Returns
What should be saved.

Definition at line 436 of file resolve.c.

References gpf_glyph::advance, gpf_glyph::base, gpf_glyph::bearing_x, gpf_glyph::bearing_y, gpf_glyph::bits, gpf_glyph::code, GPF_ENTRY_INK, GPF_ENTRY_METRICS, GPF_ENTRY_NONE, GPF_GLYPH_INK, GPF_GLYPH_METRICS, GPF_NO_PARENT, gpf_variant_parent(), gpf_glyph::has_advance, gpf_glyph::has_shift, gpf_glyph::height, gpf_glyph::kind, gpf_glyph::shift_x, and gpf_glyph::width.

◆ gpf_font_simplify()

void gpf_font_simplify ( struct gpf_font * font)

Simplifies a font.

Rewrites every overlay entry into the smallest form that is true, the same decision the writer makes.

Editing materializes glyphs as ink, so this is what makes the editor say "inherited" again after a metrics only edit instead of "stored".

Parameters
fontA font.

Definition at line 489 of file resolve.c.

References gpf_glyph::bits, gpf_glyph::code, gpf_variant::glyphs, GPF_ENTRY_INK, GPF_ENTRY_METRICS, GPF_ENTRY_NONE, GPF_NO_PARENT, gpf_variant_glyph_del(), gpf_variant_glyphs(), gpf_variant_parent(), GPF_VARIANTS, and gpf_font::variants.

◆ gpf_measure()

int gpf_measure ( struct gpf_font * font,
enum gpf_variant_id id,
enum gpf_measure what,
int * val )

Measures a font metric.

Parameters
fontA font.
idA glyph variant e.g. GPF_REGULAR, GPF_MONO, etc.
whatWhich metric to measure.
valWhere to store the result to.
Returns
Zero when the val was set, non-zero when the variant doesn't have the letter, or, for the heights, when its ink is empty.

Definition at line 536 of file resolve.c.

References gpf_glyph::advance, gpf_glyph::bearing_y, gpf_resolved::glyph, GPF_MEASURE_CAP_HEIGHT, GPF_MEASURE_CH_WIDTH, GPF_MEASURE_X_HEIGHT, gpf_resolve(), gpf_resolved_clear(), and gpf_glyph::height.

◆ gpf_provenance_name()

const char * gpf_provenance_name ( enum gpf_provenance prov)

Returns provenance name.

Parameters
provA provenance.
Returns
A provenance name.

Definition at line 25 of file resolve.c.

◆ gpf_resolve()

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.

Parameters
fontA font.
idA variant id e.g. GPF_MONO, GPF_BOLD, etc.
codeAn unicode codepoint to resolve.
resA resolved struct to store the result into.
Returns
Zero on success, non-zero when the font has no such glyph or on an allocation failure.

Definition at line 521 of file resolve.c.

References gpf_glyph::code, and gpf_resolved::glyph.

Referenced by gpf_accent_ink(), gpf_bdf_write(), gpf_cell_draw(), gpf_cell_draw_glyph(), gpf_deps_draw(), gpf_deps_input(), gpf_gui_accented(), and gpf_measure().

◆ gpf_resolve_derived()

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.

What the glyph would be if this variant had no entry for it — the thing an overlay entry is an override of. Used when saving to write the smallest form an entry can take.

Parameters
fontA font.
idA variant id e.g. GPF_MONO, GPF_BOLD, etc.
codeAn unicode codepoint to resolve.
resA resolved struct to store the result into.
Returns
Zero on success, non-zero when the font has no such glyph or on an allocation failure.

Definition at line 412 of file resolve.c.

References gpf_glyph::code, GPF_GLYPH_METRICS, gpf_variant_glyph(), gpf_variant::id, gpf_glyph::kind, and gpf_font::variants.

◆ gpf_resolved_clear()

void gpf_resolved_clear ( struct gpf_resolved * self)

Clears the resolved glyph.

Frees the ink and clears the gpf_resolved::glyph structure.

Parameters
selfA resolved glyph.

Definition at line 30 of file resolve.c.

References gpf_glyph::bits, and gpf_resolved::glyph.

Referenced by gpf_accent_ink(), gpf_bdf_write(), gpf_cell_draw(), gpf_cell_draw_glyph(), gpf_deps_input(), gpf_gui_accented(), and gpf_measure().