1 /* === S Y N F I G ========================================================= */
2 /*! \file lyr_freetype.h
3 ** \brief Header file for implementation of the "Text" layer
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2007, 2008 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 ** === N O T E S ===========================================================
24 ** ========================================================================= */
26 /* === S T A R T =========================================================== */
28 #ifndef __SYNFIG_LYR_FREETYPE_H
29 #define __SYNFIG_LYR_FREETYPE_H
31 /* === H E A D E R S ======================================================= */
34 //#define USE_MAC_FT_FUNCS (1)
37 #include <synfig/layer_composite.h>
38 #include <synfig/vector.h>
39 #include <synfig/color.h>
40 #include <synfig/string.h>
43 #include FT_FREETYPE_H
47 #include <synfig/string.h>
48 #include <synfig/time.h>
49 #include <synfig/context.h>
50 #include <synfig/paramdesc.h>
51 #include <synfig/renddesc.h>
52 #include <synfig/surface.h>
53 #include <synfig/value.h>
54 #include <synfig/valuenode.h>
55 #include <synfig/canvas.h>
60 #ifdef USE_MAC_FT_FUNCS
61 #include <CoreServices/CoreServices.h>
65 /* === M A C R O S ========================================================= */
67 /* === T Y P E D E F S ===================================================== */
69 /* === C L A S S E S & S T R U C T S ======================================= */
71 using namespace synfig;
85 std::vector<Glyph> glyph_table;
87 TextLine():width(0) { }
88 void clear_and_free();
90 int actual_height()const
94 std::vector<Glyph>::const_iterator iter;
95 for(iter=glyph_table.begin();iter!=glyph_table.end();++iter)
99 //FT_Glyph_Get_CBox( glyphs[n], ft_glyph_bbox_pixels, &glyph_bbox );
100 FT_Glyph_Get_CBox( iter->glyph, ft_glyph_bbox_subpixels, &glyph_bbox );
102 if(glyph_bbox.yMax>height)
103 height=glyph_bbox.yMax;
110 class Layer_Freetype : public synfig::Layer_Composite, public synfig::Layer_NoDeform
112 SYNFIG_LAYER_MODULE_EXT
117 synfig::String family;
120 synfig::Vector orient;
122 synfig::Point origin;
123 synfig::Real compress;
124 synfig::Real vcompress;
137 synfig::Color color_func(const synfig::Point &x, int quality=10, float supersample=0)const;
139 mutable synfig::Mutex mutex;
143 virtual ~Layer_Freetype();
145 virtual bool set_param(const String & param, const synfig::ValueBase &value);
146 virtual ValueBase get_param(const String & param)const;
147 virtual Color get_color(Context context, const synfig::Point &pos)const;
148 virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
150 virtual Vocab get_param_vocab()const;
152 virtual bool set_version(const String &ver){if(ver=="0.1")old_version=true;return true;}
153 virtual void reset_version(){old_version=false;}
155 virtual synfig::Rect get_bounding_rect()const;
158 void new_font(const synfig::String &family, int style=0, int weight=400);
159 bool new_font_(const synfig::String &family, int style=0, int weight=400);
160 bool new_face(const synfig::String &newfont);
163 extern FT_Library ft_library;
165 /* === E N D =============================================================== */