Problem description
Normal Chinese characters in OpenCasCade cannot be displayed. After referring to eryar's blog OpenCascade Chinese Text Rendering, I found that the previous version can add Resource_Unicode::ConvertGBToUnicode() to the VDrawText function in OCCT. This command can be implemented. In version 7.2, the prototype The function has undergone great changes. Following this idea, this function is implemented in AIS_LabelText.
Code
TCollection_ExtendedString tostr;
Standard_CString str= "OpenCasCade 你好啊";
Resource_Unicode::ConvertGBToUnicode(str,tostr);
Handle(AIS_TextLabel) aLabel = new AIS_TextLabel();
aLabel -> SetText(tostr);
aLabel -> SetColor(Quantity_NOC_RED);
aLabel -> SetFont("SimHei");//一定要设置合适的字体,不然不能实现功能
Handle(AIS_InteractiveContext) myAISContext = GetDocument()->GetIC();
myAISContext->Display(aLabel,Standard_False);
Effect display