zenilib: Zeni::Font Class Reference

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | List of all members
Zeni::Font Class Referenceabstract
Zenilib

Font Abstraction. More...

`#include <Font.h>`

Inherited by Zeni::Font_FT.

## Public Member Functions

| Font ()
| Instantiate a new Font with a call to get_Video().create_Font() More...
| Font (const float &glyph_height, const float &virtual_screen_height, const String &font_name="Untitled Font")
| Instantiate a new Font with a call to get_Video().create_Font() More...
virtual | ~Font ()
const String & | get_name () const
| Get the name of the font. More...
float | get_text_height () const
| Get the height of the font. The width is usually half the height, by default. More...
virtual float | get_text_width (const String &text) const =0
| Get the width of text rendering using this font. Approximately text_height * text.length() / 2.0f. More...
float | get_virtual_screen_height () const
| Get the intended virtual screen height for the rendering of this Font. More...
virtual void | render_text (const String &text, const Point2f &position, const Color &color, const JUSTIFY &justify=ZENI_DEFAULT_JUSTIFY) const =0
| Render text at screen position (x, y), with justification JUSTIFY. More...
virtual void | render_text (const String &text, const Point3f &position, const Vector3f &right, const Vector3f &down, const Color &color, const JUSTIFY &justify=ZENI_DEFAULT_JUSTIFY) const =0
| Render text with greater control over position and orientation, with justification JUSTIFY. More...

## Detailed Description

Font Abstraction.

The Font class allows one to render text using a TrueType font in both Direct3D and in OpenGL. It is done rather differently in both cases, however. In Direct3D, it is done using built in DirectX functions and rendered with screen coordinates. In OpenGL, it is done using SDL_ttf and textures. The result appears much the same.

Note
  TrueType fonts must be installed to work correctly in DirectX.
  Created with a call to get_Video().create_Font(...)

Warning
  Always instantiate a new Font with a call to get_Video().create_Font(). Do not directly call the class constrcutors.
  Text will look faded if you render to a clipped portion of the screen in OpenGL (e.g. split-screen multiplayer). The workaround is to choose a smaller font size and to transform the position of the text manually. Not to do so is essentially a coding error.

Author
  bazald

Contact: bazal.nosp@m.d@ze.nosp@m.nipex.nosp@m..com

Definition at line 70 of file Font.h.

## Constructor & Destructor Documentation

Zeni::Font::Font | ( |  | ) |

Instantiate a new Font with a call to get_Video().create_Font()

Definition at line 35 of file Font.cpp.

Zeni::Font::Font | ( | const float & | glyph_height,
|  | const float & | virtual_screen_height,
|  | const String & | font_name = `"Untitled Font"`
| ) |  |

Instantiate a new Font with a call to get_Video().create_Font()

Definition at line 41 of file Font.cpp.

virtual Zeni::Font::~Font | ( |  | ) |

inlinevirtual

Definition at line 79 of file Font.h.

## Member Function Documentation

const String & Zeni::Font::get_name | ( |  | ) | const

inline

Get the name of the font.

Definition at line 25 of file Font.hxx.

float Zeni::Font::get_text_height | ( |  | ) | const

inline

Get the height of the font. The width is usually half the height, by default.

Definition at line 29 of file Font.hxx.

Referenced by Zeni::Popup_Pause_State::render(), Zeni::Popup_Menu_State::Sound_Check_Box::render_impl(), Zeni::Text_Box::render_impl(), and Zeni::Widget_Renderer_Text::render_to().

virtual float Zeni::Font::get_text_width | ( | const String & | text | ) | const

pure virtual

Get the width of text rendering using this font. Approximately text_height * text.length() / 2.0f.

Implemented in Zeni::Font_FT.

Referenced by Zeni::Text_Box::on_accept(), Zeni::Popup_Menu_State::Sound_Check_Box::render_impl(), and Zeni::Text_Box::render_impl().

float Zeni::Font::get_virtual_screen_height | ( |  | ) | const

inline

Get the intended virtual screen height for the rendering of this Font.

Definition at line 33 of file Font.hxx.

virtual void Zeni::Font::render_text | ( | const String & | text,
|  | const Point2f & | position,
|  | const Color & | color,
|  | const JUSTIFY & | justify = `ZENI_DEFAULT_JUSTIFY`
| ) |  | const

pure virtual

Render text at screen position (x, y), with justification JUSTIFY.

Implemented in Zeni::Font_FT.

Referenced by Zeni::Popup_Pause_State::render(), Zeni::Popup_Menu_State::Sound_Check_Box::render_impl(), Zeni::Text_Box::render_impl(), and Zeni::Widget_Renderer_Text::render_to().

virtual void Zeni::Font::render_text | ( | const String & | text,
|  | const Point3f & | position,
|  | const Vector3f & | right,
|  | const Vector3f & | down,
|  | const Color & | color,
|  | const JUSTIFY & | justify = `ZENI_DEFAULT_JUSTIFY`
| ) |  | const

pure virtual

Render text with greater control over position and orientation, with justification JUSTIFY.

Implemented in Zeni::Font_FT.

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

- zenilib/jni/external/zenilib/zeni_graphics/Zeni/Font.h
- zenilib/jni/external/zenilib/zeni_graphics/Font.cpp
- zenilib/jni/external/zenilib/zeni_graphics/Zeni/Font.hxx