A typeface represents a size-independent font. More...
#include <juce_Typeface.h>
Public Types | |
using | Ptr = ReferenceCountedObjectPtr< Typeface > |
A handy typedef for a pointer to a typeface. More... | |
Public Member Functions | |
~Typeface () override | |
Destructor. More... | |
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. More... | |
void | decReferenceCount () noexcept |
Decreases the object's reference count. More... | |
bool | decReferenceCountWithoutDeleting () noexcept |
Decreases the object's reference count. More... | |
virtual float | getAscent () const =0 |
Returns the ascent of the font, as a proportion of its height. More... | |
virtual float | getDescent () const =0 |
Returns the descent of the font, as a proportion of its height. More... | |
virtual EdgeTable * | getEdgeTableForGlyph (int glyphNumber, const AffineTransform &transform, float fontHeight) |
Returns a new EdgeTable that contains the path for the given glyph, with the specified transform applied. More... | |
virtual void | getGlyphPositions (const String &text, Array< int > &glyphs, Array< float > &xOffsets)=0 |
Converts a line of text into its glyph numbers and their positions. More... | |
virtual float | getHeightToPointsFactor () const =0 |
Returns the value by which you should multiply a JUCE font-height value to convert it to the equivalent point-size. More... | |
const String & | getName () const noexcept |
Returns the font family of the typeface. More... | |
virtual bool | getOutlineForGlyph (int glyphNumber, Path &path)=0 |
Returns the outline for a glyph. More... | |
int | getReferenceCount () const noexcept |
Returns the object's current reference count. More... | |
virtual float | getStringWidth (const String &text)=0 |
Measures the width of a line of text. More... | |
const String & | getStyle () const noexcept |
Returns the font style of the typeface. More... | |
void | incReferenceCount () noexcept |
Increments the object's reference count. More... | |
virtual bool | isHinted () const |
Returns true if the typeface uses hinting. More... | |
virtual bool | isSuitableForFont (const Font &) const |
Returns true if this typeface can be used to render the specified font. More... | |
Static Public Member Functions | |
static void | clearTypefaceCache () |
Clears any fonts that are currently cached in memory. More... | |
static Ptr | createSystemTypefaceFor (const Font &font) |
Creates a new system typeface. More... | |
static Ptr | createSystemTypefaceFor (const void *fontFileData, size_t fontFileDataSize) |
Attempts to create a font from some raw font file data (e.g. More... | |
static void | scanFolderForFonts (const File &folder) |
On some platforms, this allows a specific path to be scanned. More... | |
static void | setTypefaceCacheSize (int numFontsToCache) |
Changes the number of fonts that are cached in memory. More... | |
Protected Member Functions | |
Typeface (const String &name, const String &style) noexcept | |
void | resetReferenceCount () noexcept |
Resets the reference count to zero without deleting the object. More... | |
Static Protected Member Functions | |
static Ptr | getFallbackTypeface () |
Protected Attributes | |
String | name |
String | style |
Private Attributes | |
CriticalSection | hintingLock |
std::unique_ptr< HintingParams > | hintingParams |
Atomic< int > | refCount { 0 } |
A typeface represents a size-independent font.
This base class is abstract, but calling createSystemTypefaceFor() will return a platform-specific subclass that can be used.
The CustomTypeface subclass allow you to build your own typeface, and to load and save it in the JUCE typeface format.
Normally you should never need to deal directly with Typeface objects - the Font class does everything you typically need for rendering text.
@tags{Graphics}
A handy typedef for a pointer to a typeface.
|
override |
Destructor.
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.
The path should be an unscaled (i.e. normalised to height of 1.0) path for a glyph.
|
static |
Clears any fonts that are currently cached in memory.
Creates a new system typeface.
|
static |
Attempts to create a font from some raw font file data (e.g.
a TTF or OTF file image). The system will take its own internal copy of the data, so you can free the block once this method has returned.
|
inlinenoexceptinherited |
Decreases the object's reference count.
If the count gets to zero, the object will be deleted.
References jassert.
|
inlinenoexceptinherited |
Decreases the object's reference count.
If the count gets to zero, the object will not be deleted, but this method will return true, allowing the caller to take care of deletion.
References jassert.
|
pure 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.
Implemented in juce::CustomTypeface.
|
pure 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.
Implemented in juce::CustomTypeface.
|
virtual |
Returns a new EdgeTable that contains the path for the given glyph, with the specified transform applied.
Reimplemented in juce::CustomTypeface.
|
staticprotected |
|
pure 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!
Implemented in juce::CustomTypeface.
|
pure virtual |
Returns the value by which you should multiply a JUCE font-height value to convert it to the equivalent point-size.
Implemented in juce::CustomTypeface.
|
inlinenoexcept |
Returns the outline for a glyph.
The path returned will be normalised to a font height of 1.0.
Implemented in juce::CustomTypeface.
|
inlinenoexceptinherited |
Returns the object's current reference count.
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!
Implemented in juce::CustomTypeface.
|
inlinenoexcept |
Returns the font style of the typeface.
|
inlinenoexceptinherited |
Increments the object's reference count.
This is done automatically by the smart pointer, but is public just in case it's needed for nefarious purposes.
Referenced by juce::ReferenceCountedObjectPtr< juce::ReferenceCountedObject >::operator=().
|
inlinevirtual |
Returns true if the typeface uses hinting.
Returns true if this typeface can be used to render the specified font.
When called, the font will already have been checked to make sure that its name and style flags match the typeface.
|
inlineprotectednoexceptinherited |
Resets the reference count to zero without deleting the object.
You should probably never need to use this!
|
static |
On some platforms, this allows a specific path to be scanned.
On macOS you can load .ttf and .otf files, otherwise this is only available when using FreeType.
|
static |
Changes the number of fonts that are cached in memory.
|
private |
|
private |
|
protected |
|
protected |