26 #ifndef vtkFreeTypeTools_h
27 #define vtkFreeTypeTools_h
29 #include "vtkRenderingFreeTypeModule.h"
43 #include "vtk_freetype.h"
44 #include FT_FREETYPE_H
51 class vtkTextPropertyLookup;
107 vtkSetMacro(DebugTextures,
bool)
108 vtkGetMacro(DebugTextures,
bool)
109 vtkBooleanMacro(DebugTextures,
bool)
115 FT_Library* GetLibrary();
149 vtkGetMacro(MaximumNumberOfFaces,
unsigned int);
151 vtkGetMacro(MaximumNumberOfSizes,
unsigned int);
153 vtkGetMacro(MaximumNumberOfBytes,
unsigned long);
166 int dpi,
int bbox[4]);
168 int dpi,
int bbox[4]);
219 int dpi,
int targetWidth,
int targetHeight);
222 int targetWidth,
int targetHeight);
229 static vtkTypeUInt16 HashString(
const char *str);
235 static vtkTypeUInt32 HashBuffer(
const void* str,
size_t n, vtkTypeUInt32 hash = 0);
248 void MapTextPropertyToId(
vtkTextProperty *tprop,
size_t *tprop_cache_id);
249 void MapIdToTextProperty(
size_t tprop_cache_id,
vtkTextProperty *tprop);
259 vtkSetMacro(ScaleToPowerTwo,
bool);
260 vtkGetMacro(ScaleToPowerTwo,
bool);
261 vtkBooleanMacro(ScaleToPowerTwo,
bool);
270 vtkSetMacro(ForceCompiledFonts,
bool);
271 vtkGetMacro(ForceCompiledFonts,
bool);
272 vtkBooleanMacro(ForceCompiledFonts,
bool);
281 static bool LookupFace(
vtkTextProperty *tprop, FT_Library lib, FT_Face *face);
287 virtual FT_Error CreateFTCManager();
295 bool PrepareMetaData(
vtkTextProperty *tprop,
int dpi, MetaData &metaData);
297 ImageMetaData &metaData);
310 ImageMetaData &metaData);
334 bool GetGlyphIndex(
vtkTextProperty *tprop, FT_UInt32 c, FT_UInt *gindex);
351 GLYPH_REQUEST_DEFAULT = 0,
352 GLYPH_REQUEST_BITMAP = 1,
353 GLYPH_REQUEST_OUTLINE = 2
358 int request = GLYPH_REQUEST_DEFAULT);
359 bool GetSize(
size_t tprop_cache_id,
int font_size, FT_Size *
size);
360 bool GetSize(FTC_Scaler scaler, FT_Size *
size);
361 bool GetFace(
size_t tprop_cache_id, FT_Face *face);
362 bool GetGlyphIndex(
size_t tprop_cache_id, FT_UInt32 c,
364 bool GetGlyph(
size_t tprop_cache_id,
368 int request = GLYPH_REQUEST_DEFAULT);
369 bool GetGlyph(FTC_Scaler scaler,
372 int request = GLYPH_REQUEST_DEFAULT);
387 FT_Face &face,
bool &face_has_kerning);
393 FT_Bitmap* GetBitmap(FT_UInt32 c,
size_t prop_cache_id,
394 int prop_font_size, FT_UInt &gindex,
395 FT_BitmapGlyph &bitmap_glyph);
396 FT_Bitmap* GetBitmap(FT_UInt32 c, FTC_Scaler scaler, FT_UInt &gindex,
397 FT_BitmapGlyph &bitmap_glyph);
404 FT_Outline* GetOutline(FT_UInt32 c,
size_t prop_cache_id,
405 int prop_font_size, FT_UInt &gindex,
406 FT_OutlineGlyph &outline_glyph);
407 FT_Outline* GetOutline(FT_UInt32 c, FTC_Scaler scaler, FT_UInt &gindex,
408 FT_OutlineGlyph &outline_glyph);
439 FTC_Manager* GetCacheManager();
440 FTC_ImageCache* GetImageCache();
441 FTC_CMapCache* GetCMapCache();
451 void InitializeCacheManager();
452 void ReleaseCacheManager();
461 template <
typename StringType>
462 bool RenderStringInternal(
vtkTextProperty *tprop,
const StringType &str,
468 template <
typename StringType>
469 bool StringToPathInternal(
vtkTextProperty *tprop,
const StringType &str,
477 bool CalculateBoundingBox(
const vtkStdString& str, MetaData &metaData);
479 template <
typename T>
480 bool CalculateBoundingBox(
const T& str, MetaData &metaData,
const T& defaultHeightString);
488 template <
typename StringType,
typename DataType>
489 bool PopulateData(
const StringType& str, DataType
data, MetaData &metaData);
494 template <
typename IteratorType,
typename DataType>
495 bool RenderLine(IteratorType begin, IteratorType end,
int lineIndex,
496 DataType
data, MetaData &metaData);
502 template <
typename CharType>
503 bool RenderCharacter(CharType character,
int &x,
int &y,
506 template <
typename CharType>
507 bool RenderCharacter(CharType character,
int &x,
int &y,
508 FT_UInt &previousGlyphIndex,
vtkPath *path,
512 void OutlineToPath(
int x,
int y, FT_Outline *outline,
vtkPath *path);
519 template <
typename T>
520 int FitStringToBBox(
const T &str, MetaData &metaData,
int targetWidth,
532 void GetLineMetrics(T begin, T end, MetaData &metaData,
int &width,