Gorgon Game Engine
GlyphRenderer Class Referenceabstract

Should be implemented by the systems aimed to render fonts on the screen. More...

Inheritance diagram for GlyphRenderer:
[legend]

Public Member Functions

virtual ~GlyphRenderer ()
 
virtual bool Exists (Glyph g) const =0
 Returns true if the glyph exists. More...
 
virtual float GetBaseLine () const =0
 Baseline point of glyphs from the top. More...
 
virtual float GetCursorAdvance (Glyph g) const =0
 This function should return the number of pixels the cursor should advance after this glyph. More...
 
virtual int GetDigitWidth () const =0
 Width of a digit, if digits do not have the same width, maximum should be returned. More...
 
virtual int GetEMSize () const =0
 Returns the size of the EM dash. More...
 
virtual int GetHeight () const =0
 Height of glyphs, actual size could be smaller but all glyphs should have the same virtual height. More...
 
virtual std::pair< int, int > GetLetterHeight (bool asciionly=false) const =0
 Returns the offset (first) and maximum height (second) that is used by letters. More...
 
virtual float GetLineGap () const =0
 This is the default distance between two consecutive lines. More...
 
virtual float GetLineThickness () const =0
 Should return the average thickness of a line. More...
 
virtual int GetMaxWidth () const =0
 Returns the width of widest glyph. More...
 
virtual Geometry::Size GetSize (Glyph chr) const =0
 This function should return the size of the requested glyph. More...
 
virtual int GetUnderlineOffset () const =0
 The position of the underline, if it is to be drawn. More...
 
virtual bool IsASCII () const =0
 This function should return true if this font renderer supports only 7-bit ASCII. More...
 
virtual bool IsFixedWidth () const =0
 This function should return true if this font is fixed width. More...
 
virtual Geometry::Pointf KerningDistance (Glyph left, Glyph right) const =0
 This function should return the additional distance between given glyphs. More...
 
virtual bool NeedsPrepare () const
 Should return if the glyph renderer requires preparation regarding the text given. More...
 
virtual void Prepare (const std::string &) const
 Notifies glyph renderer about a text to be rendered. More...
 
virtual void Render (Glyph chr, TextureTarget &target, Geometry::Pointf location, RGBAf color) const =0
 This function should render the given character to the target at the specified location and color. More...
 

Detailed Description

Should be implemented by the systems aimed to render fonts on the screen.

Glyph renderer should be capable of rendering single glyphs at the screen. These systems should also provide info about glyphs.

Constructor & Destructor Documentation

◆ ~GlyphRenderer()

virtual ~GlyphRenderer ( )
virtual

Member Function Documentation

◆ Exists()

virtual bool Exists ( Glyph  g) const
pure virtual

Returns true if the glyph exists.

Implemented in FreeType, and BitmapFont.

◆ GetBaseLine()

virtual float GetBaseLine ( ) const
pure virtual

Baseline point of glyphs from the top.

Implemented in FreeType, and BitmapFont.

◆ GetCursorAdvance()

virtual float GetCursorAdvance ( Glyph  g) const
pure virtual

This function should return the number of pixels the cursor should advance after this glyph.

This value will be added to kerning distance.

Implemented in FreeType, and BitmapFont.

◆ GetDigitWidth()

virtual int GetDigitWidth ( ) const
pure virtual

Width of a digit, if digits do not have the same width, maximum should be returned.

For practical reasons, this function is expected to consider arabic numerals.

Implemented in FreeType, and BitmapFont.

◆ GetEMSize()

virtual int GetEMSize ( ) const
pure virtual

Returns the size of the EM dash.

Implemented in FreeType, and BitmapFont.

◆ GetHeight()

virtual int GetHeight ( ) const
pure virtual

Height of glyphs, actual size could be smaller but all glyphs should have the same virtual height.

When drawn on the same y position, all glyphs should line up. Renderer can change actual draw location to compensate.

Implemented in FreeType, and BitmapFont.

◆ GetLetterHeight()

virtual std::pair<int, int> GetLetterHeight ( bool  asciionly = false) const
pure virtual

Returns the offset (first) and maximum height (second) that is used by letters.

Offset is the distance of the letter with max height to the top. This function uses  and j to calculate letter height when ascii only is not set. If ascii only is set, it uses A, f, j. If  is not found, this function simply reverts to using A.

Implemented in FreeType, and BitmapFont.

◆ GetLineGap()

virtual float GetLineGap ( ) const
pure virtual

This is the default distance between two consecutive lines.

This distance can be modified by text renderers

Implemented in FreeType, and BitmapFont.

◆ GetLineThickness()

virtual float GetLineThickness ( ) const
pure virtual

Should return the average thickness of a line.

This information can be used to construct underline and strike through.

Implemented in FreeType, and BitmapFont.

◆ GetMaxWidth()

virtual int GetMaxWidth ( ) const
pure virtual

Returns the width of widest glyph.

Implemented in FreeType, and BitmapFont.

◆ GetSize()

virtual Geometry::Size GetSize ( Glyph  chr) const
pure virtual

This function should return the size of the requested glyph.

If it does not exists, 0x0 should be returned

Implemented in FreeType, and BitmapFont.

◆ GetUnderlineOffset()

virtual int GetUnderlineOffset ( ) const
pure virtual

The position of the underline, if it is to be drawn.

Implemented in FreeType, and BitmapFont.

◆ IsASCII()

virtual bool IsASCII ( ) const
pure virtual

This function should return true if this font renderer supports only 7-bit ASCII.

Implemented in FreeType, and BitmapFont.

◆ IsFixedWidth()

virtual bool IsFixedWidth ( ) const
pure virtual

This function should return true if this font is fixed width.

This will suppress calls to GetSize function.

Implemented in FreeType, and BitmapFont.

◆ KerningDistance()

virtual Geometry::Pointf KerningDistance ( Glyph  left,
Glyph  right 
) const
pure virtual

This function should return the additional distance between given glyphs.

Returned value could be (in most cases it is) negative. Left and right are visual locations, they will not be reverted for right to left rendering.

Implemented in FreeType, and BitmapFont.

◆ NeedsPrepare()

virtual bool NeedsPrepare ( ) const
virtual

Should return if the glyph renderer requires preparation regarding the text given.

Reimplemented in FreeType.

◆ Prepare()

virtual void Prepare ( const std::string &  ) const
virtual

Notifies glyph renderer about a text to be rendered.

If renderers require modification to their internal structures, they should mark them

Reimplemented in FreeType.

◆ Render()

virtual void Render ( Glyph  chr,
TextureTarget target,
Geometry::Pointf  location,
RGBAf  color 
) const
pure virtual

This function should render the given character to the target at the specified location and color.

If chr does not exists, this function should perform no action. location and color can be modified as per the needs of renderer. If the kerning returns integers location will always be an integer. Additionally, text renderers will place glyphs on 0 y position from the top. It is glyph renderer's task to ensure baseline of glyphs to line up.

Implemented in FreeType, and BitmapFont.


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