[vtkusers] Why the vtkTextProperty.SetFontSize() does not take effect?

David Lonie david.lonie at kitware.com
Tue Sep 20 10:23:24 EDT 2016


My mistake -- the method is vtkCaptionActor2D::GetCaptionTextProperty. It
also looks like the caption text actor is initialized to TEXT_SCALE_TO_PROP
(see vtkTextActor's TextScaleMode documentation). This will always resize
the text to fit inside a specified bounding box, instead of using the font
size. Try:

captionActor->GetTextActor()->SetTextScaleModeToNone();
captionActor->GetCaptionTextProperty()->SetFontSize(fontSize);

HTH,
Dave

On Tue, Sep 20, 2016 at 10:15 AM, Liu_tj <tjlp at netease.com> wrote:

> Hi, David,
>
> There is no member method GetTextProperty() for vtkCaptionActor2D. No
> matter how much the font size is, the display is the same. And I found a
> similar post http://public.kitware.com/pipermail/vtkusers/2004-June/
> 024902.html which is not answered.
>
> 在2016-09-20,"David Lonie" <david.lonie at kitware.com> 写道:
>
> -----原始邮件-----
> *发件人:*"David Lonie" <david.lonie at kitware.com>
> *发送时间:*2016年09月20日 星期二
> *收件人:*"Liu_tj" <tjlp at netease.com>
> *抄送:*"vtkusers" <vtkusers at vtk.org>
> *主题:*Re: [vtkusers] Why the vtkTextProperty.SetFontSize() does not take
> effect?
>
> On Sat, Sep 17, 2016 at 11:26 AM, Liu_tj <tjlp at netease.com> wrote:
>
>> Hi,
>>
>> I use vtkCaptionWidget to display text annotation on 3D model. My issue
>> is the font size of the text. Below is my C# code:
>>
>> vtkCaptionRepresentation rep = vtkCaptionRepresentation.New();
>> rep.GetCaptionActor2D().ThreeDimensionalLeaderOff();
>> rep.GetCaptionActor2D().GetTextActor().GetTextProperty().
>> SetFontSize(100);
>> rep.GetCaptionActor2D().GetTextActor().GetTextProperty().Set
>> FontFamily(4);
>> rep.GetCaptionActor2D().GetTextActor().GetTextProperty().
>> SetFontFile("simsunb.ttf");
>> rep.GetCaptionActor2D().GetCaptionTextProperty().SetColor(0.0, 1.0, 0.0);
>>
>
> Try setting it on rep.GetCaptionActor2D().GetTextProperty() instead of
> rep.GetCaptionActor2D().GetTextActor().GetTextProperty().
>
> Dave
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160920/5b5250d8/attachment.html>


More information about the vtkusers mailing list