When displaying text in a Windows Form (like a TextBox
for example) I can enter Chinese characters in it if I want, and they will get displayed correctly. However, the font used by the Form is not actually capable of rendering Chinese. As a result, if I try to use the Form's font in order to create a PDF file containing the text, it won't work:
myPdf.RenderText(myForm.Font, myForm.Text);
In this case in Windows 10, myForm.Font
is just Microsoft Sans Serif
(or Arial
in older Windows versions,) which does not support Chinese (or CJK in general) and as a result the PDF won't render correctly when embedding the Arial font in it.
So, how do I find out which font is really used to render text in a Windows Form? It can't be what the Font
property says it is. In this particular case, it's probably "SimSun" or some other system font that supports Chinese characters, but there doesn't seem to be any way whatsoever to find out.
How do I deal with this? If it's not possible to get the true font of a Form, then could I somehow detect what font (or combination of fonts) Windows would use to render a piece of text on a Form before actually displaying the text on that Form?