36 enum AlignXMode { ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER };
40 virtual bool init(
const char* fontname =
nullptr) = 0;
52 virtual int getStringWidth(
float fontSize,
const char*
string,
int len = -1)
const = 0;
59 virtual void drawString(
float dx,
float dy,
float fontSize,
const float* color,
const char*
string,
int length,
60 bool shadow =
true,
const float* shadowColor =
nullptr,
bool flipped =
false) = 0;
63 void drawStringFlipped(
float dx,
float dy,
float fontSize,
const float* color,
const char*
string,
int length,
64 bool shadow =
true,
const float* shadowColor =
nullptr)
66 drawString(dx, dy, fontSize, color,
string, length, shadow, shadowColor,
true);
70 virtual void getTextSize(
float fontSize,
const char* text,
int& width,
int& height,
float lineSpacing = 0.0f)
const;
75 virtual void drawText(
float dx,
float dy,
float fontSize,
const float* color,
const char* text,
AlignXMode mode,
76 bool shadow =
true,
float lineSpacing = 0.0f,
const float* shadowColor =
nullptr);
#define SOVIEW2D_API
File to resolve system dependencies in View2D library.
Abstract GL font drawing using FTGL.
static View2DFont * createFont(const char *fontname=nullptr)
create a new font object with the given font name (/see init).
virtual int getFontDescender(float fontSize) const =0
get descender of font
virtual void getTextSize(float fontSize, const char *text, int &width, int &height, float lineSpacing=0.0f) const
returns size of the box spanned by text box
virtual int getFontAscender(float fontSize) const =0
get ascender of font
static View2DFont * globalFont()
get the global font used for annotations etc. (only call this within a valid GL context!...
virtual void drawText(float dx, float dy, float fontSize, const float *color, const char *text, AlignXMode mode, bool shadow=true, float lineSpacing=0.0f, const float *shadowColor=nullptr)
draws a multi-line text, lines are separated by , the drawing starts in the top-left corner.
virtual bool init(const char *fontname=nullptr)=0
init with given font (either just a font name without .ttf or an absolute path) requires a valid GL c...
virtual int getFontHeight(float fontSize) const =0
get height of font (ascender + descender)
void drawStringFlipped(float dx, float dy, float fontSize, const float *color, const char *string, int length, bool shadow=true, const float *shadowColor=nullptr)
as above for drawing a string up-side down where you don't need to specify all parameters
virtual int getStringWidth(float fontSize, const char *string, int len=-1) const =0
get width of simple string
AlignXMode
align mode of multi-line text
virtual void drawString(float dx, float dy, float fontSize, const float *color, const char *string, int length, bool shadow=true, const float *shadowColor=nullptr, bool flipped=false)=0
draws a simple string with no linefeeds, the drawing starts in the top-left corner color needs to poi...