0

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?

Nikos C.
  • 50,738
  • 9
  • 71
  • 96
  • https://stackoverflow.com/questions/7043904/microsoft-sans-serif-font-not-used-in-chinese-localized-windows – Dmitry Bychenko Jun 23 '20 at 16:23
  • [How can Label control display Japanese characters properly when font of the label doesn't support Japanese characters?](https://stackoverflow.com/a/51612395/7444103) -- [Some Alt keys changes my RichTextBox font](https://stackoverflow.com/a/51451303/7444103) – Jimi Jun 23 '20 at 16:35

0 Answers0