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
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
juce::Typeface Class Referenceabstract

A typeface represents a size-independent font. More...

#include "juce_Typeface.h"

Inheritance diagram for juce::Typeface:
juce::ReferenceCountedObject juce::CustomTypeface juce::FreeTypeTypeface

Classes

struct  HintingParams
 

Public Types

using Ptr = ReferenceCountedObjectPtr< Typeface >
 A handy typedef for a pointer to a typeface.
 

Public Member Functions

const StringgetName () const noexcept
 Returns the font family of the typeface.
 
const StringgetStyle () 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 float getAscent () const =0
 Returns the ascent of the font, as a proportion of its height.
 
virtual float getDescent () const =0
 Returns the descent of the font, as a proportion of its height.
 
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.
 
virtual float getStringWidth (const String &text)=0
 Measures the width of a line of text.
 
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.
 
virtual bool getOutlineForGlyph (int glyphNumber, Path &path)=0
 Returns the outline for a glyph.
 
virtual EdgeTablegetEdgeTableForGlyph (int glyphNumber, const AffineTransform &transform, float fontHeight)
 Returns a new EdgeTable that contains the path for the given glyph, with the specified transform applied.
 
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.
 

Static Public Member Functions

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.
 

Protected Member Functions

 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.
 
ReferenceCountedObjectoperator= (const ReferenceCountedObject &) noexcept
 Copying from another object does not affect this one's reference-count.
 
ReferenceCountedObjectoperator= (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.
 

Static Protected Member Functions

static Ptr getFallbackTypeface ()
 

Protected Attributes

String name
 
String style
 

Detailed Description

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.

See also
CustomTypeface, Font

@tags{Graphics}

Definition at line 46 of file juce_Typeface.h.

Member Typedef Documentation

◆ Ptr

A handy typedef for a pointer to a typeface.

Definition at line 51 of file juce_Typeface.h.

Constructor & Destructor Documentation

◆ Typeface()

juce::Typeface::Typeface ( const String name,
const String style 
)
protectednoexcept

Definition at line 235 of file juce_Typeface.cpp.

Member Function Documentation

◆ applyVerticalHintingTransform()

void juce::Typeface::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.

The path should be an unscaled (i.e. normalised to height of 1.0) path for a glyph.

Definition at line 221 of file juce_Typeface.cpp.

◆ clearTypefaceCache()

void juce::Typeface::clearTypefaceCache ( )
static

Clears any fonts that are currently cached in memory.

Definition at line 175 of file juce_Font.cpp.

◆ createSystemTypefaceFor() [1/2]

Typeface::Ptr juce::Typeface::createSystemTypefaceFor ( const Font font)
static

Creates a new system typeface.

Definition at line 83 of file juce_Fonts_linux.cpp.

◆ createSystemTypefaceFor() [2/2]

Typeface::Ptr juce::Typeface::createSystemTypefaceFor ( const void fontFileData,
size_t  fontFileDataSize 
)
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.

Definition at line 88 of file juce_Fonts_linux.cpp.

◆ getAscent()

virtual float juce::Typeface::getAscent ( ) const
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.

◆ getDescent()

virtual float juce::Typeface::getDescent ( ) const
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.

◆ getEdgeTableForGlyph()

EdgeTable * juce::Typeface::getEdgeTableForGlyph ( int  glyphNumber,
const AffineTransform transform,
float  fontHeight 
)
virtual

Returns a new EdgeTable that contains the path for the given glyph, with the specified transform applied.

Reimplemented in juce::CustomTypeface.

Definition at line 248 of file juce_Typeface.cpp.

◆ getFallbackTypeface()

Typeface::Ptr juce::Typeface::getFallbackTypeface ( )
staticprotected

Definition at line 242 of file juce_Typeface.cpp.

◆ getGlyphPositions()

virtual void juce::Typeface::getGlyphPositions ( const String text,
Array< int > &  glyphs,
Array< float > &  xOffsets 
)
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.

◆ getHeightToPointsFactor()

virtual float juce::Typeface::getHeightToPointsFactor ( ) const
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.

◆ getName()

const String & juce::Typeface::getName ( ) const
noexcept

Returns the font family of the typeface.

See also
Font::getTypefaceName

Definition at line 57 of file juce_Typeface.h.

◆ getOutlineForGlyph()

virtual bool juce::Typeface::getOutlineForGlyph ( int  glyphNumber,
Path path 
)
pure virtual

Returns the outline for a glyph.

The path returned will be normalised to a font height of 1.0.

Implemented in juce::CustomTypeface.

◆ getStringWidth()

virtual float juce::Typeface::getStringWidth ( const String text)
pure 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!

Implemented in juce::CustomTypeface.

◆ getStyle()

const String & juce::Typeface::getStyle ( ) const
noexcept

Returns the font style of the typeface.

See also
Font::getTypefaceStyle

Definition at line 63 of file juce_Typeface.h.

◆ isHinted()

virtual bool juce::Typeface::isHinted ( ) const
virtual

Returns true if the typeface uses hinting.

Definition at line 125 of file juce_Typeface.h.

◆ isSuitableForFont()

virtual bool juce::Typeface::isSuitableForFont ( const Font ) const
virtual

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.

Definition at line 83 of file juce_Typeface.h.

◆ scanFolderForFonts()

void juce::Typeface::scanFolderForFonts ( const File folder)
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.

Definition at line 93 of file juce_Fonts_linux.cpp.

◆ setTypefaceCacheSize()

void juce::Typeface::setTypefaceCacheSize ( int  numFontsToCache)
static

Changes the number of fonts that are cached in memory.

Definition at line 168 of file juce_Font.cpp.

Member Data Documentation

◆ name

String juce::Typeface::name
protected

Definition at line 147 of file juce_Typeface.h.

◆ style

String juce::Typeface::style
protected

Definition at line 147 of file juce_Typeface.h.


The documentation for this class was generated from the following files: