level 2
秋尚朋与剑2P
楼主
我按照本吧内vtk显示中文的教程已经实现了中文显示,但是当用到vtkTextWidget时,根本没有文字显示,请教各位我该如何解决?
以下是部分代码:
...
vtkTextProperty singleLineTextProp =new vtkTextPropertyUnicode();
singleLineTextProp.SetFontSize(60);
singleLineTextProp.SetFontFamilyToArial();
singleLineTextProp.BoldOff();
singleLineTextProp.ItalicOff();
singleLineTextProp.ShadowOff();
vtkTextMapper singleLineTextC = newvtkFTGLChineseCharacterMapper();
singleLineTextC.SetInput("测试widget显示中文");
singleLineTextC.SetTextProperty(singleLineTextProp);
vtkTextPropertyUnicode unicode2 = (vtkTextPropertyUnicode)(singleLineTextC.GetTextProperty());
unicode2.SetFontFileName("C:\\Windows\\Fonts\\simkai.ttf");
vtkTextActor textactor = new vtkTextActor();
textactor.SetTextProperty(singleLineTextC.GetTextProperty());
vtkTextRepresentation rep = new vtkTextRepresentation();
rep.GetPositionCoordinate().SetValue( .15, .15 );
rep.GetPosition2Coordinate().SetValue( .7, .2 );
vtkTextWidget widget = new vtkTextWidget();
widget.SetRepresentation( rep );
widget.SetInteractor(iren);
widget.SetTextActor(textactor);
widget.SelectableOff();
...
widget.On();
以上代码中,若textactor.SetTextProperty()改为textactor.SetInput("测试widget显示中文");就能显示英文,中文乱码,请教如何解决widget中显示中文?
2013年04月30日 08点04分
1
以下是部分代码:
...
vtkTextProperty singleLineTextProp =new vtkTextPropertyUnicode();
singleLineTextProp.SetFontSize(60);
singleLineTextProp.SetFontFamilyToArial();
singleLineTextProp.BoldOff();
singleLineTextProp.ItalicOff();
singleLineTextProp.ShadowOff();
vtkTextMapper singleLineTextC = newvtkFTGLChineseCharacterMapper();
singleLineTextC.SetInput("测试widget显示中文");
singleLineTextC.SetTextProperty(singleLineTextProp);
vtkTextPropertyUnicode unicode2 = (vtkTextPropertyUnicode)(singleLineTextC.GetTextProperty());
unicode2.SetFontFileName("C:\\Windows\\Fonts\\simkai.ttf");
vtkTextActor textactor = new vtkTextActor();
textactor.SetTextProperty(singleLineTextC.GetTextProperty());
vtkTextRepresentation rep = new vtkTextRepresentation();
rep.GetPositionCoordinate().SetValue( .15, .15 );
rep.GetPosition2Coordinate().SetValue( .7, .2 );
vtkTextWidget widget = new vtkTextWidget();
widget.SetRepresentation( rep );
widget.SetInteractor(iren);
widget.SetTextActor(textactor);
widget.SelectableOff();
...
widget.On();
以上代码中,若textactor.SetTextProperty()改为textactor.SetInput("测试widget显示中文");就能显示英文,中文乱码,请教如何解决widget中显示中文?