A typeface that can be populated with custom glyphs. More...
Inherits Typeface.
Public Member Functions | |
| CustomTypeface () | |
| Creates a new, empty typeface. | |
| CustomTypeface (InputStream &serialisedTypefaceStream) | |
| Loads a typeface from a previously saved stream. | |
| ~CustomTypeface () | |
| Destructor. | |
| void | clear () |
| Resets this typeface, deleting all its glyphs and settings. | |
| void | setCharacteristics (const String &name, float ascent, bool isBold, bool isItalic, juce_wchar defaultCharacter) throw () |
| Sets the vital statistics for the typeface. | |
| void | addGlyph (juce_wchar character, const Path &path, float width) throw () |
| Adds a glyph to the typeface. | |
| void | addKerningPair (juce_wchar char1, juce_wchar char2, float extraAmount) throw () |
| Specifies an extra kerning amount to be used between a pair of characters. | |
| void | addGlyphsFromOtherTypeface (Typeface &typefaceToCopy, juce_wchar characterStartIndex, int numCharacters) throw () |
| Adds a range of glyphs from another typeface. | |
| bool | writeToStream (OutputStream &outputStream) |
| Saves this typeface as a Juce-formatted font file. | |
| float | getAscent () const |
| Returns the ascent of the font, as a proportion of its height. | |
| float | getDescent () const |
| Returns the descent of the font, as a proportion of its height. | |
| float | getStringWidth (const String &text) |
| Measures the width of a line of text. | |
| void | getGlyphPositions (const String &text, Array< int > &glyphs, Array< float > &xOffsets) |
| Converts a line of text into its glyph numbers and their positions. | |
| bool | getOutlineForGlyph (int glyphNumber, Path &path) |
| Returns the outline for a glyph. | |
| int | getGlyphForCharacter (juce_wchar character) |
Protected Member Functions | |
| virtual bool | loadGlyphIfPossible (juce_wchar characterNeeded) |
| If a subclass overrides this, it can load glyphs into the font on-demand. | |
Protected Attributes | |
| juce_wchar | defaultCharacter |
| float | ascent |
| bool | isBold |
| bool | isItalic |
A typeface that can be populated with custom glyphs.
You can create a CustomTypeface if you need one that contains your own glyphs, or if you need to load a typeface from a Juce-formatted binary stream.
If you want to create a copy of a native face, you can use addGlyphsFromOtherTypeface() to copy glyphs into this face.
| CustomTypeface::CustomTypeface | ( | ) |
Creates a new, empty typeface.
| CustomTypeface::CustomTypeface | ( | InputStream & | serialisedTypefaceStream | ) | [explicit] |
Loads a typeface from a previously saved stream.
The stream must have been created by writeToStream().
| CustomTypeface::~CustomTypeface | ( | ) |
Destructor.
| void CustomTypeface::clear | ( | ) |
Resets this typeface, deleting all its glyphs and settings.
| void CustomTypeface::setCharacteristics | ( | const String & | name, | |
| float | ascent, | |||
| bool | isBold, | |||
| bool | isItalic, | |||
| juce_wchar | defaultCharacter | |||
| ) | throw () |
Sets the vital statistics for the typeface.
| name | the typeface's name | |
| ascent | the ascent - this is normalised to a height of 1.0 and this is the value that will be returned by Typeface::getAscent(). The descent is assumed to be (1.0 - ascent) | |
| isBold | should be true if the typeface is bold | |
| isItalic | should be true if the typeface is italic | |
| defaultCharacter | the character to be used as a replacement if there's no glyph available for the character that's being drawn |
| void CustomTypeface::addGlyph | ( | juce_wchar | character, | |
| const Path & | path, | |||
| float | width | |||
| ) | throw () |
Adds a glyph to the typeface.
The path that is passed in is normalised so that the font height is 1.0, and its origin is the anchor point of the character on its baseline.
The width is the nominal width of the character, and any extra kerning values that are specified will be added to this width.
| void CustomTypeface::addKerningPair | ( | juce_wchar | char1, | |
| juce_wchar | char2, | |||
| float | extraAmount | |||
| ) | throw () |
Specifies an extra kerning amount to be used between a pair of characters.
The amount will be added to the nominal width of the first character when laying out a string.
| void CustomTypeface::addGlyphsFromOtherTypeface | ( | Typeface & | typefaceToCopy, | |
| juce_wchar | characterStartIndex, | |||
| int | numCharacters | |||
| ) | throw () |
Adds a range of glyphs from another typeface.
This will attempt to pull in the paths and kerning information from another typeface and add it to this one.
| bool CustomTypeface::writeToStream | ( | OutputStream & | outputStream | ) |
Saves this typeface as a Juce-formatted font file.
A CustomTypeface can be created to reload the data that is written - see the CustomTypeface constructor.
| float CustomTypeface::getAscent | ( | ) | const [virtual] |
Returns the ascent of the font, as a proportion of its height.
The height is considered to always be normalised as 1.0, so this will be a value less that 1.0, indicating the proportion of the font that lies above its baseline.
Implements Typeface.
| float CustomTypeface::getDescent | ( | ) | const [virtual] |
Returns the descent of the font, as a proportion of its height.
The height is considered to always be normalised as 1.0, so this will be a value less that 1.0, indicating the proportion of the font that lies below its baseline.
Implements Typeface.
| float CustomTypeface::getStringWidth | ( | const String & | text | ) | [virtual] |
Measures the width of a line of text.
The distance returned is based on the font having an normalised height of 1.0.
You should never need to call this directly! Use Font::getStringWidth() instead!
Implements Typeface.
| void CustomTypeface::getGlyphPositions | ( | const String & | text, | |
| Array< int > & | glyphs, | |||
| Array< float > & | xOffsets | |||
| ) | [virtual] |
Converts a line of text into its glyph numbers and their positions.
The distances returned are based on the font having an normalised height of 1.0.
You should never need to call this directly! Use Font::getGlyphPositions() instead!
Implements Typeface.
| bool CustomTypeface::getOutlineForGlyph | ( | int | glyphNumber, | |
| Path & | path | |||
| ) | [virtual] |
Returns the outline for a glyph.
The path returned will be normalised to a font height of 1.0.
Implements Typeface.
| int CustomTypeface::getGlyphForCharacter | ( | juce_wchar | character | ) |
| virtual bool CustomTypeface::loadGlyphIfPossible | ( | juce_wchar | characterNeeded | ) | [protected, virtual] |
If a subclass overrides this, it can load glyphs into the font on-demand.
When methods such as getGlyphPositions() or getOutlineForGlyph() are asked for a particular character and there's no corresponding glyph, they'll call this method so that a subclass can try to add that glyph, returning true if it manages to do so.
juce_wchar CustomTypeface::defaultCharacter [protected] |
float CustomTypeface::ascent [protected] |
bool CustomTypeface::isBold [protected] |
bool CustomTypeface::isItalic [protected] |
1.6.3