synfig-core
1.0.3
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
src
modules
lyr_freetype
lyr_freetype.h
Go to the documentation of this file.
1
/* === S Y N F I G ========================================================= */
27
/* === S T A R T =========================================================== */
28
29
#ifndef __SYNFIG_LYR_FREETYPE_H
30
#define __SYNFIG_LYR_FREETYPE_H
31
32
/* === H E A D E R S ======================================================= */
33
34
//#ifdef __APPLE__
35
//#define USE_MAC_FT_FUNCS (1)
36
//#endif
37
38
#include <
synfig/layers/layer_composite.h
>
39
#include <
synfig/vector.h
>
40
#include <
synfig/color.h
>
41
#include <
synfig/string.h
>
42
43
#include <ft2build.h>
44
#include FT_FREETYPE_H
45
#include FT_GLYPH_H
46
#include <vector>
47
48
#include <
synfig/string.h
>
49
#include <
synfig/time.h
>
50
#include <
synfig/context.h
>
51
#include <
synfig/paramdesc.h
>
52
#include <
synfig/renddesc.h
>
53
#include <
synfig/surface.h
>
54
#include <
synfig/value.h
>
55
#include <
synfig/valuenode.h
>
56
#include <
synfig/canvas.h
>
57
58
59
#include <ETL/misc>
60
61
#ifdef USE_MAC_FT_FUNCS
62
#include <CoreServices/CoreServices.h>
63
#include FT_MAC_H
64
#endif
65
66
/* === M A C R O S ========================================================= */
67
68
/* === T Y P E D E F S ===================================================== */
69
70
/* === C L A S S E S & S T R U C T S ======================================= */
71
72
using namespace
synfig;
73
using namespace
std;
74
using namespace
etl;
75
76
77
struct
Glyph
78
{
79
FT_Glyph
glyph
;
80
FT_Vector
pos
;
81
//int width;
82
};
83
struct
TextLine
84
{
85
int
width
;
86
std::vector<Glyph>
glyph_table
;
87
88
TextLine
():width(0) { }
89
void
clear_and_free();
90
91
int
actual_height()
const
92
{
93
int
height(0);
94
95
std::vector<Glyph>::const_iterator iter;
96
for
(iter=glyph_table.begin();iter!=glyph_table.end();++iter)
97
{
98
FT_BBox glyph_bbox;
99
100
//FT_Glyph_Get_CBox( glyphs[n], ft_glyph_bbox_pixels, &glyph_bbox );
101
FT_Glyph_Get_CBox( iter->glyph, ft_glyph_bbox_subpixels, &glyph_bbox );
102
103
if
(glyph_bbox.yMax>height)
104
height=glyph_bbox.yMax;
105
}
106
return
height;
107
}
108
};
109
110
111
class
Layer_Freetype
:
public
synfig::Layer_Composite
,
public
synfig::Layer_NoDeform
112
{
113
SYNFIG_LAYER_MODULE_EXT
114
private
:
116
ValueBase
param_text;
118
ValueBase
param_color;
120
ValueBase
param_family;
122
ValueBase
param_style;
124
ValueBase
param_weight;
126
ValueBase
param_compress;
128
ValueBase
param_vcompress;
130
ValueBase
param_size;
132
ValueBase
param_orient;
134
ValueBase
param_origin;
136
ValueBase
param_font;
138
ValueBase
param_use_kerning;
140
ValueBase
param_grid_fit;
142
ValueBase
param_invert;
143
144
FT_Face face;
145
146
bool
old_version;
147
bool
needs_sync_;
148
149
void
sync();
150
151
synfig::Color
color_func(
const
synfig::Point
&x,
int
quality=10,
float
supersample=0)
const
;
152
153
mutable
synfig::Mutex
mutex;
154
155
public
:
156
Layer_Freetype
();
157
virtual
~
Layer_Freetype
();
158
159
virtual
bool
set_param(
const
String
& param,
const
synfig::ValueBase
&value);
160
virtual
ValueBase
get_param(
const
String
& param)
const
;
161
virtual
Color
get_color(
Context
context,
const
synfig::Point
&pos)
const
;
162
virtual
bool
accelerated_render(
Context
context,
Surface
*surface,
int
quality,
const
RendDesc
&renddesc,
ProgressCallback
*cb)
const
;
163
virtual
bool
accelerated_cairorender(
Context
context,cairo_t *cr,
int
quality,
const
RendDesc
&renddesc,
ProgressCallback
*cb)
const
;
164
165
virtual
Vocab
get_param_vocab()
const
;
166
167
virtual
bool
set_version
(
const
String
&ver){
if
(ver==
"0.1"
)old_version=
true
;
return
true
;}
168
virtual
void
reset_version
(){old_version=
false
;}
169
170
virtual
synfig::Rect
get_bounding_rect()
const
;
171
172
private
:
173
void
new_font(
const
synfig::String
&family,
int
style=0,
int
weight=400);
174
bool
new_font_(
const
synfig::String
&family,
int
style=0,
int
weight=400);
175
bool
new_face(
const
synfig::String
&newfont);
176
};
177
178
extern
FT_Library
ft_library
;
179
180
/* === E N D =============================================================== */
181
182
#endif
Generated on Mon Nov 16 2015 15:33:45 for synfig-core by
1.8.1.2