peerlessDJ
Topic Author
Posts: 34
Joined: 28 Jan 2019, 06:37

Font Icon Problem

29 Feb 2020, 03:49

I have a Font Icon, and it displayed correctly in xaml
1.png
1.png (7.21 KiB) Viewed 1378 times
2.png
2.png (3.37 KiB) Viewed 1378 times

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

And i try to unicode string
[6.png]
[7.png]
 
peerlessDJ
Topic Author
Posts: 34
Joined: 28 Jan 2019, 06:37

Re: Font Icon Problem

29 Feb 2020, 03:55

[4.png]
4.png
4.png (3.15 KiB) Viewed 1374 times
[5.png]
5.png
5.png (8.61 KiB) Viewed 1374 times
[6.png]
6.png
6.png (2.63 KiB) Viewed 1374 times
 
peerlessDJ
Topic Author
Posts: 34
Joined: 28 Jan 2019, 06:37

Re: Font Icon Problem

29 Feb 2020, 03:55

[7.png]
7.png
7.png (3.22 KiB) Viewed 1374 times
 
User avatar
sfernandez
Site Admin
Posts: 2991
Joined: 22 Dec 2011, 19:20

Re: Font Icon Problem

02 Mar 2020, 18:56

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.
 
User avatar
jsantos
Site Admin
Posts: 3918
Joined: 20 Jan 2012, 17:18
Contact:

Re: Font Icon Problem

03 Mar 2020, 10:35

In C++ you must always use UTF8.

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 7 guests