17#ifndef ENGINE_GRAPHICS_GFONT_H_
18#define ENGINE_GRAPHICS_GFONT_H_
28#include "freetype2/ft2build.h"
31#include "freetype2/freetype/freetype.h"
32#include <android/asset_manager.h>
34#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
35#include "freetype2/freetype/freetype.h"
37#if defined(WIN32) || defined(LINUX) || TARGET_OS_OSX
44#include <unordered_map>
72 bool load(
const std::string& fullPath,
int size,
bool isAntialiased =
true,
int dpi = 96);
92 bool loadFont(
const std::string& fontPath,
int size,
bool isAntialiased =
true,
int dpi = 96);
101 void drawText(
const std::string& text,
float x,
float y);
199 bool isloaded =
false;
200 std::string fullpath;
201 bool isantialiased =
false;
203 float fontsize = 0.0f;
204 int characternumlimit = 0;
206 bool iskerning =
false;
208 FT_Library ftlib =
nullptr;
209 FT_Face fontface =
nullptr;
211 float lineheight = 0.0f;
212 float letterspacing = 1.0f;
213 float spacesize = 1.0f;
216 void loadChar(
int charCode);
218 struct CharProperties {
219 float height = 0.0f, width = 0.0f;
220 float topmargin = 0.0f, leftmargin = 0.0f;
221 float advance = 0.0f;
222 float texturewidth = 0.0f, textureheight = 0.0f;
223 float dxleft = 0.0f, dxright = 0.0f, dytop = 0.0f, dybottom = 0.0f;
226 std::unordered_map<int, CharProperties> charproperties;
227 std::unordered_map<int, gTexture*> chartextures;
229 float getKerning(
int c,
int prevC)
const;
230 void resizeVectors(
int num);
231 bool insertData(
const unsigned char* srcData,
int srcWidth,
int srcHeight,
int componentNum,
232 unsigned char* dstData,
int dstWidth,
int dstHeight,
int dstComponentNum,
233 size_t dstFirstX,
size_t dstFirstY)
const;
234 std::wstring s2ws(
const std::string& s)
const;
235 float roundIfRequired(
float val);
Definition gEventHook.h:14
void onEvent(gEvent &event) override
bool loadFont(const std::string &fontPath, int size, bool isAntialiased=true, int dpi=96)
float getLineHeight() const
bool isAntialised() const
float getStringWidth(const std::string &text)
std::vector< std::string > wrapSentenceByWidth(const std::string &text, float maxWidth, TextAlign align=TextAlign::LEFT)
bool load(const std::string &fullPath, int size, bool isAntialiased=true, int dpi=96)
TextAlign
Definition gFont.h:49
void drawTextVerticallyFlipped(const std::string &text, float x, float y)
Draws the given text vertically flipped at the specified position.
float getStringHeight(const std::string &text)
const std::string & getPath() const
void drawText(const std::string &text, float x, float y)
void drawTextHorizontallyFlipped(const std::string &text, float x, float y)
Draws the given text horizontally flipped at the specified location.