29 #ifndef vtkFreeTypeTools_h
30 #define vtkFreeTypeTools_h
33 #include "vtkRenderingFreeTypeModule.h"
45 #include "vtk_freetype.h"
46 #include FT_FREETYPE_H
53 class vtkTextPropertyLookup;
110 vtkSetMacro(DebugTextures,
bool);
111 vtkGetMacro(DebugTextures,
bool);
112 vtkBooleanMacro(DebugTextures,
bool);
118 FT_Library* GetLibrary();
140 std::array<int, 2> GetUnscaledKerning(
141 vtkTextProperty* tprop, vtkTypeUInt32 leftChar, vtkTypeUInt32 rightChar);
150 vtkGetMacro(MaximumNumberOfFaces,
unsigned int);
152 vtkGetMacro(MaximumNumberOfSizes,
unsigned int);
154 vtkGetMacro(MaximumNumberOfBytes,
unsigned long);
190 int textDims[2] =
nullptr);
209 int GetConstrainedFontSize(
217 static vtkTypeUInt16 HashString(
const char* str);
223 static vtkTypeUInt32 HashBuffer(
const void* buffer,
size_t n, vtkTypeUInt32 hash = 0);
236 void MapTextPropertyToId(
vtkTextProperty* tprop,
size_t* tprop_cache_id);
237 void MapIdToTextProperty(
size_t tprop_cache_id,
vtkTextProperty* tprop);
247 vtkSetMacro(ScaleToPowerTwo,
bool);
248 vtkGetMacro(ScaleToPowerTwo,
bool);
249 vtkBooleanMacro(ScaleToPowerTwo,
bool);
258 vtkSetMacro(ForceCompiledFonts,
bool);
259 vtkGetMacro(ForceCompiledFonts,
bool);
260 vtkBooleanMacro(ForceCompiledFonts,
bool);
269 static bool LookupFace(
vtkTextProperty* tprop, FT_Library lib, FT_Face* face);
275 virtual FT_Error CreateFTCManager();
283 bool PrepareMetaData(
vtkTextProperty* tprop,
int dpi, MetaData& metaData);
320 bool GetGlyphIndex(
vtkTextProperty* tprop, FT_UInt32 c, FT_UInt* gindex);
337 GLYPH_REQUEST_DEFAULT = 0,
338 GLYPH_REQUEST_BITMAP = 1,
339 GLYPH_REQUEST_OUTLINE = 2
342 vtkTextProperty* tprop, FT_UInt32 c, FT_Glyph* glyph,
int request = GLYPH_REQUEST_DEFAULT);
343 bool GetSize(
size_t tprop_cache_id,
int font_size, FT_Size*
size);
344 bool GetSize(FTC_Scaler scaler, FT_Size*
size);
345 bool GetFace(
size_t tprop_cache_id, FT_Face* face);
346 bool GetGlyphIndex(
size_t tprop_cache_id, FT_UInt32 c, FT_UInt* gindex);
347 bool GetGlyph(
size_t tprop_cache_id,
int font_size, FT_UInt gindex, FT_Glyph* glyph,
348 int request = GLYPH_REQUEST_DEFAULT);
350 FTC_Scaler scaler, FT_UInt gindex, FT_Glyph* glyph,
int request = GLYPH_REQUEST_DEFAULT);
364 bool GetFace(
vtkTextProperty* prop,
size_t& prop_cache_id, FT_Face& face,
bool& face_has_kerning);
370 FT_Bitmap* GetBitmap(FT_UInt32 c,
size_t prop_cache_id,
int prop_font_size, FT_UInt& gindex,
371 FT_BitmapGlyph& bitmap_glyph);
372 FT_Bitmap* GetBitmap(
373 FT_UInt32 c, FTC_Scaler scaler, FT_UInt& gindex, FT_BitmapGlyph& bitmap_glyph);
380 FT_Outline* GetOutline(FT_UInt32 c,
size_t prop_cache_id,
int prop_font_size, FT_UInt& gindex,
381 FT_OutlineGlyph& outline_glyph);
382 FT_Outline* GetOutline(
383 FT_UInt32 c, FTC_Scaler scaler, FT_UInt& gindex, FT_OutlineGlyph& outline_glyph);
414 FTC_Manager* GetCacheManager();
415 FTC_ImageCache* GetImageCache();
416 FTC_CMapCache* GetCMapCache();
426 void InitializeCacheManager();
427 void ReleaseCacheManager();
436 bool RenderStringInternal(
449 bool CalculateBoundingBox(
const vtkStdString& str, MetaData& metaData);
450 bool CalculateBoundingBox(
459 template <
typename DataType>
460 bool PopulateData(
const std::string& str, DataType
data, MetaData& metaData);
465 template <
typename DataType>
466 bool RenderLine(std::string::const_iterator begin, std::string::const_iterator end,
int lineIndex,
467 DataType
data, MetaData& metaData);
473 bool RenderCharacter(FT_UInt32 codepoint,
int& x,
int& y, FT_UInt& previousGlyphIndex,
475 bool RenderCharacter(FT_UInt32 codepoint,
int& x,
int& y, FT_UInt& previousGlyphIndex,
476 vtkPath* path, MetaData& metaData);
479 void OutlineToPath(
int x,
int y, FT_Outline* outline,
vtkPath* path);
487 const std::string& str, MetaData& metaData,
int targetWidth,
int targetHeight);
497 void GetLineMetrics(std::string::const_iterator begin, std::string::const_iterator end,
498 MetaData& metaData,
int& width,
int bbox[4]);
Wrapper around std::string to keep symbols short.
abstract base class for most VTK objects
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
concrete dataset representing a path defined by Bezier curves.
#define VTK_UNSIGNED_LONG_MAX
a simple class to control print indentation
topologically and geometrically regular array of data
#define VTK_UNSIGNED_INT_MAX
represent text properties.