Commit 07e728b9 authored by David C. Lonie's avatar David C. Lonie

Add DPI awareness to text rendering.

parent c8d65517
......@@ -32,7 +32,7 @@ vtkWindow::vtkWindow()
strcpy( this->WindowName, windowname );
this->Erase = 1;
this->DoubleBuffer = 0;
this->DPI = 120;
this->DPI = 72;
this->TileViewport[0] = 0;
this->TileViewport[1] = 0;
this->TileViewport[2] = 1.0;
......
......@@ -120,7 +120,7 @@ public:
// Return a best estimate to the dots per inch of the display
// device being rendered (or printed).
vtkGetMacro(DPI,int);
vtkSetClampMacro(DPI,int,1,3000);
vtkSetClampMacro(DPI,int,1,VTK_INT_MAX);
// Description:
// Attempt to detect and set the DPI of the display device by querying the
......
......@@ -734,14 +734,19 @@ void vtkGL2PSExporter::DrawTextActor3D(vtkTextActor3D *textAct,
vtkTextProperty *tprop = textAct->GetTextProperty();
vtkNew<vtkPath> textPath;
vtkTextRenderer *tren = vtkTextRenderer::GetInstance();
if (tren)
if (!tren)
{
tren->StringToPath(tprop, vtkStdString(string), textPath.GetPointer());
vtkWarningMacro(<<"Cannot generate path data from 3D text string '"
<< string << "': Text renderer unavailable.");
return;
}
else
if (!tren->StringToPath(tprop, vtkStdString(string), textPath.GetPointer(),
vtkTextActor3D::GetRenderedDPI()))
{
vtkWarningMacro(<<"Cannot generate path data from 3D text string: "
<< string);
vtkWarningMacro(<<"Failed to generate path data from 3D text string '"
<< string << "': StringToPath failed.");
return;
}
......@@ -783,7 +788,8 @@ void vtkGL2PSExporter::DrawTextActor3D(vtkTextActor3D *textAct,
textPos[2] + (forward[2] * 0.0001)};
vtkTextRenderer::Metrics metrics;
if (tren->GetMetrics(tprop, string, metrics))
if (tren->GetMetrics(tprop, string, metrics,
vtkTextActor3D::GetRenderedDPI()))
{
vtkNew<vtkPath> bgPath;
bgPath->InsertNextPoint(static_cast<double>(metrics.TopLeft.GetX()),
......
......@@ -193,10 +193,19 @@ void vtkCaptionRepresentation::AdjustCaptionBoundary()
return;
}
vtkWindow *win = this->Renderer->GetVTKWindow();
if (!win)
{
vtkErrorMacro(<<"No render window available: cannot determine DPI.");
return;
}
int text_bbox[4];
if (!tren->GetBoundingBox(this->CaptionActor2D->GetCaptionTextProperty(),
this->CaptionActor2D->GetCaption(), text_bbox))
this->CaptionActor2D->GetCaption(), text_bbox,
win->GetDPI()))
{
vtkErrorMacro(<<"Error calculating caption bounding box.");
return;
}
......
......@@ -20,6 +20,7 @@
#include "vtkRenderer.h"
#include "vtkStdString.h"
#include "vtkCommand.h"
#include "vtkWindow.h"
class vtkTextRepresentationObserver : public vtkCommand
{
......@@ -270,9 +271,16 @@ void vtkTextRepresentation::CheckTextBoundary()
this->TextActor->ComputeScaledFont(this->GetRenderer());
vtkWindow *win = this->Renderer->GetVTKWindow();
if (!win)
{
vtkErrorMacro(<<"No render window available: cannot determine DPI.");
return;
}
int text_bbox[4];
if (!tren->GetBoundingBox(this->TextActor->GetScaledTextProperty(),
this->GetText(), text_bbox))
this->GetText(), text_bbox, win->GetDPI()))
{
return;
}
......
a84ace11ef6ec63994f9be321a24b5f9
50101c180fac543f8e5cff299c31cd59
cef3b676f5b613333f0299bef1304b2d
3b0a123f21ae9514f9b02beab27ab73c
......@@ -33,6 +33,7 @@
#include "vtkTextProperty.h"
#include "vtkVectorText.h"
#include "vtkViewport.h"
#include "vtkWindow.h"
vtkStandardNewMacro(vtkAxisActor);
vtkCxxSetObjectMacro(vtkAxisActor, Camera, vtkCamera);
......@@ -986,6 +987,13 @@ vtkAxisActor::SetLabelPositions2D(vtkViewport *viewport, bool force)
return;
}
vtkWindow *win = viewport->GetVTKWindow();
if (!win)
{
vtkErrorMacro(<<"No render window available: cannot determine DPI.");
return;
}
for (int i = 0; i < this->NumberOfLabelsBuilt; i++)
{
ptIdx = 4*i + 1;
......@@ -1002,7 +1010,8 @@ vtkAxisActor::SetLabelPositions2D(vtkViewport *viewport, bool force)
int bbox[4];
if (!tren->GetBoundingBox(this->LabelActors2D[i]->GetTextProperty(),
this->LabelActors2D[i]->GetInput(), bbox))
this->LabelActors2D[i]->GetInput(), bbox,
win->GetDPI()))
{
vtkErrorMacro(<< "Unable to calculate bounding box for label "
<< this->LabelActors2D[i]->GetInput());
......
......@@ -871,7 +871,8 @@ void vtkOpenGLContextDevice2D::DrawString(float *point,
if (image->GetNumberOfPoints() == 0 && image->GetNumberOfCells() == 0)
{
int textDims[2];
if (!this->TextRenderer->RenderString(this->TextProp, string, image,
if (!this->TextRenderer->RenderString(this->TextProp, string,
this->RenderWindow->GetDPI(), image,
textDims))
{
return;
......@@ -923,7 +924,8 @@ void vtkOpenGLContextDevice2D::DrawString(float *point,
void vtkOpenGLContextDevice2D::ComputeStringBounds(const vtkUnicodeString &string,
float bounds[4])
{
vtkVector2i box = this->TextRenderer->GetBounds(this->TextProp, string);
vtkVector2i box = this->TextRenderer->GetBounds(this->TextProp, string,
this->RenderWindow->GetDPI());
// Check for invalid bounding box
if (box[0] == VTK_INT_MIN || box[0] == VTK_INT_MAX ||
box[1] == VTK_INT_MIN || box[1] == VTK_INT_MAX)
......
......@@ -1256,7 +1256,8 @@ void vtkOpenGLContextDevice2D::DrawString(float *point,
if (image->GetNumberOfPoints() == 0 && image->GetNumberOfCells() == 0)
{
int textDims[2];
if (!this->TextRenderer->RenderString(this->TextProp, string, image,
if (!this->TextRenderer->RenderString(this->TextProp, string,
this->RenderWindow->GetDPI(), image,
textDims))
{
return;
......@@ -1317,7 +1318,8 @@ void vtkOpenGLContextDevice2D::DrawString(float *point,
void vtkOpenGLContextDevice2D::ComputeStringBounds(const vtkUnicodeString &string,
float bounds[4])
{
vtkVector2i box = this->TextRenderer->GetBounds(this->TextProp, string);
vtkVector2i box = this->TextRenderer->GetBounds(this->TextProp, string,
this->RenderWindow->GetDPI());
// Check for invalid bounding box
if (box[0] == VTK_INT_MIN || box[0] == VTK_INT_MAX ||
box[1] == VTK_INT_MIN || box[1] == VTK_INT_MAX)
......
......@@ -557,6 +557,11 @@ bool vtkLabeledContourMapper::PrepareRender(vtkRenderer *ren, vtkActor *act)
vtkCellArray *lines = input->GetLines();
vtkDataArray *scalars = input->GetPointData()->GetScalars();
vtkTextRenderer *tren = vtkTextRenderer::GetInstance();
if (!tren)
{
vtkErrorMacro(<< "Text renderer unavailable.");
return false;
}
// Maps scalar values to text properties:
typedef std::map<double, vtkTextProperty*> LabelPropertyMapType;
......@@ -638,7 +643,8 @@ bool vtkLabeledContourMapper::PrepareRender(vtkRenderer *ren, vtkActor *act)
it->TProp = tpropIt->second;
// Assign bounding box/dims.
if (!tren->GetBoundingBox(it->TProp, it->Text, it->BoundingBox.GetData()))
if (!tren->GetBoundingBox(it->TProp, it->Text, it->BoundingBox.GetData(),
vtkTextActor3D::GetRenderedDPI()))
{
vtkErrorMacro(<<"Error calculating bounding box for string '"
<< it->Text << "'.");
......
......@@ -49,9 +49,9 @@ public:
// is valid (it may not if GetBoundingBox() failed or if the string
// was empty).
virtual vtkVector2i GetBounds(vtkTextProperty *property,
const vtkUnicodeString& string) = 0;
const vtkUnicodeString& string, int dpi) = 0;
virtual vtkVector2i GetBounds(vtkTextProperty *property,
const vtkStdString& string) = 0;
const vtkStdString& string, int dpi) = 0;
// Description:
// Given a text property and a string, this function initializes the
......@@ -60,11 +60,11 @@ public:
// This is useful when ScaleToPowerOfTwo is true, and the image dimensions may
// not match the dimensions of the rendered text.
virtual int RenderString(vtkTextProperty *property,
const vtkUnicodeString& string,
const vtkUnicodeString& string, int dpi,
vtkImageData *data,
int textDims[2] = NULL) = 0;
virtual int RenderString(vtkTextProperty *property,
const vtkStdString& string,
const vtkStdString& string, int dpi,
vtkImageData *data,
int text_dims[2] = NULL) = 0;
......
......@@ -29,6 +29,7 @@
#include "vtkMath.h"
#include "vtkTextRenderer.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include <algorithm>
......@@ -101,6 +102,7 @@ vtkTextActor::vtkTextActor()
this->InputRendered = false;
this->FormerOrientation = 0.0;
this->RenderedDPI = 0;
this->TextRenderer = vtkTextRenderer::GetInstance();
if (!this->TextRenderer)
......@@ -175,7 +177,8 @@ int vtkTextActor::SetConstrainedFontSize(vtkViewport* viewport,
int targetWidth,
int targetHeight)
{
return this->SetConstrainedFontSize(this, viewport, targetWidth, targetHeight);
return this->SetConstrainedFontSize(this, viewport, targetWidth,
targetHeight);
}
......@@ -330,26 +333,43 @@ void vtkTextActor::SetNonLinearFontScale(double exp, int tgt)
}
// ----------------------------------------------------------------------------
bool vtkTextActor::RenderImage(vtkTextProperty *tprop, vtkViewport *)
bool vtkTextActor::RenderImage(vtkTextProperty *tprop, vtkViewport *vp)
{
vtkStdString text;
if (this->Input && this->Input[0])
{
text = this->Input;
}
return this->TextRenderer->RenderString(tprop, text, this->ImageData);
vtkWindow *win = vp->GetVTKWindow();
if (!win)
{
vtkErrorMacro(<<"No render window available: cannot determine DPI.");
return false;
}
return this->TextRenderer->RenderString(tprop, text, this->ImageData,
NULL, win->GetDPI());
}
// ----------------------------------------------------------------------------
bool vtkTextActor::GetImageBoundingBox(vtkTextProperty *tprop, vtkViewport *,
int bbox[4])
bool vtkTextActor::GetImageBoundingBox(vtkTextProperty *tprop, vtkViewport *vp,
int bbox[4])
{
vtkStdString text;
if (this->Input && this->Input[0])
{
text = this->Input;
}
return this->TextRenderer->GetBoundingBox(tprop, text, bbox);
vtkWindow *win = vp->GetVTKWindow();
if (!win)
{
vtkErrorMacro(<<"No render window available: cannot determine DPI.");
return false;
}
return this->TextRenderer->GetBoundingBox(tprop, text, bbox, win->GetDPI());
}
// ----------------------------------------------------------------------------
......@@ -718,9 +738,16 @@ void vtkTextActor::ComputeScaledFont(vtkViewport *viewport)
}
int max_height = static_cast<int>(this->MaximumLineHeight * size[1]);
vtkWindow *win = viewport->GetVTKWindow();
if (!win)
{
vtkErrorMacro(<<"No render window available: cannot determine DPI.");
return;
}
int fsize = this->TextRenderer->GetConstrainedFontSize(
this->Input, this->ScaledTextProperty, size[0],
(size[1] < max_height ? size[1] : max_height));
(size[1] < max_height ? size[1] : max_height), win->GetDPI());
if (fsize == -1)
{
......@@ -860,9 +887,17 @@ int vtkTextActor::UpdateRectangle(vtkViewport* viewport)
this->ComputeScaledFont(viewport);
}
vtkWindow *win = viewport->GetVTKWindow();
if (!win)
{
vtkErrorMacro(<<"No render window available: cannot determine DPI.");
return 0;
}
//check if we need to render the string
if(this->ScaledTextProperty->GetMTime() > this->BuildTime ||
!this->InputRendered || this->GetMTime() > this->BuildTime)
!this->InputRendered || this->GetMTime() > this->BuildTime ||
this->RenderedDPI != win->GetDPI())
{
if(!this->RenderImage(this->ScaledTextProperty, viewport))
{
......@@ -879,6 +914,7 @@ int vtkTextActor::UpdateRectangle(vtkViewport* viewport)
this->Texture->SetInputData(this->ImageData);
this->Texture->Modified();
this->InputRendered = true;
this->RenderedDPI = win->GetDPI();
this->BuildTime.Modified();
}
return 1;
......
......@@ -265,6 +265,7 @@ protected:
char *Input;
bool InputRendered;
double FormerOrientation;
int RenderedDPI;
vtkTextProperty *ScaledTextProperty;
......
......@@ -116,7 +116,8 @@ int vtkTextActor3D::GetBoundingBox(int bbox[4])
return 0;
}
if (!tRend->GetBoundingBox(this->TextProperty, this->Input, bbox))
if (!tRend->GetBoundingBox(this->TextProperty, this->Input, bbox,
vtkTextActor3D::GetRenderedDPI()))
{
vtkErrorMacro(<<"No text in input.");
return 0;
......@@ -137,18 +138,6 @@ int vtkTextActor3D::RenderOverlay(vtkViewport *viewport)
{
int rendered_something = 0;
// Is the viewport's RenderWindow capturing GL2PS-special props?
if (vtkRenderer *renderer = vtkRenderer::SafeDownCast(viewport))
{
if (vtkRenderWindow *renderWindow = renderer->GetRenderWindow())
{
if (renderWindow->GetCapturingGL2PSSpecialProps())
{
renderer->CaptureGL2PSSpecialProp(this);
}
}
}
if (this->UpdateImageActor() &&
this->ImageData &&
this->ImageData->GetNumberOfPoints() > 0)
......@@ -180,16 +169,7 @@ int vtkTextActor3D::RenderTranslucentPolygonalGeometry(vtkViewport *viewport)
// Does this prop have some translucent polygonal geometry?
int vtkTextActor3D::HasTranslucentPolygonalGeometry()
{
int result = 0;
if (this->UpdateImageActor() &&
this->ImageData &&
this->ImageData->GetNumberOfPoints() > 0)
{
result=this->ImageActor->HasTranslucentPolygonalGeometry();
}
return result;
return 1;
}
// --------------------------------------------------------------------------
......@@ -197,9 +177,20 @@ int vtkTextActor3D::RenderOpaqueGeometry(vtkViewport *viewport)
{
int rendered_something = 0;
if (vtkRenderer *renderer = vtkRenderer::SafeDownCast(viewport))
{
if (vtkRenderWindow *renderWindow = renderer->GetRenderWindow())
{
// Is the viewport's RenderWindow capturing GL2PS-special props?
if (renderWindow->GetCapturingGL2PSSpecialProps())
{
renderer->CaptureGL2PSSpecialProp(this);
}
}
}
if (this->UpdateImageActor() &&
this->ImageData &&
this->ImageData->GetNumberOfPoints() > 0)
this->ImageData && this->ImageData->GetNumberOfPoints() > 0)
{
rendered_something += this->ImageActor->RenderOpaqueGeometry(viewport);
}
......@@ -214,6 +205,7 @@ int vtkTextActor3D::UpdateImageActor()
if (!this->TextProperty)
{
vtkErrorMacro(<<"Need a text property to render text actor");
this->ImageActor->SetInputData(0);
return 0;
}
......@@ -251,12 +243,15 @@ int vtkTextActor3D::UpdateImageActor()
if (!tRend)
{
vtkErrorMacro(<<"Failed getting the TextRenderer instance.");
this->ImageActor->SetInputData(0);
return 0;
}
if (!tRend->RenderString(this->TextProperty, this->Input, this->ImageData))
if (!tRend->RenderString(this->TextProperty, this->Input, this->ImageData,
NULL, vtkTextActor3D::GetRenderedDPI()))
{
vtkErrorMacro(<<"Failed rendering text to buffer");
this->ImageActor->SetInputData(0);
return 0;
}
......
......@@ -54,6 +54,13 @@ public:
virtual void SetTextProperty(vtkTextProperty *p);
vtkGetObjectMacro(TextProperty,vtkTextProperty);
// Description:
// Since a 3D text actor is not pixel-aligned and positioned in 3D space,
// the text is rendered at a constant DPI, rather than using the current
// window DPI. This static method returns the DPI value used to produce the
// text images.
static int GetRenderedDPI() { return 72; }
// Description:
// Shallow copy of this text actor. Overloads the virtual
// vtkProp method.
......@@ -65,10 +72,10 @@ public:
void GetBounds(double bounds[6]) {this->vtkProp3D::GetBounds( bounds );}
// Description:
// Get the Freetype-derived real bounding box for the given vtkTextProperty
// Get the vtkTextRenderer-derived bounding box for the given vtkTextProperty
// and text string str. Results are returned in the four element bbox int
// array. This call can be used for sizing other elements.
virtual int GetBoundingBox(int bbox[4]);
int GetBoundingBox(int bbox[4]);
//BTX
// Description:
......
......@@ -29,6 +29,7 @@
#include "vtkTextProperty.h"
#include "vtkTextRenderer.h"
#include "vtkTexture.h"
#include "vtkWindow.h"
#include <algorithm>
......@@ -44,6 +45,8 @@ vtkTextMapper::vtkTextMapper()
this->Input = NULL;
this->TextProperty = NULL;
this->RenderedDPI = 0;
vtkNew<vtkTextProperty> tprop;
this->SetTextProperty(tprop.GetPointer());
......@@ -128,9 +131,17 @@ void vtkTextMapper::PrintSelf(ostream& os, vtkIndent indent)
}
//----------------------------------------------------------------------------
void vtkTextMapper::GetSize(vtkViewport *, int size[])
void vtkTextMapper::GetSize(vtkViewport *vp, int size[2])
{
UpdateImage();
vtkWindow *win = vp ? vp->GetVTKWindow() : NULL;
if (!win)
{
size[0] = size[1] = 0;
vtkErrorMacro(<<"No render window available: cannot determine DPI.");
return;
}
this->UpdateImage(win->GetDPI());
size[0] = this->TextDims[0];
size[1] = this->TextDims[1];
}
......@@ -161,7 +172,8 @@ int vtkTextMapper::SetConstrainedFontSize(vtkViewport *viewport,
//----------------------------------------------------------------------------
int vtkTextMapper::SetConstrainedFontSize(vtkTextMapper *tmapper, vtkViewport *viewport,
int vtkTextMapper::SetConstrainedFontSize(vtkTextMapper *tmapper,
vtkViewport *viewport,
int targetWidth, int targetHeight)
{
// If target "empty" just return
......@@ -357,8 +369,16 @@ void vtkTextMapper::RenderOverlay(vtkViewport *viewport, vtkActor2D *actor)
vtkRenderer *ren = NULL;
if (this->Input && this->Input[0])
{
this->UpdateImage();
this->UpdateQuad(actor);
vtkWindow *win = viewport->GetVTKWindow();
if (!win)
{
vtkErrorMacro(<<"No render window available: cannot determine DPI.");
return;
}
this->UpdateImage(win->GetDPI());
this->UpdateQuad(actor, win->GetDPI());
ren = vtkRenderer::SafeDownCast(viewport);
if (ren)
{
......@@ -438,13 +458,10 @@ int vtkTextMapper::GetNumberOfLines(const char *input)
#endif // VTK_LEGACY_REMOVE
//----------------------------------------------------------------------------
void vtkTextMapper::UpdateQuad(vtkActor2D *actor)
void vtkTextMapper::UpdateQuad(vtkActor2D *actor, int dpi)
{
vtkDebugMacro(<<"UpdateQuad called");
// Ensure that the image is up to date.
UpdateImage();
// Update texture coordinates:
if (this->Image->GetMTime() > this->TCoordsTime)
{
......@@ -503,7 +520,7 @@ void vtkTextMapper::UpdateQuad(vtkActor2D *actor)
{
if (!tren->GetBoundingBox(this->TextProperty,
this->Input ? this->Input : std::string(),
text_bbox))
text_bbox, dpi))
{
vtkErrorMacro(<<"Error calculating bounding box.");
}
......@@ -528,10 +545,11 @@ void vtkTextMapper::UpdateQuad(vtkActor2D *actor)
}
//----------------------------------------------------------------------------
void vtkTextMapper::UpdateImage()
void vtkTextMapper::UpdateImage(int dpi)
{
vtkDebugMacro(<<"UpdateImage called");
if (this->MTime > this->Image->GetMTime() ||
this->RenderedDPI != dpi ||
this->TextProperty->GetMTime() > this->Image->GetMTime())
{
vtkTextRenderer *tren = vtkTextRenderer::GetInstance();
......@@ -539,10 +557,11 @@ void vtkTextMapper::UpdateImage()
{
if (!tren->RenderString(this->TextProperty,
this->Input ? this->Input : std::string(),
this->Image.GetPointer(), this->TextDims))
this->Image.GetPointer(), this->TextDims, dpi))
{
vtkErrorMacro(<<"Texture generation failed.");
}
this->RenderedDPI = dpi;
vtkDebugMacro(<< "Text rendered to " << this->TextDims[0] << ", "
<< this->TextDims[1] << " buffer.");
}
......
......@@ -135,11 +135,12 @@ private:
vtkTextMapper(const vtkTextMapper&); // Not implemented.
void operator=(const vtkTextMapper&); // Not implemented.
void UpdateQuad(vtkActor2D *actor);
void UpdateImage();
void UpdateQuad(vtkActor2D *actor, int dpi);
void UpdateImage(int dpi);
int TextDims[2];
int RenderedDPI;
vtkTimeStamp CoordsTime;
vtkTimeStamp TCoordsTime;
vtkNew<vtkImageData> Image;
......
......@@ -146,16 +146,14 @@ public:
// ymin, ymax} of the rendered string in pixels. The origin of the bounding
// box is the anchor point described by the horizontal and vertical
// justification text property variables.
// Some rendering backends need the DPI of the target. If it is not provided,
// a DPI of 120 is assumed.
// Return true on success, false otherwise.
bool GetBoundingBox(vtkTextProperty *tprop, const vtkStdString &str,
int bbox[4], int dpi = 120, int backend = Default)
int bbox[4], int dpi, int backend = Default)
{
return this->GetBoundingBoxInternal(tprop, str, bbox, dpi, backend);
}
bool GetBoundingBox(vtkTextProperty *tprop, const vtkUnicodeString &str,
int bbox[4], int dpi = 120, int backend = Default)
int bbox[4], int dpi, int backend = Default)
{
return this->GetBoundingBoxInternal(tprop, str, bbox, dpi, backend);
}
......@@ -164,16 +162,14 @@ public:
// Description:
// Given a text property and a string, get some metrics for the rendered
// string.
// Some rendering backends need the DPI of the target. If it is not provided,
// a DPI of 120 is assumed.
// Return true on success, false otherwise.
bool GetMetrics(vtkTextProperty *tprop, const vtkStdString &str,
Metrics &metrics, int dpi = 120, int backend = Default)
Metrics &metrics, int dpi, int backend = Default)
{
return this->GetMetricsInternal(tprop, str, metrics, dpi, backend);
}
bool GetMetrics(vtkTextProperty *tprop, const vtkUnicodeString &str,
Metrics &metrics, int dpi = 120, int backend = Default)
Metrics &metrics, int dpi, int backend = Default)
{
return this->GetMetricsInternal(tprop, str, metrics, dpi, backend);
}
......@@ -191,16 +187,14 @@ public:
// The origin of the image's extents is aligned with the anchor point
// described by the text property's vertical and horizontal justification
// options.
// Some rendering backends need the DPI of the target. If it is not provided,
// a DPI of 120 is assumed.
bool RenderString(vtkTextProperty *tprop, const vtkStdString &str,
vtkImageData *data, int textDims[2] = NULL, int dpi = 120,
vtkImageData *data, int textDims[2], int dpi,
int backend = Default)
{
return this->RenderStringInternal(tprop, str, data, textDims, dpi, backend);
}
bool RenderString(vtkTextProperty *tprop, const vtkUnicodeString &str,
vtkImageData *data, int textDims[2] = NULL, int dpi = 120,
vtkImageData *data, int textDims[2], int dpi,
int backend = Default)
{
return this->RenderStringInternal(tprop, str, data, textDims, dpi, backend);
......@@ -211,17 +205,15 @@ public:
// tprop that is required to fit the string in the target rectangle. The
// computed font size will be set in @a tprop as well. If an error occurs,
// this function will return -1.
// Some rendering backends need the DPI of the target. If it is not provided,
// a DPI of 120 is assumed.
int GetConstrainedFontSize(const vtkStdString &str, vtkTextProperty *tprop,
int targetWidth, int targetHeight, int dpi = 120,
int targetWidth, int targetHeight, int dpi,
int backend = Default)
{
return this->GetConstrainedFontSizeInternal(str, tprop, targetWidth,
targetHeight, dpi, backend);
}
int GetConstrainedFontSize(const vtkUnicodeString &str, vtkTextProperty *tprop,
int targetWidth, int targetHeight, int dpi = 120,
int targetWidth, int targetHeight, int dpi,
int backend = Default)
{
return this->GetConstrainedFontSizeInternal(str, tprop, targetWidth,
......@@ -235,14 +227,14 @@ public:
// property's horizontal and vertical justification options.
// Return true on success, false otherwise.
bool StringToPath(vtkTextProperty *tprop, const vtkStdString &str,
vtkPath *path, int backend = Default)
vtkPath *path, int dpi, int backend = Default)
{
return this->StringToPathInternal(tprop, str, path, backend);
return this->StringToPathInternal(tprop, str, path, dpi, backend);
}
bool StringToPath(vtkTextProperty *tprop, const vtkUnicodeString &str,