BitmapToolkit Scol plugin
BitmapToolkitText.h
Go to the documentation of this file.
1#ifndef __BITMAPTOOLKIT_TEXT_H__
2#define __BITMAPTOOLKIT_TEXT_H__
3
4#include <scolPlugin.h>
5
6#include <opencv2/opencv.hpp>
7#include <tuple>
8
9#ifdef BT_USE_FREETYPE
10 #include "freetypeFont.h"
11#endif
12
13extern int SObjBTFont;
14
15// Font look
16#define BT_FONT_BOLD 0x1
17#define BT_FONT_ITALIC 0x10
18#define BT_FONT_ANTIALIAS 0x100
19#define BT_FONT_FILLED 0x0000
20#define BT_FONT_HOLLOW 0x1000
21
22// Font face
23#define BT_FONT_SANS 0
24#define BT_FONT_SERIF 1
25#define BT_FONT_SCRIPT 2
26
27// Text alignment horizontal
28#define BT_TEXT_HORIZ_MASK (0x1 << 0 | 0x1 << 1)
29#define BT_TEXT_HORIZ_LEFT (0x0 << 0)
30#define BT_TEXT_HORIZ_RIGHT (0x1 << 0)
31#define BT_TEXT_HORIZ_CENTERED (0x1 << 1)
32#define BT_TEXT_HORIZ_JUSTIFIED (0x1 << 0 | 0x1 << 1)
33
34// Text alignment vertical
35#define BT_TEXT_VERT_MASK (0x1 << 2 | 0x1 << 3)
36#define BT_TEXT_VERT_TOP (0x0 << 0)
37#define BT_TEXT_VERT_CENTER (0x1 << 2)
38#define BT_TEXT_VERT_BOTTOM (0x1 << 3)
39
40// Word wrap
41#define BT_TEXT_WORD_WRAP (0x1 << 4)
42#define BT_CHARSET "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,;:!./§&é(-è_çà@)]=}$¤*ùµ%"
43#define BT_CHARSETREF "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
44
45struct btfonts
46{
47 static bool initialized;
48 struct type
49 {
50 int face;
51 bool bold;
53 bool italic;
54 type(int f = 0, bool b = false, bool eb = false, bool i = false) : face(f), bold(b), extra_bold(eb), italic(i) {}
55 };
56 static std::map<std::string, type> font_to_cv;
57 static void initialize();
58 static type& get(std::string name);
59 static bool has(std::string name);
60};
61
63{
64public:
65 int face;
66 float scale;
71 int size;
72 int mode;
73 cv::Size baseSize;
74#ifdef BT_USE_FREETYPE
75 cv::Ptr<cv::freetype::FreeTypeFont> ft2;
76#endif
77
78 ObjBTFont(int pmode = 0)
79 {
80 face = cv::FONT_HERSHEY_SIMPLEX;
81 scale = 1.0f;
82 thickness = 1;
83 linetype = cv::LINE_AA;
84 lineOffset = 1.0f;
85 xoffset = 0;
86 size = 16;
87 mode = pmode;
88
89#ifdef BT_USE_FREETYPE
90 if (pmode)
92#endif
93 }
94
96 {
97#ifdef BT_USE_FREETYPE
98 if (!ft2.empty())
99 ft2.release();
100#endif
101 }
102};
104
105int destroyCVFont(mmachine m, SCOL_PTR_TYPE handsys, int obj);
106
107int _CRBTfont(mmachine m);
108int _CRBTfontFromFile(mmachine m);
109int _DSBTfont(mmachine m);
110int _BTDRAWtextBitmap(mmachine m);
111int _BTDRAWtextAreaBitmap(mmachine m);
112int _BTDRAWtextAlphaBitmap(mmachine m);
113int _BTDRAWtextAreaAlphaBitmap(mmachine m);
114int _BTGETtextSize(mmachine m);
115int _BTGETtextAreaHeight(mmachine m);
116
117int _BTBLENDbitmaps(mmachine m);
118int _BTBLENDalphaBitmaps(mmachine m);
119
120#endif
ObjBTFont * PtrObjBTFont
int SObjBTFont
int destroyCVFont(mmachine m, SCOL_PTR_TYPE handsys, int obj)
cv::Size baseSize
ObjBTFont(int pmode=0)
Ptr< FreeTypeFont > createFreeTypeFont()
Create FreeType2 Instance.
int _BTBLENDalphaBitmaps(mmachine m)
_BTBLENDalphaBitmaps : blends 2 alpha bitmaps. Takes a piece of the src to blit it in a piece of the ...
int _BTBLENDbitmaps(mmachine m)
_BTBLENDbitmaps : blends 2 bitmaps from percentage value. Takes a piece of the src to blit it in a pi...
int _CRBTfont(mmachine m)
_CRBTfont : Creates a ObjBTFont object Prototype: fun [Chn S I I F] ObjBTFont
int _CRBTfontFromFile(mmachine m)
_CRBTfontFromFile : Creates a ObjBTFont object Prototype: fun [Chn P I I F] ObjBTFont
int _BTDRAWtextAlphaBitmap(mmachine m)
_BTDRAWtextAlphaBitmap : Draws a text to a bitmap Prototype: fun [AlphaBitmap ObjBTFont [I I] I I I S...
int _BTDRAWtextAreaAlphaBitmap(mmachine m)
_BTDRAWtextAreaAlphaBitmap : Draws a text to an alpha bitmap, within a defined area Prototype: fun [A...
int _BTDRAWtextBitmap(mmachine m)
_BTDRAWtextBitmap : Draws a text to a bitmap Prototype: fun [ObjBitmap S ObjBTFont [I I] I I] ObjBitm...
int _BTGETtextSize(mmachine m)
_BTGETtextSize : Gets the length of a text line Prototype: fun [ObjBTFont S] [I I]
int _BTGETtextAreaHeight(mmachine m)
_BTGETtextAreaHeight : Gets the height of a formated text area Prototype: fun [ObjBTFont S I I] I
int _DSBTfont(mmachine m)
_DSBTfont : Deletes a cv font object Prototype: fun [ObjBTFont] I
int _BTDRAWtextAreaBitmap(mmachine m)
_BTDRAWtextAreaBitmap : Draws a text to a bitmap, within a defined area Prototype: fun [ObjBitmap Obj...
type(int f=0, bool b=false, bool eb=false, bool i=false)
static type & get(std::string name)
static bool has(std::string name)
static bool initialized
static std::map< std::string, type > font_to_cv
static void initialize()