Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to render unicode characters in the correct font? (C#/WinForms)

My application correctly handles different kind of character sets, but only internally - when it comes to displaying text in standard WinForms labels und textboxes, it seems to have problems with chinese characters.

The problem seems to be the font used (Tahoma), because when I copy&paste the text, or view it in the debugger, it is displayed correctly. Also when I set MS Mincho as the font to be used, the characters on the screen look OK.

Of course, I don't want to use MS Mincho in the entire application. Do I have to switch the font depending on the characters displayed, or is there a better way I have missed?

like image 542
Stefan Schultze Avatar asked Sep 19 '08 16:09

Stefan Schultze


People also ask

How do I change my Unicode font?

To set your font as the default for a given block of characters, choose Edit > Preferences > Fonts. Then for each encoding you are likely to use, pick the appropriate fonts for the Variable Width and Fixed Width fonts.

Does C support Unicode?

It can represent all 1,114,112 Unicode characters. Most C code that deals with strings on a byte-by-byte basis still works, since UTF-8 is fully compatible with 7-bit ASCII.

What is Unicode compliant font?

A Unicode font is a computer font that maps glyphs to code points defined in the Unicode Standard. The vast majority of modern computer fonts use Unicode mappings, even those fonts which only include glyphs for a single writing system, or even only support the basic Latin alphabet.

How do I text Unicode?

Unicode characters can then be entered by holding down Alt , and typing + on the numeric keypad, followed by the hexadecimal code – using the numeric keypad for digits from 0 to 9 and letter keys for A to F – and then releasing Alt .


1 Answers

UniScribe, which was introduced in Windows 2000, is supposed to handle this transparently, meaning that it will automatically use a different font (such as Mincho) for characters that aren't present in the font you've selected. This is why it looks correct in the debugger, even though the font used in the debugger doesn't contain Chinese characters. Perhaps you are doing something that disables UniScribe, or is problematic in some other way. Perhaps if you could paste some code it would be easier to identify the problem.

like image 74
bzlm Avatar answered Sep 30 '22 14:09

bzlm