Gorgon Game Engine
BasicFont Class Reference

This is the basic font, performing the minimal amount of operations necessary to render text on the screen. More...

Inheritance diagram for BasicFont:
[legend]

Public Member Functions

 BasicFont (const GlyphRenderer &renderer, RGBAf color=1.f, TextAlignment defaultalign=TextAlignment::Left)
 
virtual float GetBaseLine () const override
 Get the distance of baseline from the top of the text. More...
 
virtual int GetCharacterIndex (const std::string &text, Geometry::Point location) const override
 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 override
 Returns the character index of glyph immediately after the given location. This function is Unicode aware. More...
 
RGBAf GetColor () const
 Returns the current text color. More...
 
TextAlignment GetDefaultAlignment () const
 Returns the current default alignment. More...
 
virtual int GetEMSize () const override
 Returns the size of the EM dash. More...
 
virtual const GlyphRendererGetGlyphRenderer () const override
 Returns the glyphrenderer that is used by this text renderer. More...
 
virtual int GetHeight () const override
 Get the distance of baseline from the top of the text. More...
 
virtual Geometry::Rectangle GetPosition (const std::string &text, int index) const override
 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 override
 Returns the position of the glyph at the character index. More...
 
virtual Geometry::Size GetSize (const std::string &text) const override
 Returns the size of the given text. More...
 
virtual Geometry::Size GetSize (const std::string &text, int width) const override
 Returns the size of the given text. More...
 
virtual bool IsReady () const override
 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, RGBAf color) 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::Point location, int w, TextAlignment align_override, RGBAf color) const
 
void Print (TextureTarget &target, const std::string &text, Geometry::Point location, RGBAf color) 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, RGBAf color) const
 
void Print (TextureTarget &target, const std::string &text, int x, int y, int w, TextAlignment align_override) const
 
void Print (TextureTarget &target, const std::string &text, int x, int y, int w, TextAlignment align_override, RGBAf color) const
 
void Print (TextureTarget &target, const std::string &text, int x, int y, RGBAf color) const
 
void Print (TextureTarget &target, const std::string &text, RGBAf color) const
 
void PrintNoWrap (TextureTarget &target, const std::string &text, Geometry::Point location, int w, RGBAf color) const
 
void PrintNoWrap (TextureTarget &target, const std::string &text, Geometry::Point location, int w, TextAlignment align_override, RGBAf color) const
 
void PrintNoWrap (TextureTarget &target, const std::string &text, int x, int y, int w, RGBAf color) const
 
void PrintNoWrap (TextureTarget &target, const std::string &text, int x, int y, int w, TextAlignment align_override, RGBAf color) const
 
void SetColor (RGBAf value)
 Changes the the color of the text. Color can only be overridden through BasicFont interface. More...
 
void SetDefaultAlignment (TextAlignment value)
 Changes the default alignment. It is possible to override default alignment through TextRenderer interface. More...
 
- Public Member Functions inherited from TextRenderer
virtual ~TextRenderer ()
 
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 override
 
virtual void print (TextureTarget &target, const std::string &text, Geometry::Point location, RGBAf color) const
 
virtual void print (TextureTarget &target, const std::string &text, Geometry::Rectangle location) const override
 
virtual void print (TextureTarget &target, const std::string &text, Geometry::Rectangle location, RGBAf color) const
 
virtual void print (TextureTarget &target, const std::string &text, Geometry::Rectangle location, TextAlignment align) const override
 Should print the given text to the specified location and color. More...
 
virtual void print (TextureTarget &target, const std::string &text, Geometry::Rectangle location, TextAlignment align, RGBAf color) const
 
virtual void printnowrap (TextureTarget &target, const std::string &text, Geometry::Rectangle location) const override
 Should print the given text to the specified location and color. More...
 
virtual void printnowrap (TextureTarget &target, const std::string &text, Geometry::Rectangle location, RGBAf color) const
 
virtual void printnowrap (TextureTarget &target, const std::string &text, Geometry::Rectangle location, TextAlignment align) const override
 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, RGBAf color) const
 

Protected Attributes

RGBAf color
 Color of this renderer, can be overridden. More...
 
TextAlignment defaultalign
 Default alignment if none is specified. More...
 

Detailed Description

This is the basic font, performing the minimal amount of operations necessary to render text on the screen.

It requires a single GlyphRenderer to work.

Constructor & Destructor Documentation

◆ BasicFont()

BasicFont ( const GlyphRenderer renderer,
RGBAf  color = 1.f,
TextAlignment  defaultalign = TextAlignment::Left 
)

Member Function Documentation

◆ GetBaseLine()

virtual float GetBaseLine ( ) const
overridevirtual

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

Implements TextRenderer.

Reimplemented in FreeType, and BitmapFont.

References GlyphRenderer::GetBaseLine().

◆ GetCharacterIndex() [1/2]

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

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

Implements TextRenderer.

References GlyphRenderer::GetMaxWidth(), GlyphRenderer::NeedsPrepare(), GlyphRenderer::Prepare(), and Gorgon::Graphics::internal::simplelayout().

◆ GetCharacterIndex() [2/2]

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

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

Implements TextRenderer.

References Gorgon::begin(), Gorgon::Graphics::internal::boundedlayout(), BasicFont::defaultalign, Gorgon::end(), GlyphRenderer::NeedsPrepare(), GlyphRenderer::Prepare(), Gorgon::Graphics::Right, and basic_Point< T_ >::X.

◆ GetColor()

RGBAf GetColor ( ) const

Returns the current text color.

References BasicFont::color.

◆ GetDefaultAlignment()

TextAlignment GetDefaultAlignment ( ) const

Returns the current default alignment.

References BasicFont::defaultalign.

◆ GetEMSize()

virtual int GetEMSize ( ) const
overridevirtual

Returns the size of the EM dash.

Implements TextRenderer.

Reimplemented in FreeType, and BitmapFont.

References GlyphRenderer::GetEMSize().

◆ GetGlyphRenderer()

virtual const GlyphRenderer& GetGlyphRenderer ( ) const
overridevirtual

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.

Implements TextRenderer.

Reimplemented in BitmapFont.

◆ GetHeight()

virtual int GetHeight ( ) const
overridevirtual

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

Implements TextRenderer.

Reimplemented in FreeType, and BitmapFont.

References GlyphRenderer::GetHeight().

◆ GetPosition() [1/2]

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

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.

Implements TextRenderer.

References GlyphRenderer::NeedsPrepare(), GlyphRenderer::Prepare(), and Gorgon::Graphics::internal::simplelayout().

◆ GetPosition() [2/2]

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

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.

Implements TextRenderer.

References Gorgon::begin(), Gorgon::Graphics::internal::boundedlayout(), Gorgon::end(), GlyphRenderer::NeedsPrepare(), GlyphRenderer::Prepare(), and Gorgon::Input::Keyboard::Keycodes::Right.

◆ GetSize() [1/2]

Geometry::Size GetSize ( const std::string &  text) const
overridevirtual

◆ GetSize() [2/2]

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

◆ IsReady()

virtual bool IsReady ( ) const
overridevirtual

Whether the render can render text.

Implements TextRenderer.

Reimplemented in FreeType.

◆ Print() [1/15]

◆ Print() [2/15]

void Print

References TextRenderer::print().

◆ print() [1/6]

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

Implements TextRenderer.

References BasicFont::color.

◆ Print() [3/15]

void Print

References TextRenderer::print().

◆ Print() [4/15]

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

◆ Print() [5/15]

void Print

References TextRenderer::print().

◆ Print() [6/15]

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

◆ Print() [7/15]

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

◆ print() [2/6]

void print ( TextureTarget target,
const std::string &  text,
Geometry::Point  location,
RGBAf  color 
) const
protectedvirtual

◆ Print() [8/15]

void Print

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.

References TextRenderer::print().

◆ print() [3/6]

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

◆ print() [4/6]

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

◆ print() [5/6]

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

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.

Implements TextRenderer.

References BasicFont::color, and BasicFont::print().

◆ print() [6/6]

◆ Print() [9/15]

void Print

References TextRenderer::print().

◆ Print() [10/15]

void Print

References TextRenderer::print().

◆ Print() [11/15]

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

◆ Print() [12/15]

void Print

References TextRenderer::print().

◆ Print() [13/15]

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

◆ Print() [14/15]

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

◆ Print() [15/15]

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

◆ PrintNoWrap() [1/4]

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

◆ PrintNoWrap() [2/4]

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

◆ printnowrap() [1/4]

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

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.

Implements TextRenderer.

References BasicFont::defaultalign, and BasicFont::printnowrap().

◆ printnowrap() [2/4]

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

◆ printnowrap() [3/4]

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

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.

Implements TextRenderer.

References BasicFont::color, and BasicFont::printnowrap().

◆ printnowrap() [4/4]

◆ PrintNoWrap() [3/4]

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

◆ PrintNoWrap() [4/4]

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

◆ SetColor()

void SetColor ( RGBAf  value)

Changes the the color of the text. Color can only be overridden through BasicFont interface.

References BasicFont::color.

◆ SetDefaultAlignment()

void SetDefaultAlignment ( TextAlignment  value)

Changes the default alignment. It is possible to override default alignment through TextRenderer interface.

References BasicFont::defaultalign.

Member Data Documentation

◆ color

RGBAf color
protected

Color of this renderer, can be overridden.

◆ defaultalign

TextAlignment defaultalign
protected

Default alignment if none is specified.


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