|
gpforge
An advanced bitmap font editor
|
Accented letters: the decomposition table and accent composition. More...
Go to the source code of this file.
Data Structures | |
| struct | gpf_decomposition |
| A glyph decomposition. More... | |
Enumerations | |
| enum | gpf_accent_place { GPF_ACCENT_ABOVE , GPF_ACCENT_BELOW , GPF_ACCENT_OGONEK } |
| Accent location in the glyph rectangle. More... | |
Functions | |
| unsigned int | gpf_decompose_accented (uint32_t base_code, uint32_t *codes, unsigned int max) |
| Returns all accented forms of a letter. | |
| unsigned int | gpf_decompose_by_accent (uint32_t accent, uint32_t *codes, unsigned int max) |
| Looks up all glyphs for a given accent. | |
| uint32_t | gpf_decompose_base (uint32_t code) |
| Looks up the base letter of an accented letter. | |
| const struct gpf_decomposition * | gpf_decompose (uint32_t code) |
| Looks up the decomposition of an accented letter. | |
| void | gpf_accent_offset (const struct gpf_font *font, const struct gpf_glyph *base, const struct gpf_glyph *accent, enum gpf_accent_place place, int *dx, int *dy) |
| The default offset for an accent on a base. | |
| int | gpf_compose (struct gpf_glyph *dst, const struct gpf_glyph *base, const struct gpf_glyph *accent, int dx, int dy) |
| Composes the base ink with the accent ink. | |
| int | gpf_compose_remainder (const struct gpf_glyph *glyph, const struct gpf_glyph *base, struct gpf_glyph *rem) |
| Subtracts the base ink from a glyph. | |
| int | gpf_draw_base (struct gpf_font *font, enum gpf_variant_id id, const struct gpf_decomposition *decomp, struct gpf_resolved *res) |
| The letter a new accented letter is drawn from. | |
| int | gpf_accent_ink (struct gpf_font *font, enum gpf_variant_id id, const struct gpf_decomposition *decomp, struct gpf_glyph *out) |
| The accent of a decomposition, as this font draws it. | |
Variables | |
| const struct gpf_decomposition | gpf_decompositions [] |
| A decomposition table. | |
Accented letters: the decomposition table and accent composition.
The table is generated from the unicode decompositions. It says which letters are accented forms of which letter — that is what the editor works on, the letters that have to follow when a letter is edited — and, for drawing a new one, what to draw it from and which accent to put on it.
The composition is what draws a new letter: the accent taken off a letter that has it, put on the base at gpf_accent_offset().
Definition in file compose.h.
| enum gpf_accent_place |
| int gpf_accent_ink | ( | struct gpf_font * | font, |
| enum gpf_variant_id | id, | ||
| const struct gpf_decomposition * | decomp, | ||
| struct gpf_glyph * | out ) |
The accent of a decomposition, as this font draws it.
Attempts to resolve accent ink from existing letters. E.g. caron can be resolved from 'Č' minus 'C'. The accent is subtracted from whichever glyph carries it. Where it goes on the new letter is gpf_accent_offset().
Falls back to the combining mark and then to the spacing accent, for a font that has no letter to take it from.
| font | A font. |
| id | A glyph variant id e.g. GPF_BOLD. |
| decomp | A decomposition description. |
| out | Where to store the result to. |
Definition at line 725 of file compose.c.
References gpf_decomposition::accent, gpf_glyph::bits, gpf_resolved::glyph, gpf_resolve(), gpf_resolved_clear(), and gpf_decomposition::mark.
| void gpf_accent_offset | ( | const struct gpf_font * | font, |
| const struct gpf_glyph * | base, | ||
| const struct gpf_glyph * | accent, | ||
| enum gpf_accent_place | place, | ||
| int * | dx, | ||
| int * | dy ) |
The default offset for an accent on a base.
The starting point a hand adjustment moves from. The accent is kept inside the font's box: a letter that already reaches the ascent leaves no room above it, and an accent drawn outside the box is drawn into the line above. It is pushed down (or up) until it fits, which is what a bitmap font does at small sizes anyway.
| font | A font, its ascent and descent are the box; NULL for no clamp. |
| base | The base glyph. |
| accent | The accent glyph. |
| place | Where the accent goes. |
| dx | Where to store the offset for the accent ink, positive right. |
| dy | Where to store the offset for the accent ink, positive up. |
Definition at line 418 of file compose.c.
References gpf_decomposition::accent, gpf_family_meta::ascent, gpf_glyph::bearing_x, gpf_glyph::bearing_y, gpf_family_meta::descent, GPF_ACCENT_ABOVE, GPF_ACCENT_BELOW, GPF_ACCENT_OGONEK, gpf_glyph::height, gpf_font::meta, gpf_decomposition::place, and gpf_glyph::width.
| int gpf_compose | ( | struct gpf_glyph * | dst, |
| const struct gpf_glyph * | base, | ||
| const struct gpf_glyph * | accent, | ||
| int | dx, | ||
| int | dy ) |
Composes the base ink with the accent ink.
The metrics come from the base.
| dst | Where to store the composed glyph into. |
| base | A base glyph. |
| accent | An accent glyph. |
| dx | Offset for the accent ink, positive right. |
| dy | Offset for the accent ink, positive up. |
Definition at line 494 of file compose.c.
References gpf_decomposition::accent, gpf_glyph::advance, gpf_glyph::bearing_x, gpf_glyph::bearing_y, gpf_glyph::bits, GPF_GLYPH_INK, GPF_MAX, GPF_MIN, gpf_glyph::has_advance, gpf_glyph::has_bearing, gpf_glyph::height, gpf_glyph::kind, and gpf_glyph::width.
| int gpf_compose_remainder | ( | const struct gpf_glyph * | glyph, |
| const struct gpf_glyph * | base, | ||
| struct gpf_glyph * | rem ) |
Subtracts the base ink from a glyph.
Fails when the base does not sit inside the glyph pixel for pixel, or when nothing is left after the subtraction.
| glyph | An accented letter. |
| base | The letter it is drawn from. |
| rem | Where to store what is left, the accent. |
Definition at line 543 of file compose.c.
References gpf_glyph::advance, gpf_glyph::bearing_x, gpf_glyph::bearing_y, GPF_GLYPH_INK, gpf_glyph_pixel(), GPF_MAX, GPF_MIN, gpf_glyph::has_advance, gpf_glyph::has_bearing, gpf_glyph::height, gpf_glyph::kind, and gpf_glyph::width.
| const struct gpf_decomposition * gpf_decompose | ( | uint32_t | code | ) |
Looks up the decomposition of an accented letter.
| code | A codepoint to look up. |
Definition at line 357 of file compose.c.
References gpf_decomposition::code.
Referenced by gpf_decompose_base(), and gpf_gui_create_glyph().
| unsigned int gpf_decompose_accented | ( | uint32_t | base_code, |
| uint32_t * | codes, | ||
| unsigned int | max ) |
Returns all accented forms of a letter.
The accented forms of a letter, sorted by the codepoint: A has À Á Â Ã Ä Å Ā Ă Ą Ǎ, i has ì í î ï ĩ ī ĭ į ǐ. These are the letters the update box copies an edit of the letter into.
| base_code | A base code to lookup the accented variants for. |
| codes | An array to fill the accented letters into. |
| max | The size of the codes array. |
Definition at line 372 of file compose.c.
References gpf_decomposition::base_code.
| uint32_t gpf_decompose_base | ( | uint32_t | code | ) |
Looks up the base letter of an accented letter.
The letter whose accented forms to work with when this glyph is selected: the glyph itself, or the letter it is an accented form of. Selecting í and selecting i show the same family.
| code | A codepoint to lookup the base variant for. |
Definition at line 411 of file compose.c.
References gpf_decomposition::base_code, gpf_decomposition::code, and gpf_decompose().
| unsigned int gpf_decompose_by_accent | ( | uint32_t | accent, |
| uint32_t * | codes, | ||
| unsigned int | max ) |
Looks up all glyphs for a given accent.
The letters an accent goes on, sorted by the codepoint: the caron — the combining U+030C or the spacing U+02C7, either names it — has Č Ď Ě Ľ Ň Ř Š Ť Ž and their lower case. These are the letters the accented letters strip shows composed while the mark is selected.
| accent | An accent to lookup the accented variants for. |
| codes | An array to fill the accented letters into. |
| max | The size of the codes array. |
Definition at line 392 of file compose.c.
References gpf_decomposition::accent, and gpf_decomposition::mark.
| int gpf_draw_base | ( | struct gpf_font * | font, |
| enum gpf_variant_id | id, | ||
| const struct gpf_decomposition * | decomp, | ||
| struct gpf_resolved * | res ) |
The letter a new accented letter is drawn from.
The decomposition's gpf_decomposition::draw_base, and for an i or a j that the font has no dotless form of, the letter with its dot taken off.
| font | A font. |
| id | A glyph variant id e.g. GPF_BOLD. |
| decomp | A decomposition description. |
| res | Where to store the base, free it with gpf_resolved_clear(). |
Definition at line 660 of file compose.c.
References gpf_decomposition::base_code, gpf_decomposition::draw_base, and gpf_resolved::glyph.
|
extern |