Search code examples
c#.netwinformsunicodelabel

How can a Label control display Japanese characters properly when the Font used doesn't support this language?


I am working on a Windows Forms application, with .Net 4.5 as target framework.

One thing I have noticed that if I display text in Japanese language on Label control while Font of label (Arial) is not supporting Japanese characters, then too Label can successfully display those characters.

If I check font property of the label before and after assigning Japanese text to it, it shows me "Arial" only, so probably fonts are not dynamically changing.

What internal functionality Label have which enables it to achieve this?


Solution

  • About Font fallback
    System feature, tied to the International Font Management. It automates the selection of a Font other than the Font selected by the user in an application, to represent glyphs that the Font in use can't handle.
    See also: International Font Enumeration and Selection

    A selection of predefined Font substitutes can be found in the System Registry:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink
    

    An example and some notes, in relation to the RichTextBox/RichEdit Control, are reported here:
    Some keys change my RichTextBox font

    The RichTextBox Control is created with EM_SETLANGOPTIONS set to the IMF_AUTOFONT option.
    The predefined behavior, when the current Font cannot display an Unicode subset, it's an automatic Font fallback. The text selection reports the Font substitute reference.

    A Font substitute can be selected using the Unicode Subset Bitfields when the default mapping doesn't return a direct match.

    Any Font substitution is in relation with the current System language and the available installed fonts. The System installs a number of fonts to support this feature. The fallback fonts are usually marked as "Hidden" in the System Font repository (\Windows\Fonts in Windows). These can be marked as usable/enumerable, using the Show command in the toolbar button or contextual menu.
    (Arial Unicode is among these).

    See also:

    International Fonts and Text Display
    About Multilingual User Interface
    Using Font Fallback
    Uniscribe