How to set the font when font name is (e.g.) Chinese

This article talks about a font with a Chinese name (e.g. 长仿宋体). However, the content applies to other fonts where the name include non-ASCII characters.

HPS

The HPS API supports this directly. The SetFont method of a TextKit accepts a “UTF8-encoded font name”.

3DF

The 3DF API does not support setting the font using non-ASCII characters for the font name.

A font search (cf. Begin_Font_Search) is always your friend!

For example, here’s an approach for investigation;

  1. Capture font search results in a file
  2. Created a new directory containing the font file of interest and added this directory to the list of font directories known to HOOPS (cf. Define_System_Options font directory).
  3. Capture the results of a second font search
  4. Comparing the two font search results shows the name of the new font found:
name : LFangSong
name : LFSWM7.TTF`

Either of these names will work in “HC_Set_Text_Font("name = ...”.

The search results are the same whether the font is picked up as described above or installed on the (Windows) system. In this case, the font name is given in the Windows Explorer UI as 长仿宋体. However, this name will not work using HC_Set_Text_Font().