Hi, Serge,<br><br>I use pure C# code instead of C# with managed C++. Before I set the caption I transform the C# utf16 Chinese string to utf8. But it does not work. The code is as follow.<br><br>public static string Utf16ToUtf8(string utf16String)<br>{<br> byte[] utf16Bytes = Encoding.Unicode.GetBytes(utf16String);<br> byte[] utf8Bytes = Encoding.Convert(Encoding.Unicode, Encoding.UTF8, utf16Bytes);<br> string utf8String = Encoding.Default.GetString(utf8Bytes);<br> return utf8String;<br>}<br><br>vtkCaptionRepresentation rep = vtkCaptionRepresentation.New();<br>rep.GetCaptionActor2D().ThreeDimensionalLeaderOff();<br>rep.GetCaptionActor2D().GetTextActor().GetTextProperty().SetFontSize(25);<br>rep.GetCaptionActor2D().GetTextActor().GetTextProperty().SetFontFamily(4);<br>rep.GetCaptionActor2D().GetTextActor().GetTextProperty().SetFontFile("simsunb.ttf");<br>rep.GetCaptionActor2D().GetCaptionTextProperty().SetColor(0.0, 1.0, 0.0);<br>string utf8text = Utilities.Utf16ToUtf8(@"ab12测试");<br>rep.GetCaptionActor2D().SetCaption(utf8text);<br><div><br>....<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>