17 #ifndef vtkFreeTypeTools_h
18 #define vtkFreeTypeTools_h
21 #include "vtkRenderingFreeTypeModule.h"
27 VTK_ABI_NAMESPACE_BEGIN
35 #include "vtk_freetype.h"
36 #include FT_FREETYPE_H
40 VTK_ABI_NAMESPACE_BEGIN
44 class vtkTextPropertyLookup;
101 vtkSetMacro(DebugTextures,
bool);
102 vtkGetMacro(DebugTextures,
bool);
103 vtkBooleanMacro(DebugTextures,
bool);
109 FT_Library* GetLibrary();
131 std::array<int, 2> GetUnscaledKerning(
132 vtkTextProperty* tprop, vtkTypeUInt32 leftChar, vtkTypeUInt32 rightChar);
141 vtkGetMacro(MaximumNumberOfFaces,
unsigned int);
143 vtkGetMacro(MaximumNumberOfSizes,
unsigned int);
145 vtkGetMacro(MaximumNumberOfBytes,
unsigned long);
181 int textDims[2] =
nullptr);
200 int GetConstrainedFontSize(
208 static vtkTypeUInt16 HashString(
const char* str);
214 static vtkTypeUInt32 HashBuffer(
const void* buffer,
size_t n, vtkTypeUInt32 hash = 0);
227 void MapTextPropertyToId(
vtkTextProperty* tprop,
size_t* tprop_cache_id);
228 void MapIdToTextProperty(
size_t tprop_cache_id,
vtkTextProperty* tprop);
238 vtkSetMacro(ScaleToPowerTwo,
bool);
239 vtkGetMacro(ScaleToPowerTwo,
bool);
240 vtkBooleanMacro(ScaleToPowerTwo,
bool);
249 vtkSetMacro(ForceCompiledFonts,
bool);
250 vtkGetMacro(ForceCompiledFonts,
bool);
251 vtkBooleanMacro(ForceCompiledFonts,
bool);
260 static bool LookupFace(
vtkTextProperty* tprop, FT_Library lib, FT_Face* face);
266 virtual FT_Error CreateFTCManager();
274 bool PrepareMetaData(
vtkTextProperty* tprop,
int dpi, MetaData& metaData);
311 bool GetGlyphIndex(
vtkTextProperty* tprop, FT_UInt32 c, FT_UInt* gindex);
328 GLYPH_REQUEST_DEFAULT = 0,
329 GLYPH_REQUEST_BITMAP = 1,
330 GLYPH_REQUEST_OUTLINE = 2
333 vtkTextProperty* tprop, FT_UInt32 c, FT_Glyph* glyph,
int request = GLYPH_REQUEST_DEFAULT);
334 bool GetSize(
size_t tprop_cache_id,
int font_size, FT_Size*
size);
335 bool GetSize(FTC_Scaler scaler, FT_Size*
size);
336 bool GetFace(
size_t tprop_cache_id, FT_Face* face);
337 bool GetGlyphIndex(
size_t tprop_cache_id, FT_UInt32 c, FT_UInt* gindex);
338 bool GetGlyph(
size_t tprop_cache_id,
int font_size, FT_UInt gindex, FT_Glyph* glyph,
339 int request = GLYPH_REQUEST_DEFAULT);
341 FTC_Scaler scaler, FT_UInt gindex, FT_Glyph* glyph,
int request = GLYPH_REQUEST_DEFAULT);
355 bool GetFace(
vtkTextProperty* prop,
size_t& prop_cache_id, FT_Face& face,
bool& face_has_kerning);
361 FT_Bitmap* GetBitmap(FT_UInt32 c,
size_t prop_cache_id,
int prop_font_size, FT_UInt& gindex,
362 FT_BitmapGlyph& bitmap_glyph);
363 FT_Bitmap* GetBitmap(
364 FT_UInt32 c, FTC_Scaler scaler, FT_UInt& gindex, FT_BitmapGlyph& bitmap_glyph);
371 FT_Outline* GetOutline(FT_UInt32 c,
size_t prop_cache_id,
int prop_font_size, FT_UInt& gindex,
372 FT_OutlineGlyph& outline_glyph);
373 FT_Outline* GetOutline(
374 FT_UInt32 c, FTC_Scaler scaler, FT_UInt& gindex, FT_OutlineGlyph& outline_glyph);
405 FTC_Manager* GetCacheManager();
406 FTC_ImageCache* GetImageCache();
407 FTC_CMapCache* GetCMapCache();
417 void InitializeCacheManager();
418 void ReleaseCacheManager();
427 bool RenderStringInternal(
440 bool CalculateBoundingBox(
const vtkStdString& str, MetaData& metaData);
441 bool CalculateBoundingBox(
450 template <
typename DataType>
451 bool PopulateData(
const std::string& str, DataType
data, MetaData& metaData);
456 template <
typename DataType>
457 bool RenderLine(std::string::const_iterator begin, std::string::const_iterator end,
int lineIndex,
458 DataType
data, MetaData& metaData);
464 bool RenderCharacter(FT_UInt32 codepoint,
int& x,
int& y, FT_UInt& previousGlyphIndex,
466 bool RenderCharacter(FT_UInt32 codepoint,
int& x,
int& y, FT_UInt& previousGlyphIndex,
467 vtkPath* path, MetaData& metaData);
470 void OutlineToPath(
int x,
int y, FT_Outline* outline,
vtkPath* path);
478 const std::string& str, MetaData& metaData,
int targetWidth,
int targetHeight);
488 void GetLineMetrics(std::string::const_iterator begin, std::string::const_iterator end,
489 MetaData& metaData,
int& width,
int bbox[4]);
496 VTK_ABI_NAMESPACE_END
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.