Home | All Classes | Grouped Classes | Index | Search
Stores and draws glyphs in one or more fonts. More...
Derived from:
none
Derived by:
none
Group: Display (Fonts)
#include <ClanLib/display.h>
Construction:
Constructs a glyph buffer. |
Subclasses:
A character and position describing a glyph in the buffer, stored in the glyphs vector. | |
Represents a subsection of the buffer |
Attributes:
Returns a reference to the glyphs in the buffer and their drawing positions. | |
Returns a reference to the font map. | |
Returns a reference to the color effect map. | |
Returns a reference to the x scale effect map. | |
Returns a reference to the y scale effect map. | |
Returns a reference to the character angle effect map. | |
Returns an iterator to the font_marker associated with a particular glyph. | |
Returns the width of the entire buffer, or a sub-Range. | |
Returns the height of the entire buffer, or a sub-Range. | |
Returns the size of the entire buffer, or a sub-Range. | |
Returns current angle. | |
Returns scale for x and y. | |
Returns translation hotspot for the entire glyph field. | |
Returns rotation hotspot for the entire glyph field. | |
Returns the area that would be drawn to if a draw were performed. | |
Returns the area occupied by glyphs inside the glyph buffer's coordinate space. | |
Returns a vector of CL_GlyphBuffer::Range, each of which contains one line. | |
Returns a single CL_GlyphBuffer::Range containing the line that contains a given glyph. |
Operations
Add elements onto the end of the glyphs vector. | |
Removes an element or elements from the glyphs vector, reorganizes the font and effect maps to compensate. | |
Adds a font change marker, set to occur before the next glyph/location you add is drawn. | |
Remove all the character position and font marker data in the buffer. | |
Draw the glyphs in the buffer. | |
Draws the glyphs in the buffer without bounding rect alignment. | |
Rejustifies lines in the GlyphBuffer to the left. | |
Rejustifies lines in the GlyphBuffer to the center. | |
Rejustifies lines in the GlyphBuffer to the right. | |
Set absolute rotation angle. | |
Add angle to current angle. | |
Set scale for x and y directions individually. | |
Sets translation hotspot. | |
Sets rotation hotspot. |
Detailed description:
!group=Display/Fonts! !header=display.h!CL_GlyphBuffer is mostly useful for text effects, for concatenating multiple CL_Font or CL_TextStyler draw_to_gb()s, or for when you need access to the low-level glyph positioning data. You can also use it to save time by only rendering a bit of text once when you need to, for example, both draw that text and know its bounding rectangle. But for optimiziation purposes alone when dealing with unchanging text, you should instead have CL_Font or CL_TextStyler render onto a CL_Canvas or CL_Surface.
A glyph buffer consists of a series of characters and positions, and markers for font changes and various other text-altering infomration. The internal data structures used are made accessible and mutable externally. CL_Font and CL_TextStyler both have draw_to_gb() methods, which allows them to put data into a CL_GlyphBuffer rather than drawing to a CL_GraphicContext.
The effect maps for color, angle, and scale allow you to affect those properties for individual glyphs during drawing and bounding rect calculation. The angle and scale maps are different from the GlyphBuffer angle and scale properties; the properties apply to the entire CL_GlyphBuffer as a whole, while entries in the effect maps affect individual glyphs seperately. It's not legal to insert an effect map entry for a glyph that doesn't exist.
Unlike scale effects map entries, which are multiplied by the CL_Font's existing scale, color effect map entries entirely override the CL_Font's color. No blending between the two colors is performed. Also, it's your responsibility to make sure that CL_Fonts have the right blending functions.
In functions that calculate the size or bounding rectangle of the GlyphBuffer (such as bouding_rect(), get_size(), and the alignment calculations within draw), effect properties do take effect on the final rectangle, but GlyphBuffer rotation and scaling (set with CL_GlyphBuffer::set_angle(), and CL_GlyphBuffer::set_scale(), respectively) do not. This is consistent with the behavior of CL_Sprite and CL_Surface; the content affects bounding rect calculation, but the other properties of the object do not.