GlistEngine
Loading...
Searching...
No Matches
gFont Class Reference

#include <gFont.h>

Inheritance diagram for gFont:
Collaboration diagram for gFont:

Public Types

enum class  TextAlign { LEFT , CENTER , RIGHT , JUSTIFY }
 

Public Member Functions

 gFont ()
 
virtual ~gFont ()
 
bool load (const std::string &fullPath, int size, bool isAntialiased=true, int dpi=96)
 
bool loadFont (const std::string &fontPath, int size, bool isAntialiased=true, int dpi=96)
 
void drawText (const std::string &text, float x, float y)
 
void drawTextVerticallyFlipped (const std::string &text, float x, float y)
 Draws the given text vertically flipped at the specified position.
 
void drawTextHorizontallyFlipped (const std::string &text, float x, float y)
 Draws the given text horizontally flipped at the specified location.
 
float getStringWidth (const std::string &text)
 
float getStringHeight (const std::string &text)
 
float getLineHeight () const
 
const std::string & getPath () const
 
int getSize () const
 
bool isLoaded () const
 
bool isAntialised () const
 
int getDpi () const
 
std::vector< std::string > wrapSentenceByWidth (const std::string &text, float maxWidth, TextAlign align=TextAlign::LEFT)
 
void onEvent (gEvent &event) override
 
- Public Member Functions inherited from gNode
 gNode ()
 
virtual ~gNode ()
 
void move (float dx, float dy, float dz)
 
void move (const glm::vec3 &dv)
 
void rotate (const glm::quat &q)
 
void rotate (float radians, float ax, float ay, float az)
 
void rotateDeg (float degrees, float ax, float ay, float az)
 
void rotateAround (float radians, const glm::vec3 &axis, const glm::vec3 &point)
 
void rotateAroundDeg (float degrees, const glm::vec3 &axis, const glm::vec3 &point)
 
void scale (float sx, float sy, float sz)
 
void scale (float s)
 
void setPosition (float px, float py, float pz)
 
void setPosition (const glm::vec3 &pv)
 
void setOrientation (const glm::quat &o)
 
void setOrientation (const glm::vec3 &angles)
 
void setScale (const glm::vec3 &s)
 
void setScale (float sx, float sy, float sz)
 
void setScale (float s)
 
void truck (float distance)
 
void boom (float distance)
 
void dolly (float distance)
 
void tilt (float radians)
 
void tiltDeg (float degrees)
 
void pan (float radians)
 
void panDeg (float degrees)
 
void roll (float radians)
 
void rollDeg (float degrees)
 
float getPosX () const
 
float getPosY () const
 
float getPosZ () const
 
const glm::vec3 & getPosition () const
 
const glm::quat & getOrientation () const
 
const glm::vec3 & getScale () const
 
glm::vec3 getScalarDirectionX () const
 
glm::vec3 getScalarDirectionY () const
 
glm::vec3 getScalarDirectionZ () const
 
void setTransformationMatrix (const glm::mat4 &transformationMatrix)
 
const glm::mat4 & getTransformationMatrix () const
 
int getId () const
 
void setParent (gNode *parent)
 
gNodegetParent () const
 
void removeParent ()
 
void addChild (gNode *child)
 
void removeChild (gNode *child)
 
void removeChild (int gObjectId)
 
void setEnabled (bool isEnabled)
 
bool isEnabled () const
 
void pushMatrix () const
 
void popMatrix () const
 
- Public Member Functions inherited from gRenderObject
 gRenderObject ()
 
int getScreenWidth ()
 
int getScreenHeight ()
 
void pushMatrix ()
 
void popMatrix ()
 
- Public Member Functions inherited from gObject
 gObject ()
 
void logi (std::string message)
 
void logd (std::string message)
 
void logw (std::string message)
 
void loge (std::string message)
 
void logi (std::string tag, std::string message)
 
void logd (std::string tag, std::string message)
 
void logw (std::string tag, std::string message)
 
void loge (std::string tag, std::string message)
 
- Public Member Functions inherited from gEventHook
 gEventHook ()
 
virtual ~gEventHook ()
 

Additional Inherited Members

- Static Public Member Functions inherited from gRenderObject
static void setScreenSize (int screenWidth, int screenHeight)
 
static void setUnitScreenSize (int unitWidth, int unitHeight)
 
static void setScreenScaling (int screenScaling)
 
static void enableShadowMapping ()
 
static void disableShadowMapping ()
 
static bool isShadowMappingEnabled ()
 
static gRenderergetRenderer ()
 
static void destroyRenderer ()
 
static void createRenderer ()
 
- Static Public Member Functions inherited from gObject
static std::string gGetAppDir ()
 
static std::string gGetAssetsDir ()
 
static void gSetAssetsDir (std::string assetsDir)
 
static std::string gGetFilesDir ()
 
static std::string gGetImagesDir ()
 
static std::string gGetFontsDir ()
 
static std::string gGetModelsDir ()
 
static std::string gGetTexturesDir ()
 
static std::string gGetShadersDir ()
 
static std::string gGetSoundsDir ()
 
static std::string gGetDatabasesDir ()
 
static std::string gGetVideosDir ()
 
static void setCurrentResolution (int scalingNo, int currentResolutionNo)
 
- Static Public Attributes inherited from gObject
static const int LOGLEVEL_SILENT
 
static const int LOGLEVEL_DEBUG
 
static const int LOGLEVEL_INFO
 
static const int LOGLEVEL_WARNING
 
static const int LOGLEVEL_ERROR
 
- Static Public Attributes inherited from gEventHook
static std::list< gEventHook * > hooks
 
- Protected Member Functions inherited from gNode
virtual void processTransformationMatrix ()
 
- Protected Attributes inherited from gNode
gNodeparent
 
std::deque< gNode * > children
 
glm::mat4 localtransformationmatrix
 
bool isenabled
 
glm::vec3 position
 
glm::quat orientation
 
glm::vec3 scalevec
 
glm::vec3 prevposition
 
glm::quat prevorientation
 
glm::vec3 prevscalevec
 
- Static Protected Attributes inherited from gRenderObject
static bool isshadowmappingenabled
 
- Static Protected Attributes inherited from gObject
static int renderpassnum
 
static int renderpassno
 
static int releasescaling
 
static int releaseresolution
 

Member Enumeration Documentation

◆ TextAlign

enum class gFont::TextAlign
strong
Enumerator
LEFT 
CENTER 
RIGHT 
JUSTIFY 

Constructor & Destructor Documentation

◆ gFont()

gFont::gFont ( )

◆ ~gFont()

virtual gFont::~gFont ( )
virtual

Member Function Documentation

◆ drawText()

void gFont::drawText ( const std::string &  text,
float  x,
float  y 
)
   Draws the text to the given screen coordinates

   @param std::string text - The text to be printed.
   @param float x - x coordinate of the region you want to draw

, *

Parameters
floaty - y coordinate of the region you want to draw

◆ drawTextHorizontallyFlipped()

void gFont::drawTextHorizontallyFlipped ( const std::string &  text,
float  x,
float  y 
)

Draws the given text horizontally flipped at the specified location.

See also
drawText

◆ drawTextVerticallyFlipped()

void gFont::drawTextVerticallyFlipped ( const std::string &  text,
float  x,
float  y 
)

Draws the given text vertically flipped at the specified position.

See also
drawText

◆ getDpi()

int gFont::getDpi ( ) const

Returns the dpi of the font Dpi is a measure of resolution used for printed text or images, the higher the dots per inch, the higher the resolution.

Returns
The dpi value

◆ getLineHeight()

float gFont::getLineHeight ( ) const

Returns the line's height

Returns
Line height

◆ getPath()

const std::string & gFont::getPath ( ) const

Returns the path of the loaded font.

Returns
The path of the font

◆ getSize()

int gFont::getSize ( ) const

Returns the font's size

Returns
Font size

◆ getStringHeight()

float gFont::getStringHeight ( const std::string &  text)

Calculates text's height

May cause performance drops when used inside the main loop.

Parameters
textThe text to calculate the height
Returns
The height of the given text

◆ getStringWidth()

float gFont::getStringWidth ( const std::string &  text)

Calculates text's width

May cause performance drops when used inside the main loop.

Parameters
textThe text to calculate the width
Returns
The width of the given text

◆ isAntialised()

bool gFont::isAntialised ( ) const

Returns if the antialiasing is enabled

Returns
The antialiasing

◆ isLoaded()

bool gFont::isLoaded ( ) const

Returns if the font is loaded or not

Returns
The font is loaded or not

◆ load()

bool gFont::load ( const std::string &  fullPath,
int  size,
bool  isAntialiased = true,
int  dpi = 96 
)

Loads a font from the given fullPath

Developers could use this function for loading font and giving text's features.

Developers do not need to enter the isAntialiased and the dpi values because those values are given automatically.

Font files may be stored anywhere on the drives.

Parameters
std::stringfullPath The full path to the font file. It should contain the full path of the folder where the font is located.
intsize - The size of the font
boolisAntialised - This is used in digital imaging to reduce visual imperfections and developers don't need to give value.
intdpi - The measure of resolution used for printed text or images and developers don't need to give value
Returns
boolean indicating if font is loaded

◆ loadFont()

bool gFont::loadFont ( const std::string &  fontPath,
int  size,
bool  isAntialiased = true,
int  dpi = 96 
)

Loads a font from the given fontPath

Developers could use this function for loading font and giving text's features.

Developers do not need to enter the isAntialiased and the dpi values because those values are given automatically.

Font files should be stored in the GlistEngine's assets/fonts folder.

Parameters
std::stringfontPath - The font path to the font file. It should contain the font path of the folder where the font is located.
intsize - This is the size of the font. Developers are recommended to use 6 and its multiples.
boolisAntialised - This is used in digital imaging to reduce visual imperfections and developers don't need to give value.
intdpi - This is a measure of resolution used for printed text or images and developers don't need to give value
Returns
boolean indicating if font is loaded

◆ onEvent()

void gFont::onEvent ( gEvent event)
overridevirtual

Implements gEventHook.

◆ wrapSentenceByWidth()

std::vector< std::string > gFont::wrapSentenceByWidth ( const std::string &  text,
float  maxWidth,
TextAlign  align = TextAlign::LEFT 
)

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