sam hocevar
sam hocevar

Reputation: 12129

Using a XAML font family breaks some Unicode glyphs

I am trying to display various Unicode characters in a XAML TextBlock without any particular attributes:

<TextBlock Text="{Binding MyString}" Foreground="Black" />

This works well for all scripts on my Windows 8.1 system, except for emoji characters:

Latin OK Emoji Broken Cyrillic OK

Since these symbols are available in the Segoe UI Symbol font, I simply added it to FontFamily:

<TextBlock Text="{Binding MyString}" Foreground="Black"
           FontFamily="Segoe UI Symbol" />

However, now some Cyrillic symbols are broken:

Latin OK Emoji OK Cyrillic Broken

So I tried to enable several fonts, including composite fonts listed on MSDN:

<TextBlock Text="{Binding MyString}" Foreground="Black"
           FontFamily="Lucida Sans Unicode, Lucida Grande, Segoe UI Symbol,
                       Open Sans, Arial, Microsoft Sans Serif, Tahoma,
                       Courier New, Times New Roman, Global User Interface,
                       Portable User Interface" />

But I get exactly the same result:

Latin OK Emoji OK Cyrillic Broken

How can I fix this? Isn’t Global User Interface supposed to give me a decent fallback for all characters? What could my TextBlock be using when I specify no FontFamily?

Upvotes: 4

Views: 999

Answers (1)

sam hocevar
sam hocevar

Reputation: 12129

I finally managed to fix it. It appears that:

  • Segoe UI is needed in addition to Segoe UI Symbol.
  • Segoe UI Symbol will mess up some characters and fonts that follow it will not be used; it should therefore be moved to the end.

The following string worked and all my glyphs now get rendered:

<TextBlock Text="{Binding MyString}" Foreground="Black"
           FontFamily="Segoe UI, Lucida Sans Unicode, Lucida Grande,
                       Open Sans, Arial, Microsoft Sans Serif, Tahoma,
                       Courier New, Times New Roman, Global User Interface,
                       Portable User Interface, Segoe UI Symbol" />

Upvotes: 1

Related Questions