Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

BFont Class Reference

#include <BFont.h>

Collaboration diagram for BFont:

Collaboration graph
[legend]
List of all members.

Detailed Description

Antialiased, multi character range, bitmap font class.

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 FontHeaderfontHeader ()
 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.


Member Enumeration Documentation

enum BFont::FontFlag
 

Enumeration values:
FLAG_REGULAR 
FLAG_BOLD 
FLAG_OBLIQUE 


Constructor & Destructor Documentation

BFont::BFont const BImage   img,
const GlyphDescription   indices,
int    firstchar,
int    lastchar
 

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.

BFont::BFont BVirtualFile   f
 

Create a font by reading from the given file.

BFont::~BFont  
 


Member Function Documentation

BPoint BFont::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.

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.

BPoint BFont::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& BFont::fontHeader   [inline]
 

Return the font header.

int BFont::height   [inline]
 

Return the font height.

BFont* BFont::otherSizeFont int    delta
 

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.

bool BFont::readFontHeader BVirtualFile   f,
FontHeader   header
[static]
 

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.

int BFont::widthOfGlyph uint32    glyph
 

Return the width of the given glyph.

int BFont::widthOfString const std::string &    str
 

Return the width of the given string (by adding its glyph widths).


The documentation for this class was generated from the following file:
Generated on Sat Dec 29 10:00:21 2007 for DSGUI by doxygen1.3-rc3