Page 1 of 1

Font Icon Problem

Posted: 29 Feb 2020, 03:49
by peerlessDJ
I have a Font Icon, and it displayed correctly in xaml
1.png
1.png (7.21 KiB) Viewed 2125 times
2.png
2.png (3.37 KiB) Viewed 2125 times

When it bind a variable in CPP, it displayed error in xaml
3.png
3.png (7.94 KiB) Viewed 2124 times
[4.png]
[5.png]

And i try to unicode string
[6.png]
[7.png]

Re: Font Icon Problem

Posted: 29 Feb 2020, 03:55
by peerlessDJ
[4.png]
4.png
4.png (3.15 KiB) Viewed 2121 times
[5.png]
5.png
5.png (8.61 KiB) Viewed 2121 times
[6.png]
6.png
6.png (2.63 KiB) Viewed 2121 times

Re: Font Icon Problem

Posted: 29 Feb 2020, 03:55
by peerlessDJ
[7.png]
7.png
7.png (3.22 KiB) Viewed 2121 times

Re: Font Icon Problem

Posted: 02 Mar 2020, 18:56
by sfernandez
In code you should escape the unicode characters using '\u' + the hexadecimal value of the character.

For example, I could write the following xaml:
<Grid x:Class="Testing.UnicodeTest"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
        <TextBlock Text="&#xf027;" FontFamily="Fonts/#Font Awesome 5 Free" FontSize="40" FontWeight="Bold"/>
        <TextBlock Text="{Binding Unicode}" FontFamily="Fonts/#Font Awesome 5 Free" FontSize="40" FontWeight="Bold"/>
    </StackPanel>
</Grid>
And in code expose a Unicode property in the ViewModel initilized as:
_unicode = "\xEF\x80\xA7"; // UTF-8 representation of \uF027
That will render the volume-down for both texts.

From the images you attached it seems that it is not finding the glyph in the supplied font, and is using our internal fallback font that renders the ? for not found glyphs.

Re: Font Icon Problem

Posted: 03 Mar 2020, 10:35
by jsantos
In C++ you must always use UTF8.