How to insert Text with with non-english characters

When you define a Text element using UTF-8 characters, be sure to include a compatible font.

e.g.


void CHPSView::OnUserCode3()
{

	auto segKey = GetCanvas().GetFrontView().GetAttachedModel().GetSegmentKey();

	TextKit tk1; //font set
	tk1.SetFont("Yu Gothic");
	tk1.SetText("こんにちは");
	tk1.SetPosition(Point(0, 0, 0));
	segKey.InsertText(tk1);
	
	TextKit tk2; //font not set
	tk2.SetText("こんにちは");
	tk2.SetPosition(Point(0, 5, 0));
	segKey.InsertText(tk2);

}

:warning: Note: for this code sample to work, you need to make sure the CPP file is encoded in UTF-8 without BOM.

This code sample insert a japanese text and uses the default Yu Gothic font to display it.

On Windows, this is the list of default font available for the different characters sets: Font List Windows 10 - Typography

1 Like