GFXprim
2D bitmap graphics library with emphasis on speed and correctness
|
A text metric. More...
Go to the source code of this file.
Functions | |
gp_size | gp_glyph_advance_x (const gp_text_style *style, uint32_t ch) |
Returns a letter advance in horizontal direction. | |
gp_ssize | gp_glyph_bearing_x (const gp_text_style *style, uint32_t ch) |
Returns horizontal bearing. | |
gp_size | gp_text_width_len (const gp_text_style *style, enum gp_text_len_type type, const char *str, size_t len) |
Calculates the width of the string drawn in the given style. | |
static gp_size | gp_text_wbbox_len (const gp_text_style *style, const char *str, size_t len) |
Calculates bounding box width of the string drawn in the given style. | |
gp_size | gp_text_width (const gp_text_style *style, enum gp_text_len_type type, const char *str) |
Calculates the width of the string drawn in the given style. | |
static gp_size | gp_text_wbbox (const gp_text_style *style, const char *str) |
Calculates bounding box width of the string drawn in the given style. | |
gp_size | gp_text_max_width (const gp_text_style *style, unsigned int len) |
Counts maximal width for len characters. | |
gp_size | gp_text_avg_width (const gp_text_style *style, unsigned int len) |
Counts average width for len characters. | |
gp_size | gp_text_max_width_chars (const gp_text_style *style, const char *chars, unsigned int len) |
Returns maximal width for text written with len characters from str. | |
gp_size | gp_text_height (const gp_text_style *style) |
Returns maximal text height. | |
gp_size | gp_text_ascent (const gp_text_style *style) |
Returns an ascent. | |
gp_size | gp_text_descent (const gp_text_style *style) |
Returns a descent. | |
size_t | gp_text_fit_width (const gp_text_style *style, const char *str, gp_size width) |
Counts how many characters will fit into a width pixels. | |
gp_size | gp_text_cur_pos (const gp_text_style *style, const char *str, gp_coord x_off) |
Returns position between string characters given an x pixel coordinate from the start of the rendered string. The return value is between [0, strlen(str)], where 0 means cursor before string and strlen(str) cursor after string. | |
gp_size gp_glyph_advance_x | ( | const gp_text_style * | style, |
uint32_t | ch | ||
) |
Returns a letter advance in horizontal direction.
style | A text style + font formatting |
ch | An unicode glyph. |
gp_ssize gp_glyph_bearing_x | ( | const gp_text_style * | style, |
uint32_t | ch | ||
) |
Returns horizontal bearing.
Bearing is a distance to be added to the x coordinate before we start drawing a glyph bitmap. Bearing may be negative in some cases, typically for letter 'J' and 'j'.
style | A text style + font formatting |
ch | An unicode glyph. |
gp_size gp_text_ascent | ( | const gp_text_style * | style | ) |
Returns an ascent.
Returns an ascent, the height from the baseline to the top of characters, for the given text style.
style | A text style + font formatting. |
Referenced by gp_widget_size_units_get().
gp_size gp_text_avg_width | ( | const gp_text_style * | style, |
unsigned int | len | ||
) |
Counts average width for len characters.
style | A text style + font formatting. |
len | A number of glyphs to draw. |
gp_size gp_text_cur_pos | ( | const gp_text_style * | style, |
const char * | str, | ||
gp_coord | x_off | ||
) |
Returns position between string characters given an x pixel coordinate from the start of the rendered string. The return value is between [0, strlen(str)], where 0 means cursor before string and strlen(str) cursor after string.
style | A text style. |
str | An UTF8 string. |
x_off | Horizontal offset in the rendered string in pixel. |
gp_size gp_text_descent | ( | const gp_text_style * | style | ) |
Returns a descent.
Returns a descend, the height from the baseline to the bottom of characters, for the given text style.
style | A text style + font formatting. |
size_t gp_text_fit_width | ( | const gp_text_style * | style, |
const char * | str, | ||
gp_size | width | ||
) |
Counts how many characters will fit into a width pixels.
style | A text style. |
str | An UTF-8 string. |
width | Width in pixels. |
gp_size gp_text_height | ( | const gp_text_style * | style | ) |
Returns maximal text height.
style | A text style + font formatting. |
gp_size gp_text_max_width | ( | const gp_text_style * | style, |
unsigned int | len | ||
) |
Counts maximal width for len characters.
style | A text style + font formatting. |
len | A number of glyphs to draw. |
gp_size gp_text_max_width_chars | ( | const gp_text_style * | style, |
const char * | chars, | ||
unsigned int | len | ||
) |
Returns maximal width for text written with len characters from str.
First we find maximal width of an character from the given string, then we use that to compute maximal width. Note that first and last character needs special handling due to bearing and advance.
style | A text style + font formatting. |
chars | An UTF8 string. |
len | A number of glyphs to draw. |
|
inlinestatic |
Calculates bounding box width of the string drawn in the given style.
style | A text style + font formatting. |
str | A string. |
Definition at line 106 of file gp_text_metric.h.
References gp_text_width().
|
inlinestatic |
Calculates bounding box width of the string drawn in the given style.
style | A text style + font formatting. |
str | A string. |
len | Maximal lenght of the string. |
Definition at line 82 of file gp_text_metric.h.
References gp_text_width_len().
gp_size gp_text_width | ( | const gp_text_style * | style, |
enum gp_text_len_type | type, | ||
const char * | str | ||
) |
Calculates the width of the string drawn in the given style.
style | A text style + font formatting. |
type | Select if we want a bounding box or advance. |
str | A string. |
Referenced by gp_text_wbbox().
gp_size gp_text_width_len | ( | const gp_text_style * | style, |
enum gp_text_len_type | type, | ||
const char * | str, | ||
size_t | len | ||
) |
Calculates the width of the string drawn in the given style.
style | A text style + font formatting. |
type | Select if we want a bounding box or advance. |
str | A string. |
len | Maximal lenght of the string. |
Referenced by gp_text_wbbox_len().