How to load a specific font in a font collection

Q:

How do I use a font that is contained in a font collection (ttc file)? In particular, I want to load “MS PGothic” font on windows, which is in the msgothic.ttc file along with “MS Gothic”, “MS PGothic”, “MS UI Gothic”.

If I call Font::CreateCIDTrueTypeFont(pdfDoc,”…\msgothic.ttc”)) , then the “MS Gothic” font (the first/default) is picked.

A:

Use Font.Create"pdfDoc, “MS PGothic”) method. This will enumerate the fonts on the OS looking for the best match.

Note, you will need to use the CreateUnicodeTextRun method, and not the CreateTextRun method.