MeVisLab Toolbox Reference
View2DFont.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13
15
16#pragma once
17
18#include "SoView2DSystem.h"
19
23
30{
31public:
33 virtual ~View2DFont();
34
39 ALIGN_CENTER
40 };
41
44 virtual bool init(const char* fontname = nullptr) = 0;
45
47 virtual int getFontHeight(float fontSize) const = 0;
48
50 virtual int getFontAscender(float fontSize) const = 0;
51
53 virtual int getFontDescender(float fontSize) const = 0;
54
56 virtual int getStringWidth(float fontSize, const char* string, int len) const = 0;
57
62 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;
63
65 void drawStringFlipped(float dx, float dy, float fontSize, const float* color, const char* string, int length, bool shadow = true, const float* shadowColor = nullptr)
66 {
67 drawString(dx, dy, fontSize, color, string, length, shadow, shadowColor, true);
68 }
69
71 virtual void getTextSize(float fontSize, const char* text, int &width, int &height, float lineSpacing = 0.0f) const;
72
76 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);
77
78
81
86 static View2DFont* createFont(const char* fontname = nullptr);
87
88private:
90 static View2DFont* _globalFont;
91
92};
#define SOVIEW2D_API
File to resolve system dependencies in View2D library.
Abstract GL font drawing using FTGL.
Definition View2DFont.h:30
virtual ~View2DFont()
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 at the top-left corner.
virtual int getStringWidth(float fontSize, const char *string, int len) const =0
get width of simple string
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
Definition View2DFont.h:65
static View2DFont * createFont(const char *fontname=nullptr)
create a new font object with the given font name (/see init).
AlignXMode
align mode of multi-line text
Definition View2DFont.h:36
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 at the top-left corner color needs to poi...
Target mlrange_cast(Source arg)
Generic version of checked ML casts.