Use a custom font in Win32 Desktop app using XAML islands in C++

  • Thread starter Thread starter NT_pro
  • Start date Start date
N

NT_pro

Guest
So I have my XAML islands set up with C++/WinRT in a Win32 Desktop app.

I want to use a custom font in a file named MyFont.ttf. I put MyFont.ttf in the same directory as the app's executable image. I then run the app and my font isn't used in a TextBlock I made.


TextBlock tb;
tb.FontFamily({L"MyFont.ttf"});
tb.Text("Sample");

desktopWindowXamlSource.Content(tb);

I have tried "MyFont.ttf", "/MyFont.ttf", and the full path to "MyFont.ttf", but it doesn't work and the word "Sample" is being shown in the default Segoe UI font. How can I make this work?


Thanks.

Continue reading...
 
Back
Top