[vtkusers] Chinese or Russian Text
Richard Frank
rickfrank at me.com
Thu Feb 16 17:58:22 EST 2017
Hi,
We are trying to add unicode to our vtk render windows and we haven't been able to get it to work.
I modified the DrawText.cxx example with the following
// Setup the text and add it to the renderer
vtkSmartPointer<vtkTextActor> textActor =
vtkSmartPointer<vtkTextActor>::New();
std::string testString = u8"I have a red car.";
textActor->SetInput (testString.c_str());
textActor->SetPosition2 ( 10, 40 );
textActor->GetTextProperty()->SetFontSize ( 24 );
textActor->GetTextProperty()->SetColor ( 1.0, 0.0, 0.0 );
renderer->AddActor2D ( textActor );
// Setup the text and add it to the renderer
vtkSmartPointer<vtkTextActor> textActor2 =
vtkSmartPointer<vtkTextActor>::New();
std::string testString2 = u8"我有一辆红色的汽车。";
textActor2->SetInput(testString2.c_str());
textActor2->SetPosition(10, 80);
textActor2->GetTextProperty()->SetFontFamilyAsString("Microsoft YaHei");
textActor2->GetTextProperty()->SetFontFile("D:\\Projects\\DrawText\\msyhl.ttc");
textActor2->GetTextProperty()->SetFontSize(24);
textActor2->GetTextProperty()->SetColor(0.0, 0.0, 1.0);
renderer->AddActor2D(textActor2);
// Render and interact
renderWindow->Render();
but nothing draws for the chinese text. Is there anything else needed? Or is it a bug?
I can make my DrawText.cxx, Cmake and font file available.
Thanks
Rick Frank
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170216/88dd0a08/attachment.html>
More information about the vtkusers
mailing list