1.1.0
Classes | Enumerations | Functions
Character Mapping

Functions and types related to renderings result (after calling fc_render) More...

Classes

struct  fc_character_mapping
 Specifies source and target rectangles to render the specified codepoint. More...
 
struct  fc::render_result
 Wraps a std::vector<fc_character_mapping>. More...
 

Enumerations

enum  fc_alignment { fc_align_left = 0, fc_align_center, fc_align_right }
 Specifies an aligment to be used when rendering wrapped text. More...
 

Functions

struct fc_rect fc_text_bounds (struct fc_character_mapping const mapping[], size_t length)
 Calculates a bounding box for the rendered text. More...
 
uint32_t fc_wrap (struct fc_character_mapping mapping[], size_t count, float line_width, float line_height, float space_width, enum fc_alignment alignment)
 Word-wraps characters in an array of fc_character_mapping. More...
 
void fc_move (struct fc_character_mapping *mapping, size_t count, float left, float baseline)
 Moves all the target rectangles by left pixels horizontally and baseline pixels vertically. More...
 

Detailed Description

Functions and types related to renderings result (after calling fc_render)

Enumeration Type Documentation

◆ fc_alignment

Specifies an aligment to be used when rendering wrapped text.

See also
fc_wrap
fc_render_wrapped
fc::render_result::wrap

Function Documentation

◆ fc_text_bounds()

struct fc_rect fc_text_bounds ( struct fc_character_mapping const  mapping[],
size_t  length 
)

Calculates a bounding box for the rendered text.

Parameters
mappingThe rendering mapping (result of fc_render)
lengthHow many characters were mapped
Returns
A fc_rect value with left, top, right and bottom values enclosing the text area

◆ fc_wrap()

uint32_t fc_wrap ( struct fc_character_mapping  mapping[],
size_t  count,
float  line_width,
float  line_height,
float  space_width,
enum fc_alignment  alignment 
)

Word-wraps characters in an array of fc_character_mapping.

This functions identifies words and then uses a greedy algorithm to wrap lines. Keep in mind that calling fc_wrap on an already wrapped array will produce weird results. line_height and space_width can be obtained by calling fc_get_space_metrics, which returns both how tall and how wide a space is. You can multiply line_height to increase between each line.

Parameters
mappingThe array of character mappings to wrap
countHow many mappings are in the array
line_widthThe maximum line width, in target/screen size (e.g, pixels)
line_heightThe space between the topmost pixel in the line to the bottomost pixel in the line (this includes characters in the line itself)
space_widthThe width of a space character
alignmentWhich aligment should lines follow
Returns
The line count in the text
See also
fc_render_wrapped
fc::render_result::wrap
fc_get_space_metrics

◆ fc_move()

void fc_move ( struct fc_character_mapping mapping,
size_t  count,
float  left,
float  baseline 
)

Moves all the target rectangles by left pixels horizontally and baseline pixels vertically.

You should use this to position the text where it should start rendering in your screen.

Warning
Text rendered by fc_render has a baseline set at 0 (see fc_render for a discussion about that), so most target rectangles will start rendering at negative y positions. Moving them by baseline pixels means you're moving its baseline and consequentially the y position. But you should think in terms of baseline.
Parameters
mappingThe array of character mappings to move
countHow many mappings are in the array
leftLeft position where the text should start rendering
baselineAmount to add to the text baseline
Examples
main.c.