#include <BFont.h>
Collaboration diagram for BFont:

A font is an 8-bit greyscale bitmap with all font characters laid out horizontally in a single row. The indexing method into the bitmap uses character ranges and arrays of character start and width in the bitmap. Example: A font with character ranges [31..32] and [65..100], if asked for character glyph 66, will use the fourth entry in the character start/width array to determine the bitmap position the glyph can be found at.
Of the 8 bit, only the lowest 4 bits (0-31) are used.
Public Types | |
| enum | FontFlag { FLAG_REGULAR = 0, FLAG_BOLD = 1, FLAG_OBLIQUE = 2 } |
Public Member Functions | |
| BFont (const BImage &img, const GlyphDescription *indices, int firstchar, int lastchar) | |
| Create a font from an image and character range. | |
| BFont (BVirtualFile &f) | |
| Create a font by reading from the given file. | |
| ~BFont () | |
| int | widthOfGlyph (uint32 glyph) |
| Return the width of the given glyph. | |
| int | widthOfString (const std::string &str) |
| Return the width of the given string (by adding its glyph widths). | |
| int | height () |
| Return the font height. | |
| BPoint | drawGlyph (BImage &img, const BPoint &point, uint32 glyph, uint16 color, const BRect &clip, BWidget::TextDirection dir=BWidget::DIR_LEFTTORIGHT) |
| Draw a glyph at the given position. | |
| BPoint | drawString (BImage &img, const BPoint &point, const std::string &str, uint16 color, const BRect &clip, BWidget::TextDirection dir=BWidget::DIR_LEFTTORIGHT) |
| Draw a string (by calling drawGlyph() repeatedly). | |
| const FontHeader & | fontHeader () |
| Return the font header. | |
| BFont * | otherSizeFont (int delta) |
| Use the font manager to find the same font in a different size. | |
Static Public Member Functions | |
| bool | readFontHeader (BVirtualFile &f, FontHeader &header) |
| Read the font header from a font file. | |
|
|
|
|
||||||||||||||||||||
|
Create a font from an image and character range. This allows only the use of a single char range; the glyph description array must be (lastchar-firstchar) entries long. |
|
|
Create a font by reading from the given file.
|
|
|
|
|
||||||||||||||||||||||||||||
|
Draw a glyph at the given position. Only the pixels of the glyph inside the clip rectangle are actually drawn. The text direction is actually a rotation. The point gives the top left pixel of the glyph, in glyph coordinates. The returned value is the bottom right pixel of the glyph and can be used as a cursor. |
|
||||||||||||||||||||||||||||
|
Draw a string (by calling drawGlyph() repeatedly).
|
|
|
Return the font header.
|
|
|
Return the font height.
|
|
|
Use the font manager to find the same font in a different size. Delta gives a relative size change (so if this is a 10 pixel font, a delta of -2 would look for an 8 pixel font). If the requested font cannot be found, this is returned. |
|
||||||||||||
|
Read the font header from a font file. This is mainly for inspection of the files in a directory. It allows examination of the header contents (name, height, format flags) without actually having to load the large font bitmap. |
|
|
Return the width of the given glyph.
|
|
|
Return the width of the given string (by adding its glyph widths).
|
1.3-rc3