Home | All Classes | Grouped Classes | Index | Search
Draws text using system fonts or glyph sprites. More...
Derived from:
none
Derived by:
none
Group: Display (Fonts)
#include <ClanLib/display.h>
Construction:
Constructs a font. |
Attributes:
Returns delimiters string. | |
Returns width offset. | |
Returns height offset. | |
Returns current scale. | |
Returns current alpha. | |
Returns current color. | |
Returns blending functions. | |
Returns glyph rotation hotspot. | |
Returns translation hotspot. | |
Returns the drawn height of the entire font or a string. | |
Returns the drawn width of a character or string. | |
Returns the drawn size of a string. | |
Calculate the rectangle that would be occupied by a draw operation. | |
Returns whether or not a glyph exists for a given character | |
Resource owning this font, if any. |
Operations:
Copy assignment operator. | |
Return true if the CL_Font object is valid | |
Draws text to a graphic context. | |
Inserts data into a CL_GlyphBuffer, treating the glyphs already there as part of a previous draw_to_gb(). | |
Draws a single glyph to a given spot. | |
Draws a single character to a given spot. | |
Sets delimiters string. | |
Sets width offset. | |
Sets height offset. | |
Sets scale for x and y directions individually. | |
Sets transparency. | |
Sets the color. | |
Sets blending functions. | |
Sets glyph rotation hotspot. | |
Sets translation hotspot. | |
Detailed description:
!group=Display/Fonts! !header=display.h!A font can be constructed either from a CL_Sprite (aka a bitmap font) or from a system font A bitmap font uses a CL_Sprite as the source for the font glyphs (letters), where each frame frame in the sprite represents one glyph. A string (letter_chars) is then describing which character each glyph corresponds to. If the sprite contains the letters ABCZXY123 in that order, then the string should be "ABCZXY123". A system font uses the underlaying windowing system to create the font glyphs. This means that in Windows you can choose any TTF font, and same applies to X11 if the font server supports it.
Newlines always have a width of zero. Other than that, characters for which glyphs weren't specified have the width of a space.
Unlike CL_Surface and CL_Sprite, scaling affects the calculation of any bounding rectangles (such as the result returned by draw(), bounding_rect(), or get_size(), or the rectangle calculated internally by draw() for alignment). This is because scaling the CL_Font is effectively just changing the point size of the glyphs, and that affects all sorts of things, such as word wrapping.
Word wrapping works automatically whenever you pass CL_Font a destination rectangle or size with non-zero width. CL_Font uses the delims string (which can be changed using the set_delims() method) to determine where divisions between words are. Word wrapping does allow blank characters (characters for which there isn't a glyph supplied) to extend over the border line; this helps wrapped text to remain flush.