28 #ifndef __vtkFreeTypeTools_h
29 #define __vtkFreeTypeTools_h
31 #include "vtkRenderingFreeTypeModule.h"
32 #include "vtkObject.h"
36 class vtkTextProperty;
38 class vtkUnicodeString;
41 #include "vtk_freetype.h"
42 #include FT_FREETYPE_H
49 class vtkTextPropertyLookup;
66 void PrintSelf(ostream& os, vtkIndent indent);
76 FT_Library* GetLibrary();
82 vtkSetClampMacro(MaximumNumberOfFaces,
unsigned int,1,VTK_UNSIGNED_INT_MAX);
83 vtkGetMacro(MaximumNumberOfFaces,
unsigned int);
84 vtkSetClampMacro(MaximumNumberOfSizes,
unsigned int,1,VTK_UNSIGNED_INT_MAX);
85 vtkGetMacro(MaximumNumberOfSizes,
unsigned int);
86 vtkSetClampMacro(MaximumNumberOfBytes,
unsigned long,1,VTK_UNSIGNED_LONG_MAX);
87 vtkGetMacro(MaximumNumberOfBytes,
unsigned long);
100 bool GetBoundingBox(vtkTextProperty *tprop,
const vtkStdString& str,
102 bool GetBoundingBox(vtkTextProperty *tprop,
const vtkUnicodeString& str,
104 bool IsBoundingBoxValid(
int bbox[4]);
114 bool RenderString(vtkTextProperty *tprop,
const vtkStdString& str,
115 vtkImageData *data,
int textDims[2] = NULL);
116 bool RenderString(vtkTextProperty *tprop,
const vtkUnicodeString& str,
117 vtkImageData *data,
int textDims[2] = NULL);
123 bool StringToPath(vtkTextProperty *tprop,
const vtkStdString& str,
125 bool StringToPath(vtkTextProperty *tprop,
const vtkUnicodeString& str,
133 int GetConstrainedFontSize(
const vtkStdString &str, vtkTextProperty *tprop,
134 int targetWidth,
int targetHeight);
135 int GetConstrainedFontSize(
const vtkUnicodeString &str,
136 vtkTextProperty *tprop,
137 int targetWidth,
int targetHeight);
142 static vtkTypeUInt16 HashString(
const char *str);
153 void MapTextPropertyToId(vtkTextProperty *tprop,
unsigned long *tprop_cache_id);
154 void MapIdToTextProperty(
unsigned long tprop_cache_id, vtkTextProperty *tprop);
162 vtkSetMacro(ScaleToPowerTwo,
bool);
163 vtkGetMacro(ScaleToPowerTwo,
bool);
164 vtkBooleanMacro(ScaleToPowerTwo,
bool);
171 vtkSetMacro(ForceCompiledFonts,
bool);
172 vtkGetMacro(ForceCompiledFonts,
bool);
173 vtkBooleanMacro(ForceCompiledFonts,
bool);
180 static bool LookupFace(vtkTextProperty *tprop, FT_Library lib, FT_Face *face);
184 virtual FT_Error CreateFTCManager();
191 bool PrepareMetaData(vtkTextProperty *tprop, MetaData &metaData);
192 bool PrepareImageMetaData(vtkTextProperty *tprop, vtkImageData *image,
193 ImageMetaData &metaData);
198 template <
typename StringType>
199 bool RenderStringInternal(vtkTextProperty *tprop,
const StringType &str,
200 vtkImageData *data,
int textDims[2]);
205 template <
typename StringType>
206 bool StringToPathInternal(vtkTextProperty *tprop,
const StringType &str,
214 template <
typename T>
215 bool CalculateBoundingBox(
const T& str, MetaData &metaData);
220 void PrepareImageData(vtkImageData *data,
int bbox[4]);
226 template <
typename StringType,
typename DataType>
227 bool PopulateData(
const StringType& str, DataType data, MetaData &metaData);
233 template <
typename IteratorType,
typename DataType>
234 bool RenderLine(IteratorType begin, IteratorType end,
int lineIndex,
235 DataType data, MetaData &metaData);
241 template <
typename CharType>
242 bool RenderCharacter(CharType character,
int &x,
int &y,
243 FT_UInt &previousGlyphIndex, vtkImageData *image,
245 template <
typename CharType>
246 bool RenderCharacter(CharType character,
int &x,
int &y,
247 FT_UInt &previousGlyphIndex, vtkPath *path,
252 void JustifyPath(vtkPath *path, MetaData &metaData);
258 template <
typename T>
259 int FitStringToBBox(
const T &str, MetaData &metaData,
int targetWidth,
267 bool GetSize(vtkTextProperty *tprop, FT_Size *size);
273 bool GetFace(vtkTextProperty *tprop, FT_Face *face);
277 bool GetGlyphIndex(vtkTextProperty *tprop, FT_UInt32 c, FT_UInt *gindex);
292 GLYPH_REQUEST_DEFAULT = 0,
293 GLYPH_REQUEST_BITMAP = 1,
294 GLYPH_REQUEST_OUTLINE = 2
296 bool GetGlyph(vtkTextProperty *tprop,
299 int request = GLYPH_REQUEST_DEFAULT);
300 bool GetSize(
unsigned long tprop_cache_id,
int font_size, FT_Size *size);
301 bool GetFace(
unsigned long tprop_cache_id, FT_Face *face);
302 bool GetGlyphIndex(
unsigned long tprop_cache_id, FT_UInt32 c,
304 bool GetGlyph(
unsigned long tprop_cache_id,
308 int request = GLYPH_REQUEST_DEFAULT);
319 bool GetFace(vtkTextProperty *prop,
unsigned long &prop_cache_id,
320 FT_Face &face,
bool &face_has_kerning);
325 FT_Bitmap* GetBitmap(FT_UInt32 c,
unsigned long prop_cache_id,
326 int prop_font_size, FT_UInt &gindex,
327 FT_BitmapGlyph &bitmap_glyph);
332 FT_Outline* GetOutline(FT_UInt32 c,
unsigned long prop_cache_id,
333 int prop_font_size, FT_UInt &gindex,
334 FT_OutlineGlyph &outline_glyph);
344 void GetLineMetrics(T begin, T end, MetaData &metaData,
int &width,
367 FTC_Manager* GetCacheManager();
368 FTC_ImageCache* GetImageCache();
369 FTC_CMapCache* GetCMapCache();
378 void InitializeCacheManager();
379 void ReleaseCacheManager();