Hi, Serge,<br><br>As we switch to C# GUI with Managed C++, I follow your solution and try to display chinese characters. It doesn't work.<br><br>Below is my C++ code:<br>void MDKCaptionWidget::SetCaption(String^ aCaption)<br>{<br> vtkCaptionActor2D* captionActor = _captionRep->GetCaptionActor2D();<br><br> captionActor->GetCaptionTextProperty()->SetFontFamily(VTK_FONT_FILE);<br> captionActor->GetCaptionTextProperty()->SetFontFile("C:\\Windows\\winsxs\\amd64_microsoft-windows-font-truetype-simsun_31bf3856ad364e35_6.1.7600.16385_none_56fe10b1895fd80b\\simsun.ttc");<br> captionActor->SetCaption(vtkUnicodeString::from_utf16((const vtkTypeUInt16 *)marshal_as<std::wstring>(aCaption).c_str()).utf8_str());<br> //captionActor->SetCaption("\xE4\xB8\xAD\xE6\x96\x87");<br>}<br><div><br>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".<br><br>Even I directly write as follow:<br> captionActor->SetCaption("\xE4\xB8\xAD\xE6\x96\x87");<br><br>The chinese words are not displayed.<br><br>Thanks<br>Liu Peng<br></div>
<span>
</span>
<br> 在2016-09-12,"Serge Lalonde" <serge@infolytica.com> 写道:
<blockquote id="isReplyContent" style="padding-left:1ex; margin: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
-----原始邮件-----<br>
<b>发件人:</b>"Serge Lalonde" <serge@infolytica.com> <br>
<b>发送时间:</b>2016年09月12日 星期一<br>
<b>收件人:</b>"vtkusers" <vtkusers@vtk.org><br>
<b>主题:</b>Re: [vtkusers] Does vtkCaptionActor2D support chinese characters?<br>
<br>
I had summarized the steps in the VTK Users mailing list back in Jan
2015.<br>
Search for "VTK 6.1 no longer supports ASCII characters > 128?
(5.10.1 was ok)" in the archives.<br>
<br>
<div class="moz-cite-prefix">On 9/12/2016 9:20 AM, David Lonie
wrote:<br>
</div>
<blockquote cite="mid:CA+=e1otPQ9_4NBuU922Nu9ptB42yjnWr_WiXzYB4koPMHLebCw@mail.gmail.com" type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">On Sun, Sep 11, 2016 at 12:18 PM,
Liu_tj <span dir="ltr"><<a moz-do-not-send="true" href="mailto:tjlp@netease.com" target="_blank">tjlp@netease.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div>I want to give Chinese text annotation on 3D
model.Does vtkCaptionActor2D support chinese characters?
If no, what class should I use?<br>
</div>
</blockquote>
<div><br>
</div>
<div>vtkCaptionActor2D will work.</div>
<div><br>
</div>
<div>You'll need to provide a unicode font file (the
embedded fonts in VTK only support ASCII) via the caption
actor's GetCaptionTextProperty:</div>
<div><br>
</div>
<div>
<div>captionActor->GetCaptionTextProperty()->SetFontFamily(VTK_FONT_FILE);</div>
</div>
<div>
<div>captionActor->GetCaptionTextProperty()->SetFontFile("/path/to/some/unicode/font/file");</div>
</div>
<div><br>
</div>
<div>and then encode the caption text as UTF-8.</div>
<div><br>
</div>
<div>Hope this helps,</div>
<div>Dave</div>
<div><br>
</div>
<div> </div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Powered by <a class="moz-txt-link-abbreviated" href="http://www.kitware.com">www.kitware.com</a>
Visit other Kitware open-source projects at <a class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a>
Please keep messages on-topic and check the VTK FAQ at: <a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a>
Search the list archives at: <a class="moz-txt-link-freetext" href="http://markmail.org/search/?q=vtkusers">http://markmail.org/search/?q=vtkusers</a>
Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://public.kitware.com/mailman/listinfo/vtkusers">http://public.kitware.com/mailman/listinfo/vtkusers</a>
</pre>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<a href="http:://www.infolytica.com">www.infolytica.com </a><br>
300 Leo Pariseau, Suite 2222, Montreal, QC, Canada, H2X 4B3<br>
(514) 849-8752 x236, Fax: (514) 849-4239
</div>
</blockquote><br><br><span title="neteasefooter"><p> </p></span>