How to display special characters with AIS_TextLabel

I want to show the relationship between two edges, and I use AIS_TextLabel to achieve this function. For example, there are two parallel edges, I use the code below, however, it doesn't work. I know it should be converted to a unicode string, and I can show it on the widget made by Qt.

TCollection_ExtendedString extstr;
Standard_CString str= "∥";
Handle(AIS_TextLabel) aLabel = new AIS_TextLabel();
aLabel -> SetText(extstr);
aLabel -> SetColor(Quantity_NOC_RED);
aLabel -> SetFont("Arial");

Kirill Gavrilov's picture

To use non-standard symbols you should first identify fonts supporting such symbols. Unfortunately, tools like Word are not helpful here, because they automatically use fallback fonts (and keep it unclear which ones).

On the following page you may see that this symbol is not supported by normal fonts:

I don't know which font is used by browser here, but on Windows platform at least "SimSun" family provides it. On other platforms there might be another suitable font. OCCT already includes a logic for using fallback fonts for specific UNICODE ranges, but for the moment this logic is limited to Korean / CJK subranges, it might be further extended to include math symbols - patches and support requests are welcome.

Another alternative could be a free font "Y14.5M-2009.ttf" (Copyright 2008 Peter Kanold - public domain), which you may package within your application. You might need to do some tricks to interleave special symbols using non-standard font and normal text using desired font...

vinit View1
vdrawtext t "Parallel ∥" -height 30 -font "SimSun"

he huang's picture

Thanks a lot! I have solved this problem with the source code of "vdrawtext"