26 #ifndef vtkFreeTypeTools_h 
   27 #define vtkFreeTypeTools_h 
   30 #include "vtkRenderingFreeTypeModule.h"  
   43 #include "vtk_freetype.h"  
   44 #include FT_FREETYPE_H 
   51 class vtkTextPropertyLookup;
 
  108   vtkSetMacro(DebugTextures, 
bool);
 
  109   vtkGetMacro(DebugTextures, 
bool);
 
  110   vtkBooleanMacro(DebugTextures, 
bool);
 
  116   FT_Library* GetLibrary();
 
  148   vtkGetMacro(MaximumNumberOfFaces, 
unsigned int);
 
  150   vtkGetMacro(MaximumNumberOfSizes, 
unsigned int);
 
  152   vtkGetMacro(MaximumNumberOfBytes, 
unsigned long);
 
  191     int textDims[2] = 
nullptr);
 
  213   int GetConstrainedFontSize(
 
  216     int targetWidth, 
int targetHeight);
 
  223   static vtkTypeUInt16 HashString(
const char* str);
 
  229   static vtkTypeUInt32 HashBuffer(
const void* str, 
size_t n, vtkTypeUInt32 hash = 0);
 
  242   void MapTextPropertyToId(
vtkTextProperty* tprop, 
size_t* tprop_cache_id);
 
  243   void MapIdToTextProperty(
size_t tprop_cache_id, 
vtkTextProperty* tprop);
 
  253   vtkSetMacro(ScaleToPowerTwo, 
bool);
 
  254   vtkGetMacro(ScaleToPowerTwo, 
bool);
 
  255   vtkBooleanMacro(ScaleToPowerTwo, 
bool);
 
  264   vtkSetMacro(ForceCompiledFonts, 
bool);
 
  265   vtkGetMacro(ForceCompiledFonts, 
bool);
 
  266   vtkBooleanMacro(ForceCompiledFonts, 
bool);
 
  275   static bool LookupFace(
vtkTextProperty* tprop, FT_Library lib, FT_Face* face);
 
  281   virtual FT_Error CreateFTCManager();
 
  289   bool PrepareMetaData(
vtkTextProperty* tprop, 
int dpi, MetaData& metaData);
 
  326   bool GetGlyphIndex(
vtkTextProperty* tprop, FT_UInt32 c, FT_UInt* gindex);
 
  343     GLYPH_REQUEST_DEFAULT = 0,
 
  344     GLYPH_REQUEST_BITMAP = 1,
 
  345     GLYPH_REQUEST_OUTLINE = 2
 
  348     vtkTextProperty* tprop, FT_UInt32 c, FT_Glyph* glyph, 
int request = GLYPH_REQUEST_DEFAULT);
 
  349   bool GetSize(
size_t tprop_cache_id, 
int font_size, FT_Size* 
size);
 
  350   bool GetSize(FTC_Scaler scaler, FT_Size* 
size);
 
  351   bool GetFace(
size_t tprop_cache_id, FT_Face* face);
 
  352   bool GetGlyphIndex(
size_t tprop_cache_id, FT_UInt32 c, FT_UInt* gindex);
 
  353   bool GetGlyph(
size_t tprop_cache_id, 
int font_size, FT_UInt gindex, FT_Glyph* glyph,
 
  354     int request = GLYPH_REQUEST_DEFAULT);
 
  356     FTC_Scaler scaler, FT_UInt gindex, FT_Glyph* glyph, 
int request = GLYPH_REQUEST_DEFAULT);
 
  370   bool GetFace(
vtkTextProperty* prop, 
size_t& prop_cache_id, FT_Face& face, 
bool& face_has_kerning);
 
  376   FT_Bitmap* GetBitmap(FT_UInt32 c, 
size_t prop_cache_id, 
int prop_font_size, FT_UInt& gindex,
 
  377     FT_BitmapGlyph& bitmap_glyph);
 
  378   FT_Bitmap* GetBitmap(
 
  379     FT_UInt32 c, FTC_Scaler scaler, FT_UInt& gindex, FT_BitmapGlyph& bitmap_glyph);
 
  386   FT_Outline* GetOutline(FT_UInt32 c, 
size_t prop_cache_id, 
int prop_font_size, FT_UInt& gindex,
 
  387     FT_OutlineGlyph& outline_glyph);
 
  388   FT_Outline* GetOutline(
 
  389     FT_UInt32 c, FTC_Scaler scaler, FT_UInt& gindex, FT_OutlineGlyph& outline_glyph);
 
  420   FTC_Manager* GetCacheManager();
 
  421   FTC_ImageCache* GetImageCache();
 
  422   FTC_CMapCache* GetCMapCache();
 
  432   void InitializeCacheManager();
 
  433   void ReleaseCacheManager();
 
  442   template <
typename StringType>
 
  443   bool RenderStringInternal(
 
  449   template <
typename StringType>
 
  457   bool CalculateBoundingBox(
const vtkStdString& str, MetaData& metaData);
 
  459   template <
typename T>
 
  460   bool CalculateBoundingBox(
const T& str, MetaData& metaData, 
const T& defaultHeightString);
 
  468   template <
typename StringType, 
typename DataType>
 
  469   bool PopulateData(
const StringType& str, DataType 
data, MetaData& metaData);
 
  474   template <
typename IteratorType, 
typename DataType>
 
  476     IteratorType begin, IteratorType end, 
int lineIndex, DataType 
data, MetaData& metaData);
 
  482   template <
typename CharType>
 
  483   bool RenderCharacter(CharType character, 
int& x, 
int& y, FT_UInt& previousGlyphIndex,
 
  485   template <
typename CharType>
 
  486   bool RenderCharacter(CharType character, 
int& x, 
int& y, FT_UInt& previousGlyphIndex,
 
  487     vtkPath* path, MetaData& metaData);
 
  490   void OutlineToPath(
int x, 
int y, FT_Outline* outline, 
vtkPath* path);
 
  497   template <
typename T>
 
  498   int FitStringToBBox(
const T& str, MetaData& metaData, 
int targetWidth, 
int targetHeight);
 
  508   template <
typename T>
 
  509   void GetLineMetrics(T begin, T end, MetaData& metaData, 
int& width, 
int bbox[4]);