PixelLightAPI  .
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
PLRenderer::Font Class Reference

Abstract renderer font resource base class. More...

#include <Font.h>

Inheritance diagram for PLRenderer::Font:
Inheritance graph
[legend]

List of all members.

Public Types

enum  EDrawFlags { CenterText = 1<<0, UnderlineText = 1<<1, CrossoutText = 1<<2, Mipmapping = 1<<3 }

Public Member Functions

virtual PLRENDERER_API ~Font ()
 Destructor.
FontManagerGetFontManager () const
 Returns the creating font manager.
PLCore::String GetFilename () const
 Returns the filename of the font file the data came from.
PLCore::uint32 GetSize () const
 Returns the nominal font size in points (72 points per inch)
PLCore::uint32 GetResolution () const
 Returns the horizontal and vertical resolution in DPI.
PLCore::uint32 GetSizeInPixels () const
 Returns the font size in pixels.
PLCore::uint32 GetHeightInPixels () const
 Returns the font (line) height in pixels.
virtual PLRENDERER_API bool SetSize (PLCore::uint32 nSize=12, PLCore::uint32 nResolution=96)
 Sets the font size.
virtual bool IsValid () const =0
 Returns whether or not this font is valid.
virtual float GetAscender () const =0
 Returns the ascender in font units.
virtual float GetDescender () const =0
 Returns the descender in font units.
virtual float GetHeight () const =0
 Returns the height in font units.
virtual PLRENDERER_API float GetTextWidth (const PLCore::String &sText)
 Returns the width of a text (in font units) drawn with this font.
virtual void Draw (const PLCore::String &sText, const PLGraphics::Color4 &cColor, const PLMath::Matrix4x4 &mObjectSpaceToClipSpace, const PLMath::Vector2 &vScale=PLMath::Vector2::One, const PLMath::Vector2 &vBias=PLMath::Vector2::Zero, PLCore::uint32 nFlags=0)=0
 Draws a text.

Protected Member Functions

PLRENDERER_API Font (FontManager &cFontManager, const PLCore::String &sFilename)
 Default.
 Font (const Font &cSource)
 Copy constructor.
Fontoperator= (const Font &cSource)
 Copy operator.
PLRENDERER_API void DestroyGlyphs ()
 Destroys the currently active glyphs.

Protected Attributes

FontManagerm_pFontManager
PLCore::String m_sFilename
PLCore::uint32 m_nSize
PLCore::uint32 m_nResolution
PLCore::Array< FontGlyph * > m_lstGlyphs

Detailed Description

Abstract renderer font resource base class.

Remarks:

Height Ascender Internal leading | | | | | | | | | | | | | | |----| | | | | | | | 0 |___|____|___|_____________|___ Baseline |0 | | | | | Descender Size

Term definitions:

Note:
  • For italic/bold fonts, you have to specify the corresponding font variation file of the font file

Member Enumeration Documentation

brief Draw flags

Enumerator:
CenterText 

Center the text

UnderlineText 

Underline the text

CrossoutText 

Cross out the text

Mipmapping 

Use mipmapping (may blur the font in an ugly way)


Constructor & Destructor Documentation

virtual PLRENDERER_API PLRenderer::Font::~Font ( ) [virtual]

Destructor.

PLRENDERER_API PLRenderer::Font::Font ( FontManager cFontManager,
const PLCore::String sFilename 
) [protected]

Default.

Parameters:
[in]cFontManagerCreating font manager
[in]sFilenameFilename of the font file the data came from, used to reference the new font by filename
PLRenderer::Font::Font ( const Font cSource) [protected]

Copy constructor.

Parameters:
[in]cSourceSource to copy from

Member Function Documentation

Returns the creating font manager.

Returns:
The creating font manager

Returns the filename of the font file the data came from.

Returns:
The filename of the font file the data came from
PLCore::uint32 PLRenderer::Font::GetSize ( ) const [inline]

Returns the nominal font size in points (72 points per inch)

Returns the font size in points (72 points per inch)

Returns:
The nominal font size in points, for example 12
PLCore::uint32 PLRenderer::Font::GetResolution ( ) const [inline]

Returns the horizontal and vertical resolution in DPI.

Returns:
The horizontal and vertical resolution in DPI, for example 96
PLCore::uint32 PLRenderer::Font::GetSizeInPixels ( ) const [inline]

Returns the font size in pixels.

Returns:
The font size in pixels
Remarks:
Example: Arial 12pt at 96 dpi:

Font size in points 12 Font size in pixels = ------------------- × 96 dpi = ---- × 96 = 16 pixels 72 points per inch 72

PLCore::uint32 PLRenderer::Font::GetHeightInPixels ( ) const [inline]

Returns the font (line) height in pixels.

Returns the font height in pixels.

Returns:
The font height in pixels
See also:
virtual PLRENDERER_API bool PLRenderer::Font::SetSize ( PLCore::uint32  nSize = 12,
PLCore::uint32  nResolution = 96 
) [virtual]

Sets the font size.

Parameters:
[in]nSizeNominal font size in points, for example 12 (72 points per inch)
[in]nResolutionThe horizontal and vertical resolution in DPI, for example 96
Returns:
'true' if all went fine, else 'false'
Note:
  • When overwriting this method, it's highly recommended to call this base implementation, too
virtual bool PLRenderer::Font::IsValid ( ) const [pure virtual]

Returns whether or not this font is valid.

Returns:
'true' if the font is valid, else 'false'
virtual float PLRenderer::Font::GetAscender ( ) const [pure virtual]

Returns the ascender in font units.

Returns:
The ascender in font units
virtual float PLRenderer::Font::GetDescender ( ) const [pure virtual]

Returns the descender in font units.

Returns:
The descender in font units (negative value)
virtual float PLRenderer::Font::GetHeight ( ) const [pure virtual]

Returns the height in font units.

Returns:
The height in font units
virtual PLRENDERER_API float PLRenderer::Font::GetTextWidth ( const PLCore::String sText) [virtual]

Returns the width of a text (in font units) drawn with this font.

Parameters:
[in]sTextText to 'draw'
Returns:
The width of a text (in font units) drawn with this font
Note:
  • When overwriting this method, it's highly recommended to call this base implementation, too
virtual void PLRenderer::Font::Draw ( const PLCore::String sText,
const PLGraphics::Color4 cColor,
const PLMath::Matrix4x4 mObjectSpaceToClipSpace,
const PLMath::Vector2 vScale = PLMath::Vector2::One,
const PLMath::Vector2 vBias = PLMath::Vector2::Zero,
PLCore::uint32  nFlags = 0 
) [pure virtual]

Draws a text.

Parameters:
[in]sTextText to draw
[in]cColorText color
[in]mObjectSpaceToClipSpaceObject space to clip space matrix
[in]vScaleFont scale, there are situations were it's more comfortable to have a special scale variable as just mObjectSpaceToClipSpace with all build in
[in]vBiasFont bias (position offset), there are situations were it's more comfortable to have a special bias variable as just mObjectSpaceToClipSpace with all build in
[in]nFlagsDraw flags, see EDrawFlags
Font& PLRenderer::Font::operator= ( const Font cSource) [protected]

Copy operator.

Parameters:
[in]cSourceSource to copy from
Returns:
Reference to this instance
PLRENDERER_API void PLRenderer::Font::DestroyGlyphs ( ) [protected]

Destroys the currently active glyphs.


Member Data Documentation

Creating font manager, always valid!

The filename of the font file the data came from

PLCore::uint32 PLRenderer::Font::m_nSize [protected]

Font size in points, for example 12 (72 points per inch)

PLCore::uint32 PLRenderer::Font::m_nResolution [protected]

The horizontal and vertical resolution in DPI, for example 96

List of currently active glyphs ("character code -> glyph instance")


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


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:23
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported