CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::Font Class Reference

The representation of a font in the engine. More...

#include <CeresEngine/Text/Font.hpp>

Inheritance diagram for CeresEngine::Font:
CeresEngine::TResource< Font > CeresEngine::Resource CeresEngine::IReflectable

Public Member Functions

 Font (const FilePath &fontFile, FontSize size)
 
 ~Font () override
 
double getPointSize () const
 The point size of the font.
 
bool isFixedPitch () const
 A Boolean value indicating whether all glyphs in the font have the same advancement.
 
UInt32 getNumberOfGlyphs () const
 The number of glyphs in the font. Glyphs are numbered starting at 0.
 
UInt32 getControlGlyph () const
 The reserved code for a control glyph.
 
UInt32 getNullGlyph () const
 The reserved code for a null glyph.
 
String getDisplayName () const
 The name of the font, including family and face names, to use when displaying the font information to the user.
 
String getFamilyName () const
 The family name of the font—for example, "Times" or "Helvetica.".
 
String getFontName () const
 The full name of the font, as used in PostScript language code—for example, "Times-Roman" or "Helvetica-Oblique.".
 
FontRenderingMode getRenderingMode () const
 The rendering mode of the font.
 
Size2 getAdvancement (Glyph aGlyph) const
 Returns the nominal spacing for the given glyph—the distance the current point moves after showing the glyph—accounting for the receiver’s size.
 
Rect2 getBoundingRect (Glyph aGlyph) const
 Returns the bounding rectangle for the specified glyph, scaled to the receiver’s size.
 
Rect2 getUV (Glyph aGlyph) const
 
Vector< Size2 > getAdvancements (const Span< Glyph > &glyphs) const
 Returns an array of the advancements for the specified glyphs rendered by the receiver.
 
void getAdvancements (const Span< Glyph > &glyphs, TemporaryVector< Size2 > &advancements)
 
Vector< Size2 > getPackedAdvancements (const Span< Glyph > &packedGlyphs) const
 Returns an array of the advancements for the specified packed glyphs and rendered by the receiver.
 
void getPackedAdvancements (const Span< Glyph > &packedGlyphs, TemporaryVector< Size2 > &packedAdvancements) const
 
Vector< Rect2 > getBoundingRects (const Span< Glyph > &glyphs) const
 Returns an array of the bounding rectangles for the specified glyphs rendered by the receiver.
 
void getBoundingRects (const Span< Glyph > &glyphs, TemporaryVector< Rect2 > &boundingRects) const
 
Glyph getGlyph (StringView glyphName) const
 Returns the named encoded glyph, or –1 if the receiver contains no such glyph.
 
BezierPath getPathForGlyph (Glyph glyph) const
 
void prepareCharacterSet (StringView characterSet)
 
void prepareCharacterSet (StringView characterSet, double pointSize, const AffineTransform &transform)
 Prepares the set of characters in characterSet for rendering.
 
- Public Member Functions inherited from CeresEngine::TResource< Font >
ResourceHandle< FontgetResourceHandle () const noexcept
 Generates a hash for the provided type.
 
SPtr< FontgetShared () noexcept
 Gets a shared pointer to the resource.
 
SPtr< const FontgetShared () const noexcept
 Gets a shared pointer to the resource.
 
const ResourceTypeInfogetResourceType () const noexcept override
 Returns the resource type information descriptor.
 
 TResource (ResourceData &data, InputStream &dataStream)
 
void serialize (OutputStream &dataStream) const override
 Serializes a resource by writing data to dataStream.
 
- Public Member Functions inherited from CeresEngine::Resource
 Resource ()
 Default constructor for the Resource class.
 
 Resource (ResourceData &data)
 Creates a new Resource instance by passing a ResourceData instance.
 
virtual ~Resource () noexcept=default
 Resource virtual destructor.
 
ResourceManagergetResourceManager () const noexcept
 
HResource getResourceHandle () const noexcept
 Generates a hash for the provided type.
 
UUID getResourceID () const noexcept
 
HResource getParentResource () const noexcept
 A parent resource to which this resource is attached to.
 
SPtr< ResourceMetadatagetResourceMetadata () const noexcept
 A pointer to the user-defined resource metadata.
 
const PackagePtrgetPackage () const noexcept
 The package from which the resource was loaded from.
 
template<typename T = Resource>
SPtr< TgetShared () noexcept
 Gets a shared pointer to the resource.
 
template<typename T = Resource>
SPtr< const TgetShared () const noexcept
 Gets a shared pointer to the resource.
 
 Resource (ResourceData &data, InputStream &dataStream)
 Creates a new resource by reading data from dataStream.
 
- Public Member Functions inherited from CeresEngine::IReflectable
virtual ~IReflectable () noexcept=default
 

Public Attributes

Map< Glyph, Rect2 > uvMap
 
SPtr< Textureimage
 

Private Attributes

FontSize mSize
 
voidhandle
 
Vector2 mFontUnitScale
 
FontProperties mProperties
 

Additional Inherited Members

- Static Public Member Functions inherited from CeresEngine::Resource
template<typename Processor >
static constexpr void reflect (Processor &&RTTI)
 Executes the given processor for every field of the struct.
 
- Protected Member Functions inherited from CeresEngine::Resource
HResourceStream createStream (const ResourceStreamFlags &flags=ResourceStreamFlag::Default)
 Creates a new resource stream.
 
void destroyStream (HResourceStream &stream)
 Destroys a stream.
 
void markAsDirty ()
 Marks the resource as dirty.
 

Detailed Description

The representation of a font in the engine.

Font objects represent fonts in the engine, providing access to characteristics of the font and assistance in laying out glyphs relative to one another.

Constructor & Destructor Documentation

◆ Font()

CeresEngine::Font::Font ( const FilePath fontFile,
FontSize  size 
)

◆ ~Font()

CeresEngine::Font::~Font ( )
override

Member Function Documentation

◆ getAdvancement()

Size2 CeresEngine::Font::getAdvancement ( Glyph  aGlyph) const

Returns the nominal spacing for the given glyph—the distance the current point moves after showing the glyph—accounting for the receiver’s size.

This spacing is given according to the glyph’s movement direction, which is either strictly horizontal or strictly vertical.

Parameters
aGlyphThe glyph whose advancement is returned.
Returns
The advancement spacing in points.

◆ getAdvancements() [1/2]

Vector< Size2 > CeresEngine::Font::getAdvancements ( const Span< Glyph > &  glyphs) const

Returns an array of the advancements for the specified glyphs rendered by the receiver.

Returns in advancements an array of the advancements for the glyphs specified by glyphs and rendered by the receiver.

◆ getAdvancements() [2/2]

void CeresEngine::Font::getAdvancements ( const Span< Glyph > &  glyphs,
TemporaryVector< Size2 > &  advancements 
)

◆ getBoundingRect()

Rect2 CeresEngine::Font::getBoundingRect ( Glyph  aGlyph) const

Returns the bounding rectangle for the specified glyph, scaled to the receiver’s size.

◆ getBoundingRects() [1/2]

Vector< Rect2 > CeresEngine::Font::getBoundingRects ( const Span< Glyph > &  glyphs) const

Returns an array of the bounding rectangles for the specified glyphs rendered by the receiver.

Returns in bounds an array of the bounding rectangles for the glyphs specified by glyphs and rendered by the receiver.

◆ getBoundingRects() [2/2]

void CeresEngine::Font::getBoundingRects ( const Span< Glyph > &  glyphs,
TemporaryVector< Rect2 > &  boundingRects 
) const

◆ getControlGlyph()

UInt32 CeresEngine::Font::getControlGlyph ( ) const

The reserved code for a control glyph.

◆ getDisplayName()

String CeresEngine::Font::getDisplayName ( ) const

The name of the font, including family and face names, to use when displaying the font information to the user.

◆ getFamilyName()

String CeresEngine::Font::getFamilyName ( ) const

The family name of the font—for example, "Times" or "Helvetica.".

The value in this property is intended for an application’s internal usage and not for display. To get a name that you can display to the user, use getDisplayName() instead.

◆ getFontName()

String CeresEngine::Font::getFontName ( ) const

The full name of the font, as used in PostScript language code—for example, "Times-Roman" or "Helvetica-Oblique.".

The value in this property is intended for an application’s internal usage and not for display. To get a name that you can display to the user, use getDisplayName() instead.

◆ getGlyph()

Glyph CeresEngine::Font::getGlyph ( StringView  glyphName) const

Returns the named encoded glyph, or –1 if the receiver contains no such glyph.

Returns –1 if the glyph named glyphName isn’t encoded.

Glyph names in fonts do not always accurately identify the glyph. The layout manager, an instance of TextLayoutManager, finds the correspondence between characters and glyphs.

Parameters
glyphNameThe name of the glyph.
Returns
The named encoded glyph.

◆ getNullGlyph()

UInt32 CeresEngine::Font::getNullGlyph ( ) const

The reserved code for a null glyph.

◆ getNumberOfGlyphs()

UInt32 CeresEngine::Font::getNumberOfGlyphs ( ) const

The number of glyphs in the font. Glyphs are numbered starting at 0.

◆ getPackedAdvancements() [1/2]

Vector< Size2 > CeresEngine::Font::getPackedAdvancements ( const Span< Glyph > &  packedGlyphs) const

Returns an array of the advancements for the specified packed glyphs and rendered by the receiver.

Returns in advancements an array of the advancements for the packed glyphs specified by packedGlyphs and rendered by the receiver.

◆ getPackedAdvancements() [2/2]

void CeresEngine::Font::getPackedAdvancements ( const Span< Glyph > &  packedGlyphs,
TemporaryVector< Size2 > &  packedAdvancements 
) const

◆ getPathForGlyph()

BezierPath CeresEngine::Font::getPathForGlyph ( Glyph  glyph) const

◆ getPointSize()

double CeresEngine::Font::getPointSize ( ) const

The point size of the font.

If the font has a nonstandard matrix, the point size is the effective vertical point size.

◆ getRenderingMode()

FontRenderingMode CeresEngine::Font::getRenderingMode ( ) const

The rendering mode of the font.

For a list of valid rendering modes, see FontRenderingMode.

◆ getUV()

Rect2 CeresEngine::Font::getUV ( Glyph  aGlyph) const

◆ isFixedPitch()

bool CeresEngine::Font::isFixedPitch ( ) const

A Boolean value indicating whether all glyphs in the font have the same advancement.

The value of this property is true when all glyphs have the same advancement or false when they do not.

◆ prepareCharacterSet() [1/2]

void CeresEngine::Font::prepareCharacterSet ( StringView  characterSet)

◆ prepareCharacterSet() [2/2]

void CeresEngine::Font::prepareCharacterSet ( StringView  characterSet,
double  pointSize,
const AffineTransform &  transform 
)

Prepares the set of characters in characterSet for rendering.

Parameters
pointSizeThe font sie, in points, as used in the layout calculation.
transformA transform to be applied to the each character pointSize.
Returns
The data necessary for rendering each glyph in the character set.

Member Data Documentation

◆ handle

void* CeresEngine::Font::handle
private

◆ image

SPtr<Texture> CeresEngine::Font::image

◆ mFontUnitScale

Vector2 CeresEngine::Font::mFontUnitScale
private

◆ mProperties

FontProperties CeresEngine::Font::mProperties
private

◆ mSize

FontSize CeresEngine::Font::mSize
private

◆ uvMap

Map<Glyph, Rect2> CeresEngine::Font::uvMap

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