Represents a typeface including its family, style and size. More...
Public Member Functions | |
BFont () | |
Creates a BFont object initialized to be_plain_font . | |
BFont (const BFont &font) | |
Creates and initializes a BFont object from another BFont object. | |
BFont (const BFont *font) | |
Creates and initializes a BFont object from a pointer to a BFont object. | |
unicode_block | Blocks () const |
Gets a unicode_block object that identifies the Unicode blocks supported by this font face and family. | |
BRect | BoundingBox () const |
Gets a BRect that encloses the font text. | |
int32 | CountTuned () const |
Gets the number of tuned fonts for the font family and style. | |
font_direction | Direction () const |
Gets the font direction, left-to-right or right-to left. | |
uint8 | Encoding () const |
Gets the character encoding constant. | |
uint16 | Face () const |
Gets the font face flags bitmap. | |
float | FalseBoldWidth () const |
Gets the width of the font as if it were bold. | |
uint32 | FamilyAndStyle () const |
Gets the code of the font family and style combination. | |
font_file_format | FileFormat () const |
Gets whether the font is a TrueType™ or PostScript™ Type1 font. | |
uint32 | Flags () const |
Gets the antialiasing flags. | |
void | GetBoundingBoxesAsGlyphs (const char charArray[], int32 numChars, font_metric_mode mode, BRect boundingBoxArray[]) const |
Writes an array of BRect objects to boundingBoxArray representing the bounding rectangles of each character in charArray. | |
void | GetBoundingBoxesAsString (const char charArray[], int32 numChars, font_metric_mode mode, escapement_delta *delta, BRect boundingBoxArray[]) const |
Writes an array of BRect objects to boundingBoxArray representing the bounding rectangles of each character in charArray with consideration to the horizontal space provided by the escapement delta. | |
void | GetBoundingBoxesForStrings (const char *stringArray[], int32 numStrings, font_metric_mode mode, escapement_delta deltas[], BRect boundingBoxArray[]) const |
Writes an array of BRect objects to boundingBoxArray representing the bounding rectangles of each string in stringArray with consideration to the horizontal space provided by the escapement deltas. | |
void | GetEdges (const char charArray[], int32 numBytes, edge_info edgeArray[]) const |
Determines the edge information for each character in charArray and writes the result in edgeArray. | |
void | GetEscapements (const char charArray[], int32 numChars, escapement_delta *delta, BPoint escapementArray[]) const |
Determines the escapements for each char in charArray and writes the result in escapementArray as an array of BPoint objects with consideration to the horizontal space provided by the escapement delta. | |
void | GetEscapements (const char charArray[], int32 numChars, escapement_delta *delta, BPoint escapementArray[], BPoint offsetArray[]) const |
Determines the escapements for each char in charArray and writes the result in escapementArray as an array of BPoint objects with consideration to the horizontal space provided by the escapement delta and writes the offsets to offsetArray. | |
void | GetEscapements (const char charArray[], int32 numChars, escapement_delta *delta, float escapementArray[]) const |
Determines the escapements for each char in charArray and writes the result in escapementArray with consideration to the horizontal space provided by the escapement delta. | |
void | GetEscapements (const char charArray[], int32 numChars, float escapementArray[]) const |
Determines the escapements for each char in charArray and writes the result in escapementArray. | |
void | GetFamilyAndStyle (font_family *family, font_style *style) const |
Writes out the name of the font family and/or font style. | |
void | GetGlyphShapes (const char charArray[], int32 numChars, BShape *glyphShapeArray[]) const |
Writes an array of BShape objects to glyphShapeArray representing the glyph shapes of each character in charArray. | |
void | GetHasGlyphs (const char charArray[], int32 numChars, bool hasArray[]) const |
Fills out hasArray with whether or not the font has a glyph for each character in charArray. | |
void | GetHasGlyphs (const char charArray[], int32 numChars, bool hasArray[], bool useFallbacks) const |
Fills out hasArray with whether or not the font has a glyph for each character in charArray. | |
void | GetHeight (font_height *height) const |
Fills out the font_height struct with the amount of vertical space surrounding a character. | |
void | GetStringWidths (const char *stringArray[], const int32 lengthArray[], int32 numStrings, float widthArray[]) const |
Determines the amount of space required to draw each string in stringArray and writes the result in widthArray. | |
void | GetTruncatedStrings (const char *stringArray[], int32 numStrings, uint32 mode, float width, BString resultArray[]) const |
Write truncated BString objects to resultArray given source BString objects in stringArray. | |
void | GetTruncatedStrings (const char *stringArray[], int32 numStrings, uint32 mode, float width, char *resultArray[]) const |
Write truncated strings to resultArray given source BString objects in stringArray. | |
void | GetTunedInfo (int32 index, tuned_font_info *info) const |
Writes information about the tuned font at index into info. | |
bool | IncludesBlock (uint32 start, uint32 end) const |
Gets whether the font includes the specified Unicode block. | |
bool | IsFixed () const |
Gets whether or not the font is fixed width. | |
bool | IsFullAndHalfFixed () const |
Returns whether or not the font is fixed-width and contains both full and half-width characters. | |
bool | operator!= (const BFont &font) const |
Inequality comparison overload method. | |
BFont & | operator= (const BFont &font) |
Assignment overload method. | |
bool | operator== (const BFont &font) const |
Equality comparison overload method. | |
void | PrintToStream () const |
Writes information about the font to stdout . | |
float | Rotation () const |
Gets the font rotation. | |
void | SetEncoding (uint8 encoding) |
Sets the character encoding of the font for example B_UNICODE_UTF8 or B_ISO_8859_1 . | |
void | SetFace (uint16 face) |
Sets the font face according to the flags set by face. | |
void | SetFalseBoldWidth (float width) |
Sets the false bold width. | |
status_t | SetFamilyAndFace (const font_family family, uint16 face) |
Sets the font's family and face all at once. | |
status_t | SetFamilyAndStyle (const font_family family, const font_style style) |
Sets the font's family and style all at once. | |
void | SetFamilyAndStyle (uint32 code) |
Sets the font's family and style from a font identifier. | |
void | SetFlags (uint32 flags) |
Sets font flags controlling antialiasing. | |
void | SetRotation (float rotation) |
Sets the font rotation from the baseline in degrees. | |
void | SetShear (float shear) |
Sets the angle in degrees relative to the baseline. | |
void | SetSize (float size) |
Sets the font size. | |
void | SetSpacing (uint8 spacing) |
Sets how characters are horizontally spaced relative to each other. | |
float | Shear () const |
Gets the font shear. | |
float | Size () const |
Gets the font size. | |
uint8 | Spacing () const |
Gets the spacing constant. | |
float | StringWidth (const char *string) const |
Determines the amount of space required to draw string in the current font. | |
float | StringWidth (const char *string, int32 length) const |
Determines the amount of space required to draw string in the current font up to length characters. | |
void | TruncateString (BString *inOut, uint32 mode, float width) const |
Truncates inOut to be no longer than width using the supplied truncation mode. | |
Represents a typeface including its family, style and size.
The Interface Kit provides three prebuilt BFont objects which can be used but not modified.
const
BFont* be_plain_font
A plain font used by many controls.const
BFont* be_bold_font
A bold font used by titles.const
BFont* be_fixed_font
A fixed-width font.A BFont object does nothing on its own but is used in combination with a view or control. Here is an example of creating a BFont object from a system font and assigning it to a view:
You may also create a BFont object from a view, modify it and reassign it back to the view like this:
You can change the way a font renders with the SetFamilyAndStyle(), SetFamilyAndFace(), SetSize(), SetShear(), SetRotation(), SetFalseBoldWidth(), SetSpacing(), SetEncoding(), SetFace(), and SetFlags() methods.
More information about the space taken up by a font can be determined by querying a BFont object using the following methods: StringWidth(), GetStringWidths() GetEscapements(), GetEdges(), GetHeight(), BoundingBox() GetBoundingBoxesAsGlyphs(), GetBoundingBoxesAsString(), and GetBoundingBoxesForStrings().
You can also perform intelligent string truncation with the TruncateString() and GetTruncatedStrings() methods.
BFont::BFont | ( | ) |
BFont::BFont | ( | const BFont & | font | ) |
BFont::BFont | ( | const BFont * | font | ) |
unicode_block BFont::Blocks | ( | ) | const |
Gets a unicode_block
object that identifies the Unicode blocks supported by this font face and family.
unicode_block
object containing supported Unicode blocks.BRect BFont::BoundingBox | ( | ) | const |
int32 BFont::CountTuned | ( | ) | const |
Gets the number of tuned fonts for the font family and style.
font_direction BFont::Direction | ( | ) | const |
Gets the font direction, left-to-right or right-to left.
uint8 BFont::Encoding | ( | ) | const |
Gets the character encoding constant.
uint16 BFont::Face | ( | ) | const |
float BFont::FalseBoldWidth | ( | ) | const |
Gets the width of the font as if it were bold.
uint32 BFont::FamilyAndStyle | ( | ) | const |
Gets the code of the font family and style combination.
font_file_format BFont::FileFormat | ( | ) | const |
Gets whether the font is a TrueType™ or PostScript™ Type1 font.
font_file_format
struct containing the font file format.uint32 BFont::Flags | ( | ) | const |
void BFont::GetBoundingBoxesAsGlyphs | ( | const char | charArray[], |
int32 | numChars, | ||
font_metric_mode | mode, | ||
BRect | boundingBoxArray[] | ||
) | const |
Writes an array of BRect objects to boundingBoxArray representing the bounding rectangles of each character in charArray.
Each BRect object corresponds to the glyph of one character.
The font_metric_mode
should contain one of the following values:
B_SCREEN_METRIC
The bounding boxes should use the screen metric.B_PRINTING_METRIC
The bounding boxes should use the print metric.charArray | The source character array. |
numChars | The number of characters to consider in charArray. |
mode | The font_metric_mode to use, screen or printing. |
boundingBoxArray | The destination array of BRect bounding boxes. |
void BFont::GetBoundingBoxesAsString | ( | const char | charArray[], |
int32 | numChars, | ||
font_metric_mode | mode, | ||
escapement_delta * | delta, | ||
BRect | boundingBoxArray[] | ||
) | const |
Writes an array of BRect objects to boundingBoxArray representing the bounding rectangles of each character in charArray with consideration to the horizontal space provided by the escapement delta.
Each BRect object corresponds to the glyph of one character.
The font_metric_mode
should contain one of the following values:
B_SCREEN_METRIC
The bounding boxes should use the screen metric.B_PRINTING_METRIC
The bounding boxes should use the print metric.The provided escapement delta is applied as part of the bounding box calculations. This lets you specify a character spacing is looser or tighter than normal.
The escapement_delta structure contains the following values:
nonspace
The amount of horizontal space to surround a visible glyph character with.space
The amount of horizontal space to surround a whitespace character with, for example B_TAB
or B_SPACE
.charArray | The source character array. |
numChars | The number of characters to consider in charArray. |
mode | The font_metric_mode to use, screen or printing. |
delta | The escapement_delta structure to use. |
boundingBoxArray | The destination array of BRect bounding boxes. |
void BFont::GetBoundingBoxesForStrings | ( | const char * | stringArray[], |
int32 | numStrings, | ||
font_metric_mode | mode, | ||
escapement_delta | deltas[], | ||
BRect | boundingBoxArray[] | ||
) | const |
Writes an array of BRect objects to boundingBoxArray representing the bounding rectangles of each string in stringArray with consideration to the horizontal space provided by the escapement deltas.
Each BRect object corresponds to the bounding box of the entire string.
The font_metric_mode
should contain one of the following values:
B_SCREEN_METRIC
The bounding boxes should use the screen metric.B_PRINTING_METRIC
The bounding boxes should use the print metric.The provided escapement deltas are applied as part of the bounding box calculations. This lets you specify a character spacing is looser or tighter than normal.
The escapement_delta structure contains the following values:
nonspace
The amount of horizontal space to surround a visible glyph character with.space
The amount of horizontal space to surround a whitespace character with, for example B_TAB
or B_SPACE
.stringArray | The source string array. |
numStrings | The number of strings to consider in stringArray. |
mode | The font_metric_mode to use, screen or printing. |
deltas | The array of escapement_delta structures to use. |
boundingBoxArray | The destination array of BRect bounding boxes. |
Determines the edge information for each character in charArray and writes the result in edgeArray.
The edge_info
struct contains the following values:
left
The distance that the character outline is inset from the left escapement boundary.right
The distance that the character outline is inset from the right escapement boundary.charArray | The source character array. |
numChars | The number of characters to consider in charArray. |
edgeArray | The destination array of edge_info structs. |
void BFont::GetEscapements | ( | const char | charArray[], |
int32 | numChars, | ||
escapement_delta * | delta, | ||
BPoint | escapementArray[] | ||
) | const |
Determines the escapements for each char in charArray and writes the result in escapementArray as an array of BPoint objects with consideration to the horizontal space provided by the escapement delta.
The escapement_delta structure contains the following values:
nonspace
The amount of horizontal space to surround a visible glyph character with.space
The amount of horizontal space to surround a whitespace character with, for example B_TAB
or B_SPACE
.charArray | The source character array. |
numChars | The number of characters to consider in charArray. |
delta | The escapement_delta structure to use. |
escapementArray | The destination array of escapements as BPoint objects. |
void BFont::GetEscapements | ( | const char | charArray[], |
int32 | numChars, | ||
escapement_delta * | delta, | ||
BPoint | escapementArray[], | ||
BPoint | offsetArray[] | ||
) | const |
Determines the escapements for each char in charArray and writes the result in escapementArray as an array of BPoint objects with consideration to the horizontal space provided by the escapement delta and writes the offsets to offsetArray.
The escapement_delta structure contains the following values:
nonspace
The amount of horizontal space to surround a visible glyph character with.space
The amount of horizontal space to surround a whitespace character with, for example B_TAB
or B_SPACE
.charArray | The source character array. |
numChars | The number of characters to consider in charArray. |
delta | The escapement_delta structure to use. |
escapementArray | The destination array of escapements as BPoint objects. |
offsetArray | The destination array of offsets as BPoint objects. |
void BFont::GetEscapements | ( | const char | charArray[], |
int32 | numChars, | ||
escapement_delta * | delta, | ||
float | escapementArray[] | ||
) | const |
Determines the escapements for each char in charArray and writes the result in escapementArray with consideration to the horizontal space provided by the escapement delta.
The escapement_delta structure contains the following values:
nonspace
The amount of horizontal space to surround a visible glyph character with.space
The amount of horizontal space to surround a whitespace character with, for example B_TAB
or B_SPACE
.charArray | The source character array. |
numChars | The number of characters to consider in charArray. |
delta | The escapement_delta structure to use. |
escapementArray | The destination array to put the escapements. |
void BFont::GetEscapements | ( | const char | charArray[], |
int32 | numChars, | ||
float | escapementArray[] | ||
) | const |
Determines the escapements for each char in charArray and writes the result in escapementArray.
charArray | The source character array. |
numChars | The number of characters to consider in charArray. |
escapementArray | The destination array to put the escapements. |
void BFont::GetFamilyAndStyle | ( | font_family * | family, |
font_style * | style | ||
) | const |
Writes out the name of the font family and/or font style.
This method may be called with either family or style set to NULL
in order to get one or the other.
family | A font_family pointer to be filled out. |
style | A font_style pointer to be filled out. |
void BFont::GetGlyphShapes | ( | const char | charArray[], |
int32 | numChars, | ||
BShape * | glyphShapeArray[] | ||
) | const |
Writes an array of BShape objects to glyphShapeArray representing the glyph shapes of each character in charArray.
Each BShape object corresponds to the glyph of one character.
charArray | The source character array. |
numChars | The number of characters to consider in charArray. |
glyphShapeArray | The destination array of BShape glyphs. |
void BFont::GetHasGlyphs | ( | const char | charArray[], |
int32 | numChars, | ||
bool | hasArray[] | ||
) | const |
Fills out hasArray with whether or not the font has a glyph for each character in charArray.
true
is written in hasArray if a glyph is found for the character, false
otherwise.
true
if the queried font does not provide a glyph for a character but a fallback font does.charArray | The source character array. |
numChars | The number of characters to consider in charArray. |
hasArray | The destination array of booleans. |
void BFont::GetHasGlyphs | ( | const char | charArray[], |
int32 | numChars, | ||
bool | hasArray[], | ||
bool | useFallbacks | ||
) | const |
Fills out hasArray with whether or not the font has a glyph for each character in charArray.
true
is written in hasArray if the character has a glyph in the current font and false
otherwise. Fallback fonts are also considered in the search if useFallbacks is true
.
charArray | The source character array. |
numChars | The number of characters to consider in charArray. |
hasArray | The destination array of booleans. |
useFallbacks | Whether to consider fallback fonts in the answer. |
void BFont::GetHeight | ( | font_height * | _height | ) | const |
Fills out the font_height
struct with the amount of vertical space surrounding a character.
The font_height
struct contains the following values:
ascent
The distance characters can ascend above the baseline.descent
The distance characters can descend below the baseline.leading
The distance between lines, descent above to ascent below._height | The font_height struct to fill out. |
void BFont::GetStringWidths | ( | const char * | stringArray[], |
const int32 | lengthArray[], | ||
int32 | numStrings, | ||
float | widthArray[] | ||
) | const |
Determines the amount of space required to draw each string in stringArray and writes the result in widthArray.
stringArray | The source string array. |
lengthArray | The number of characters to consider for each string in stringArray |
numStrings | The number of strings in stringArray. |
widthArray | The destination array to put the widths required to draw each string. |
void BFont::GetTruncatedStrings | ( | const char * | stringArray[], |
int32 | numStrings, | ||
uint32 | mode, | ||
float | width, | ||
BString | resultArray[] | ||
) | const |
Write truncated BString objects to resultArray given source BString objects in stringArray.
The following truncation modes are supported:
B_TRUNCATE_BEGINNING
Truncate from the beginning of the string.B_TRUNCATE_MIDDLE
Truncate from the middle of the string.B_TRUNCATE_END
Truncate from the end of the string.B_TRUNCATE_SMART
Truncate from anywhere, but do so so that each string is made unique after being truncated.stringArray | The source string array. |
numStrings | The number of strings in stringArray. |
mode | Truncation mode to use. |
width | The maximum width to truncate to. |
resultArray | The destination string array. |
void BFont::GetTruncatedStrings | ( | const char * | stringArray[], |
int32 | numStrings, | ||
uint32 | mode, | ||
float | width, | ||
char * | resultArray[] | ||
) | const |
Write truncated strings to resultArray given source BString objects in stringArray.
resultArray is an array of pointers to string buffers which should be allocated ahead of time and should be at least 3 bytes longer than the matching input string. The 3 extra bytes provide enough room for the truncated output given that GetTruncatedStrings() truncates only a single-byte character from the input string and replaces it with an ellipsis character (which takes three bytes for the UTF-8 encoding), and adds a NUL-terminator
.
The following truncation modes are supported:
B_TRUNCATE_BEGINNING
Truncate from the beginning of the string.B_TRUNCATE_MIDDLE
Truncate from the middle of the string.B_TRUNCATE_END
Truncate from the end of the string.B_TRUNCATE_SMART
Truncate from anywhere, but do so so that each string is made unique after being truncated.stringArray | The source string array. |
numStrings | The number of strings in stringArray. |
mode | Truncation mode to use. |
width | The maximum width to truncate to. |
resultArray | The destination string array. |
void BFont::GetTunedInfo | ( | int32 | index, |
tuned_font_info * | info | ||
) | const |
Writes information about the tuned font at index into info.
The index begins at 0 and counts tuned fonts for current font family and style only.
index | The index of desired tuned font. |
info | The turned_font_info struct to be filled out. |
Gets whether the font includes the specified Unicode block.
bool BFont::IsFixed | ( | ) | const |
Gets whether or not the font is fixed width.
true
if the font is fixed width, false
otherwise.bool BFont::IsFullAndHalfFixed | ( | ) | const |
Returns whether or not the font is fixed-width and contains both full and half-width characters.
A full-and-half-fixed font is one that contains characters of only two sizes, so that CJK languages can be properly supported.
bool BFont::operator!= | ( | const BFont & | font | ) | const |
Inequality comparison overload method.
font | The BFont object to compare the current font to. |
true
if the fonts objects are NOT identical, true
otherwise.bool BFont::operator== | ( | const BFont & | font | ) | const |
Equality comparison overload method.
font | The BFont object to compare the current font to. |
true
if the fonts objects are identical, false
otherwise.void BFont::PrintToStream | ( | ) | const |
Writes information about the font to stdout
.
printf("BFont { %s (%d), %s (%d) 0x%x %f/%f %fpt (%f %f %f), %d }\n", family, fFamilyID, style, fStyleID, fFace, fShear, fRotation, fSize, fHeight.ascent, fHeight.descent, fHeight.leading, fEncoding);
float BFont::Rotation | ( | ) | const |
Gets the font rotation.
void BFont::SetEncoding | ( | uint8 | encoding | ) |
Sets the character encoding of the font for example B_UNICODE_UTF8
or B_ISO_8859_1
.
The following character encodings are supported:
B_UNICODE_UTF8
B_ISO_8859_1
aka Latin 1 aka "Western European".B_ISO_8859_2
aka Latin 2 aka "Eastern European".B_ISO_8859_3
aka Latin 3 aka "South European".B_ISO_8859_4
aka Latin 4 aka "Northern European".B_ISO_8859_5
aka "Latin/Cyrillic".B_ISO_8859_6
aka "Latin/Arabic".B_ISO_8859_7
aka "Latin/Greek".B_ISO_8859_8
aka "Latin/Hebrew".B_ISO_8859_9
aka Latin 5 aka "Latin/Turkish".B_ISO_8859_10
aka Latin 6 aka "Nordic".B_MACINTOSH_ROMAN
UTF-8 is the standard encoding used by classes in the Interface Kit. It is part of the Unicode® standard and allows Haiku to represent characters from all over the world while maintaining backwards compatibility with 7-bit ASCII codes.
Each of the encodings extend the ASCII codes and differ from each other only when the highest bit is set to 1, in other words, the value is greater than 127. Furthermore each of the encodings except for UTF-8 are represented by a single byte and consequently encompass a limited set of characters. Most of the encodings are in the ISO/IEC 8859 family of character codes with the notable exception of Macintosh Roman which is the standard encoding used by the classic Mac OS®.
If the value of the first byte of a UTF-8 character is greater than 127 it indicates that the character is a multibyte character and therefore you must look at the next byte (and possibly the third byte, or rarely even forth byte) to get the whole character.
Setting the character encoding on a view determines how BView::DrawString() interprets the values passed to it and also how BView::KeyDown() interprets the values representing the keys that the user presses.
encoding | The character encoding to set the font to. |
void BFont::SetFace | ( | uint16 | face | ) |
Sets the font face according to the flags set by face.
The following font face flags are supported:
B_ITALIC_FACE
Characters are slanted to the right.B_UNDERSCORE_FACE
Characters are underlined.B_NEGATIVE_FACE
High and low colors are reversed when drawing characters.B_OUTLINED_FACE
Characters are drawn hollowed out.B_STRIKEOUT_FACE
A horizontal line is drawn through their middle.B_BOLD_FACE
Characters are bold.B_REGULAR_FACE
Characters are drawn normally.B_CONDENSED_FACE
Characters are drawn condensed. Not in BeOS 5.B_LIGHT_FACE
Characters are drawn thiner than normal. Not in BeOS 5.B_HEAVY_FACE
Characters are drawn heavier than normal. Not in BeOS 5.face | The bitmap of font face flags to set. |
void BFont::SetFalseBoldWidth | ( | float | width | ) |
Sets the false bold width.
width | The false bold width to set. |
Sets the font's family and face all at once.
family | Font family to set. |
face | Font face to set. |
B_OK
on success or an error code. B_ERROR | Family does not exists or face has an invalid value. |
status_t BFont::SetFamilyAndStyle | ( | const font_family | family, |
const font_style | style | ||
) |
Sets the font's family and style all at once.
family | Font family to set. |
style | Font style to set. |
B_OK
on success or an error code. B_BAD_VALUE | family is NULL and style is NULL . |
B_NAME_NOT_FOUND | Family or style do not exist. |
void BFont::SetFamilyAndStyle | ( | uint32 | code | ) |
Sets the font's family and style from a font identifier.
code | Unique font identifier obtained from the server. |
void BFont::SetFlags | ( | uint32 | flags | ) |
Sets font flags controlling antialiasing.
The following flags are supported:
B_DISABLE_ANTIALIASING
Disable antialiasing.B_FORCE_ANTIALIASING
Force antialiasing.flags | The bitmap of flags to set. |
void BFont::SetRotation | ( | float | rotation | ) |
Sets the font rotation from the baseline in degrees.
The default baseline is 0° and rotates counterclockwise. Rotation is not supported by BTextView.
rotation | The rotation in degrees to set the font to. |
void BFont::SetShear | ( | float | shear | ) |
Sets the angle in degrees relative to the baseline.
The default shear is 90.0° measured counterclockwise. The shear range is from 45.0° to 135.0°.
shear | The shear in degrees to set the font to. |
void BFont::SetSize | ( | float | size | ) |
Sets the font size.
size | The point size to set the font to. |
void BFont::SetSpacing | ( | uint8 | spacing | ) |
Sets how characters are horizontally spaced relative to each other.
B_CHAR_SPACING
Position each character without adjustment. Best mode for printing. Characters may collide or overlap at small font sizes.B_STRING_SPACING
Optimizes the position of each character within its space. Collisions are unlikely but characters may touch each other. Best mode to use when the screen needs to match what appears on the printed page. Adding new characters requires the entire string to be redrawn.B_BITMAP_SPACING
The widths of the characters are chosen so that they never collide and rarely touch. Best mode for drawing small amounts of text. Character widths are integral values. Spacing on screen will not match spacing used by B_CHAR_SPACING
mode for printing.B_FIXED_SPACING
Positions characters at a constant width. Must be used with fixed-width fonts otherwise B_CHAR_SPACING
mode is used. All characters have an identical integral escapement.B_STRING_SPACING
and B_BITMAP_SPACING
modes are relevant only for font sizes from 7.0pt to 18.0pt, above and below that range B_CHAR_SPACING
produces nicer results. B_CHAR_SPACING
is also always used for rotated or sheared text and when antialiasing is disabled.
spacing | The spacing mode to set. |
float BFont::Shear | ( | ) | const |
Gets the font shear.
float BFont::Size | ( | ) | const |
uint8 BFont::Spacing | ( | ) | const |
float BFont::StringWidth | ( | const char * | string | ) | const |
Determines the amount of space required to draw string in the current font.
string | The source string. |
float BFont::StringWidth | ( | const char * | string, |
int32 | length | ||
) | const |
Determines the amount of space required to draw string in the current font up to length characters.
string | The source string. |
length | The number of characters in string to consider. |
Truncates inOut to be no longer than width using the supplied truncation mode.
The following truncation modes are supported:
B_NO_TRUNCATION
Does nothing.B_TRUNCATE_BEGINNING
Truncate from the beginning of the string.B_TRUNCATE_MIDDLE
Truncate from the middle of the string.B_TRUNCATE_END
Truncate from the end of the string.B_TRUNCATE_SMART
Truncate from anywhere, but do so so that each string is made unique after being truncated.inOut | The BString to truncate. |
mode | Truncation mode to use. |
width | The maximum width to truncate to. |