Gorgon Game Engine
TextRenderer Class Referenceabstract

This class allows printing text on the screen. More...

Inheritance diagram for TextRenderer:
[legend]

Public Member Functions

virtual ~TextRenderer ()
 
virtual float GetBaseLine () const =0
 Get the distance of baseline from the top of the text. More...
 
virtual int GetCharacterIndex (const std::string &text, Geometry::Point location) const =0
 Returns the character index of glyph immediately after the given location. This function is Unicode aware. More...
 
virtual int GetCharacterIndex (const std::string &text, int w, Geometry::Point location, bool wrap=true) const =0
 Returns the character index of glyph immediately after the given location. This function is Unicode aware. More...
 
virtual int GetEMSize () const =0
 Returns the size of the EM dash. More...
 
virtual const GlyphRendererGetGlyphRenderer () const =0
 Returns the glyphrenderer that is used by this text renderer. More...
 
virtual int GetHeight () const =0
 Get the distance of baseline from the top of the text. More...
 
virtual Geometry::Rectangle GetPosition (const std::string &text, int index) const =0
 Returns the position of the glyph at the character index. More...
 
virtual Geometry::Rectangle GetPosition (const std::string &text, int w, int index, bool wrap=true) const =0
 Returns the position of the glyph at the character index. More...
 
virtual Geometry::Size GetSize (const std::string &text) const =0
 Returns the size of the given text. More...
 
virtual Geometry::Size GetSize (const std::string &text, int width) const =0
 Returns the size of the given text. More...
 
virtual bool IsReady () const =0
 Whether the render can render text. More...
 
void Print (TextureTarget &target, const std::string &text)
 
void Print (TextureTarget &target, const std::string &text, Geometry::Point location) const
 
void Print (TextureTarget &target, const std::string &text, Geometry::Point location, int w) const
 
void Print (TextureTarget &target, const std::string &text, Geometry::Point location, int w, TextAlignment align_override) const
 
void Print (TextureTarget &target, const std::string &text, Geometry::Pointf location) const
 Prints the given text to the target. More...
 
void Print (TextureTarget &target, const std::string &text, int x, int y) const
 
void Print (TextureTarget &target, const std::string &text, int x, int y, int w) const
 
void Print (TextureTarget &target, const std::string &text, int x, int y, int w, TextAlignment align_override) const
 
void PrintNoWrap (TextureTarget &target, const std::string &text, Geometry::Point location, int w) const
 
void PrintNoWrap (TextureTarget &target, const std::string &text, Geometry::Point location, int w, TextAlignment align_override) const
 
void PrintNoWrap (TextureTarget &target, const std::string &text, int x, int y, int w) const
 
void PrintNoWrap (TextureTarget &target, const std::string &text, int x, int y, int w, TextAlignment align_override) const
 

Protected Member Functions

virtual void print (TextureTarget &target, const std::string &text, Geometry::Point location) const =0
 
virtual void print (TextureTarget &target, const std::string &text, Geometry::Rectangle location) const =0
 
virtual void print (TextureTarget &target, const std::string &text, Geometry::Rectangle location, TextAlignment align_override) const =0
 Should print the given text to the specified location and color. More...
 
virtual void printnowrap (TextureTarget &target, const std::string &text, Geometry::Rectangle location) const =0
 Should print the given text to the specified location and color. More...
 
virtual void printnowrap (TextureTarget &target, const std::string &text, Geometry::Rectangle location, TextAlignment align_override) const =0
 Should print the given text to the specified location and color. More...
 

Detailed Description

This class allows printing text on the screen.

All fonts should support basic left aligned print, aligned rectangular area printing. Additionally, all fonts should support basic info functions. TextRenderers must be accept utf-8. internal::decode function should be preferred to decode utf-8, among regular utf-8 decoding, this function will map \r
to
.

Constructor & Destructor Documentation

◆ ~TextRenderer()

virtual ~TextRenderer ( )
virtual

Member Function Documentation

◆ GetBaseLine()

virtual float GetBaseLine ( ) const
pure virtual

Get the distance of baseline from the top of the text.

Implemented in FreeType, StyledRenderer, BasicFont, and BitmapFont.

◆ GetCharacterIndex() [1/2]

virtual int GetCharacterIndex ( const std::string &  text,
Geometry::Point  location 
) const
pure virtual

Returns the character index of glyph immediately after the given location. This function is Unicode aware.

Implemented in StyledRenderer, and BasicFont.

◆ GetCharacterIndex() [2/2]

virtual int GetCharacterIndex ( const std::string &  text,
int  w,
Geometry::Point  location,
bool  wrap = true 
) const
pure virtual

Returns the character index of glyph immediately after the given location. This function is Unicode aware.

Implemented in StyledRenderer, and BasicFont.

◆ GetEMSize()

virtual int GetEMSize ( ) const
pure virtual

Returns the size of the EM dash.

Implemented in FreeType, StyledRenderer, BasicFont, and BitmapFont.

◆ GetGlyphRenderer()

virtual const GlyphRenderer& GetGlyphRenderer ( ) const
pure virtual

Returns the glyphrenderer that is used by this text renderer.

It might be the text renderer itself. It is only safe to call this function if IsReady function has returned true.

Implemented in StyledRenderer, BasicFont, and BitmapFont.

◆ GetHeight()

virtual int GetHeight ( ) const
pure virtual

Get the distance of baseline from the top of the text.

Implemented in FreeType, StyledRenderer, BasicFont, and BitmapFont.

◆ GetPosition() [1/2]

virtual Geometry::Rectangle GetPosition ( const std::string &  text,
int  index 
) const
pure virtual

Returns the position of the glyph at the character index.

If the character is not found, this will return std::numeric_limit<int>::min for x and y position. Size could be 0 if it cannot be determined.

Implemented in StyledRenderer, and BasicFont.

◆ GetPosition() [2/2]

virtual Geometry::Rectangle GetPosition ( const std::string &  text,
int  w,
int  index,
bool  wrap = true 
) const
pure virtual

Returns the position of the glyph at the character index.

If the character is not found, this will return std::numeric_limit<int>::min for x and y position. Size could be 0 if it cannot be determined.

Implemented in StyledRenderer, and BasicFont.

◆ GetSize() [1/2]

virtual Geometry::Size GetSize ( const std::string &  text) const
pure virtual

Returns the size of the given text.

Implemented in StyledRenderer, and BasicFont.

◆ GetSize() [2/2]

virtual Geometry::Size GetSize ( const std::string &  text,
int  width 
) const
pure virtual

Returns the size of the given text.

Implemented in StyledRenderer, and BasicFont.

◆ IsReady()

virtual bool IsReady ( ) const
pure virtual

Whether the render can render text.

Implemented in FreeType, StyledRenderer, and BasicFont.

◆ Print() [1/8]

void Print ( TextureTarget target,
const std::string &  text 
)

◆ Print() [2/8]

void Print ( TextureTarget target,
const std::string &  text,
Geometry::Point  location 
) const

◆ print() [1/3]

virtual void print ( TextureTarget target,
const std::string &  text,
Geometry::Point  location 
) const
protectedpure virtual

Implemented in StyledRenderer, and BasicFont.

◆ Print() [3/8]

void Print ( TextureTarget target,
const std::string &  text,
Geometry::Point  location,
int  w 
) const

◆ Print() [4/8]

void Print ( TextureTarget target,
const std::string &  text,
Geometry::Point  location,
int  w,
TextAlignment  align_override 
) const

◆ Print() [5/8]

void Print ( TextureTarget target,
const std::string &  text,
Geometry::Pointf  location 
) const

Prints the given text to the target.

y coordinate is the top if the text. However, depending on the font, this value might exclude uppercase accents.

◆ print() [2/3]

virtual void print ( TextureTarget target,
const std::string &  text,
Geometry::Rectangle  location 
) const
protectedpure virtual

Implemented in StyledRenderer, and BasicFont.

◆ print() [3/3]

virtual void print ( TextureTarget target,
const std::string &  text,
Geometry::Rectangle  location,
TextAlignment  align_override 
) const
protectedpure virtual

Should print the given text to the specified location and color.

Width should be used to align the text. Unless width is 0, text should be wrapped. Even if width is 0, the alignment should be respected. For instance if width is 0 and align is right, text should end at the given location. Height of the rectangle can be left 0, thus unless explicitly requested, it should be ignored.

Implemented in StyledRenderer, and BasicFont.

◆ Print() [6/8]

void Print ( TextureTarget target,
const std::string &  text,
int  x,
int  y 
) const

◆ Print() [7/8]

void Print ( TextureTarget target,
const std::string &  text,
int  x,
int  y,
int  w 
) const

◆ Print() [8/8]

void Print ( TextureTarget target,
const std::string &  text,
int  x,
int  y,
int  w,
TextAlignment  align_override 
) const

◆ PrintNoWrap() [1/4]

void PrintNoWrap ( TextureTarget target,
const std::string &  text,
Geometry::Point  location,
int  w 
) const

◆ PrintNoWrap() [2/4]

void PrintNoWrap ( TextureTarget target,
const std::string &  text,
Geometry::Point  location,
int  w,
TextAlignment  align_override 
) const

◆ printnowrap() [1/2]

virtual void printnowrap ( TextureTarget target,
const std::string &  text,
Geometry::Rectangle  location 
) const
protectedpure virtual

Should print the given text to the specified location and color.

Width should be used to align the text. Automatic wrapping should not be used.

Implemented in StyledRenderer, and BasicFont.

◆ printnowrap() [2/2]

virtual void printnowrap ( TextureTarget target,
const std::string &  text,
Geometry::Rectangle  location,
TextAlignment  align_override 
) const
protectedpure virtual

Should print the given text to the specified location and color.

Width should be used to align the text. Automatic wrapping should not be used.

Implemented in StyledRenderer, and BasicFont.

◆ PrintNoWrap() [3/4]

void PrintNoWrap ( TextureTarget target,
const std::string &  text,
int  x,
int  y,
int  w 
) const

◆ PrintNoWrap() [4/4]

void PrintNoWrap ( TextureTarget target,
const std::string &  text,
int  x,
int  y,
int  w,
TextAlignment  align_override 
) const

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