[vtkusers] Does vtkCaptionActor2D support chinese characters?

Liu_tj tjlp at netease.com
Wed Feb 8 10:38:52 EST 2017

Hi, Serge,

As we switch to C# GUI with Managed C++, I follow your solution and try to display chinese characters. It doesn't work.

Below is my C++ code:
void MDKCaptionWidget::SetCaption(String^ aCaption)
        vtkCaptionActor2D* captionActor = _captionRep->GetCaptionActor2D();

        captionActor->SetCaption(vtkUnicodeString::from_utf16((const vtkTypeUInt16 *)marshal_as<std::wstring>(aCaption).c_str()).utf8_str());

simsun.ttc is the chinese truetype font file installed on my computer. The chinese string I pass is "中文", whose utf-8 code is "\xE4\xB8\xAD\xE6\x96\x87". But if I use vtkUnicodeString::from_utf16() to decode, I get "\x00\xB8\xAD\xE6\x96\x87".

Even I directly write as follow:

The chinese words are not displayed.

Liu Peng

在2016-09-12,"Serge Lalonde" <serge at infolytica.com> 写道: -----原始邮件-----
发件人:"Serge Lalonde" <serge at infolytica.com>
发送时间:2016年09月12日 星期一
收件人:"vtkusers" <vtkusers at vtk.org>
主题:Re: [vtkusers] Does vtkCaptionActor2D support chinese characters?

I had summarized the steps in the VTK Users mailing list back in Jan 2015.
Search for "VTK 6.1 no longer supports ASCII characters > 128? (5.10.1 was ok)" in the archives.

On 9/12/2016 9:20 AM, David Lonie wrote:

On Sun, Sep 11, 2016 at 12:18 PM, Liu_tj <tjlp at netease.com> wrote:

I want to give Chinese text annotation on 3D model.Does vtkCaptionActor2D support chinese characters? If no, what class should I use?

vtkCaptionActor2D will work.

You'll need to provide a unicode font file (the embedded fonts in VTK only support ASCII) via the caption actor's GetCaptionTextProperty:


and then encode the caption text as UTF-8.

Hope this helps,


Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:

300 Leo Pariseau, Suite 2222, Montreal, QC, Canada, H2X 4B3
(514) 849-8752 x236, Fax: (514) 849-4239
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170208/3e75e233/attachment.html>

More information about the vtkusers mailing list