|
JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins
« « « Anklang Documentation |
A typeface that can be populated with custom glyphs. More...
#include "juce_CustomTypeface.h"
Classes | |
| class | GlyphInfo |
Public Member Functions | |
| CustomTypeface () | |
| Creates a new, empty typeface. | |
| CustomTypeface (InputStream &serialisedTypefaceStream) | |
| Loads a typeface from a previously saved stream. | |
| ~CustomTypeface () override | |
| Destructor. | |
| void | clear () |
| Resets this typeface, deleting all its glyphs and settings. | |
| void | setCharacteristics (const String &fontFamily, float ascent, bool isBold, bool isItalic, juce_wchar defaultCharacter) noexcept |
| Sets the vital statistics for the typeface. | |
| void | setCharacteristics (const String &fontFamily, const String &fontStyle, float ascent, juce_wchar defaultCharacter) noexcept |
| Sets the vital statistics for the typeface. | |
| void | addGlyph (juce_wchar character, const Path &path, float width) noexcept |
| Adds a glyph to the typeface. | |
| void | addKerningPair (juce_wchar char1, juce_wchar char2, float extraAmount) noexcept |
| Specifies an extra kerning amount to be used between a pair of characters. | |
| void | addGlyphsFromOtherTypeface (Typeface &typefaceToCopy, juce_wchar characterStartIndex, int numCharacters) noexcept |
| Adds a range of glyphs from another typeface. | |
| bool | writeToStream (OutputStream &outputStream) |
| Saves this typeface as a Juce-formatted font file. | |
| float | getAscent () const override |
| Returns the ascent of the font, as a proportion of its height. | |
| float | getDescent () const override |
| Returns the descent of the font, as a proportion of its height. | |
| float | getHeightToPointsFactor () const override |
| Returns the value by which you should multiply a JUCE font-height value to convert it to the equivalent point-size. | |
| float | getStringWidth (const String &) override |
| Measures the width of a line of text. | |
| void | getGlyphPositions (const String &, Array< int > &glyphs, Array< float > &xOffsets) override |
| Converts a line of text into its glyph numbers and their positions. | |
| bool | getOutlineForGlyph (int glyphNumber, Path &) override |
| Returns the outline for a glyph. | |
| EdgeTable * | getEdgeTableForGlyph (int glyphNumber, const AffineTransform &, float fontHeight) override |
| Returns a new EdgeTable that contains the path for the given glyph, with the specified transform applied. | |
Public Member Functions inherited from juce::Typeface | |
| const String & | getName () const noexcept |
| Returns the font family of the typeface. | |
| const String & | getStyle () const noexcept |
| Returns the font style of the typeface. | |
| ~Typeface () override | |
| Destructor. | |
| virtual bool | isSuitableForFont (const Font &) const |
| Returns true if this typeface can be used to render the specified font. | |
| virtual bool | isHinted () const |
| Returns true if the typeface uses hinting. | |
| void | applyVerticalHintingTransform (float fontHeight, Path &path) |
| Makes an attempt at performing a good overall distortion that will scale a font of the given size to align vertically with the pixel grid. | |
Public Member Functions inherited from juce::ReferenceCountedObject | |
| void | incReferenceCount () noexcept |
| Increments the object's reference count. | |
| void | decReferenceCount () noexcept |
| Decreases the object's reference count. | |
| bool | decReferenceCountWithoutDeleting () noexcept |
| Decreases the object's reference count. | |
| int | getReferenceCount () const noexcept |
| Returns the object's current reference count. | |
Protected Member Functions | |
| virtual bool | loadGlyphIfPossible (juce_wchar characterNeeded) |
| If a subclass overrides this, it can load glyphs into the font on-demand. | |
Protected Member Functions inherited from juce::Typeface | |
| Typeface (const String &name, const String &style) noexcept | |
Protected Member Functions inherited from juce::ReferenceCountedObject | |
| ReferenceCountedObject ()=default | |
| Creates the reference-counted object (with an initial ref count of zero). | |
| ReferenceCountedObject (const ReferenceCountedObject &) noexcept | |
| Copying from another object does not affect this one's reference-count. | |
| ReferenceCountedObject (ReferenceCountedObject &&) noexcept | |
| Copying from another object does not affect this one's reference-count. | |
| ReferenceCountedObject & | operator= (const ReferenceCountedObject &) noexcept |
| Copying from another object does not affect this one's reference-count. | |
| ReferenceCountedObject & | operator= (ReferenceCountedObject &&) noexcept |
| Copying from another object does not affect this one's reference-count. | |
| virtual | ~ReferenceCountedObject () |
| Destructor. | |
| void | resetReferenceCount () noexcept |
| Resets the reference count to zero without deleting the object. | |
Protected Attributes | |
| juce_wchar | defaultCharacter |
| float | ascent |
Protected Attributes inherited from juce::Typeface | |
| String | name |
| String | style |
Additional Inherited Members | |
Public Types inherited from juce::Typeface | |
| using | Ptr = ReferenceCountedObjectPtr< Typeface > |
| A handy typedef for a pointer to a typeface. | |
Static Public Member Functions inherited from juce::Typeface | |
| static Ptr | createSystemTypefaceFor (const Font &font) |
| Creates a new system typeface. | |
| static Ptr | createSystemTypefaceFor (const void *fontFileData, size_t fontFileDataSize) |
| Attempts to create a font from some raw font file data (e.g. | |
| static void | setTypefaceCacheSize (int numFontsToCache) |
| Changes the number of fonts that are cached in memory. | |
| static void | clearTypefaceCache () |
| Clears any fonts that are currently cached in memory. | |
| static void | scanFolderForFonts (const File &folder) |
| On some platforms, this allows a specific path to be scanned. | |
Static Protected Member Functions inherited from juce::Typeface | |
| static Ptr | getFallbackTypeface () |
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.
NOTE! For most people this class is almost certainly NOT the right tool to use! If what you want to do is to embed a font into your exe, then your best plan is probably to embed your TTF/OTF font file into your binary using the Projucer, and then call Typeface::createSystemTypefaceFor() to load it from memory.
@tags{Graphics}
Definition at line 48 of file juce_CustomTypeface.h.
| juce::CustomTypeface::CustomTypeface | ( | ) |
Creates a new, empty typeface.
Definition at line 101 of file juce_CustomTypeface.cpp.
|
explicit |
Loads a typeface from a previously saved stream.
The stream must have been created by writeToStream().
NOTE! Since this class was written, support was added for loading real font files from memory, so for most people, using Typeface::createSystemTypefaceFor() to load a real font is more appropriate than using this class to store it in a proprietary format.
Definition at line 107 of file juce_CustomTypeface.cpp.
|
override |
Destructor.
Definition at line 147 of file juce_CustomTypeface.cpp.
|
noexcept |
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.
Definition at line 179 of file juce_CustomTypeface.cpp.
|
noexcept |
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.
Definition at line 221 of file juce_CustomTypeface.cpp.
|
noexcept |
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.
Definition at line 190 of file juce_CustomTypeface.cpp.
| void juce::CustomTypeface::clear | ( | ) |
Resets this typeface, deleting all its glyphs and settings.
Definition at line 152 of file juce_CustomTypeface.cpp.
|
overridevirtual |
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 juce::Typeface.
Definition at line 296 of file juce_CustomTypeface.cpp.
|
overridevirtual |
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 juce::Typeface.
Definition at line 297 of file juce_CustomTypeface.cpp.
|
overridevirtual |
Returns a new EdgeTable that contains the path for the given glyph, with the specified transform applied.
Reimplemented from juce::Typeface.
Definition at line 379 of file juce_CustomTypeface.cpp.
|
overridevirtual |
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 juce::Typeface.
Definition at line 323 of file juce_CustomTypeface.cpp.
|
overridevirtual |
Returns the value by which you should multiply a JUCE font-height value to convert it to the equivalent point-size.
Implements juce::Typeface.
Definition at line 298 of file juce_CustomTypeface.cpp.
Returns the outline for a glyph.
The path returned will be normalised to a font height of 1.0.
Implements juce::Typeface.
Definition at line 364 of file juce_CustomTypeface.cpp.
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 juce::Typeface.
Definition at line 300 of file juce_CustomTypeface.cpp.
|
protectedvirtual |
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.
Reimplemented in juce::FreeTypeTypeface.
Definition at line 216 of file juce_CustomTypeface.cpp.
|
noexcept |
Sets the vital statistics for the typeface.
| fontFamily | the typeface's font family |
| fontStyle | the typeface's font style |
| 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) |
| defaultCharacter | the character to be used as a replacement if there's no glyph available for the character that's being drawn |
Definition at line 170 of file juce_CustomTypeface.cpp.
|
noexcept |
Sets the vital statistics for the typeface.
| fontFamily | the typeface's font family |
| 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 |
Definition at line 161 of file juce_CustomTypeface.cpp.
| bool juce::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.
NOTE! Since this class was written, support was added for loading real font files from memory, so for most people, using Typeface::createSystemTypefaceFor() to load a real font is more appropriate than using this class to store it in a proprietary format.
Definition at line 258 of file juce_CustomTypeface.cpp.
|
protected |
Definition at line 143 of file juce_CustomTypeface.h.
|
protected |
Definition at line 142 of file juce_CustomTypeface.h.