-1

How to add custom fonts in Visual Studio and show fonts in the properties menus?

Text FontFamily List picture

LSQ
  • 52
  • 9

1 Answers1

0
  1. Add the (external) font to the solution. You can add it as a resource too which is the best practice.
  2. Close the XAML and associated files.
  3. Reopen the file and go to properties and you will see the added font
  4. If not close the solution and do the above. You should see the font

If it doesn't work for any reason you can specify the relative path of the font as shown in the image:

enter image description here

Also, check How to include external font in WPF application without installing it for other best practices which include using Style

enter image description here

CinCout
  • 9,486
  • 12
  • 49
  • 67
  • Thank you for your reply. I added fonts as resources and can be used(). But I want to select the font to be added in the font option under Text in the picture. – LSQ Dec 20 '21 at 06:58
  • Display like `Segoe UI`.Is there a way to achieve it? – LSQ Dec 20 '21 at 06:59
  • Yes. Follow the steps mentioned above from 1 - 4. See the image with the text 'The font name from properties dialogue'. This is how I can see the attached font in my project. You just need to reload the XAML windows or if doesn't work the project. – Sheikh Ashiqul Islam Pollob Dec 20 '21 at 07:11
  • thanks. I use `FontFamily="./#Pacifico"` and the font is displayed. I chose this font for another TextBlock, the code shows `FontFamily="/;component/#Pacifico"`, the font is not applied correctly. Is the path of the file I added wrong? – LSQ Dec 20 '21 at 07:23
  • 1
    It does not seem to work in the designer, but it is displayed correctly at runtime – LSQ Dec 20 '21 at 07:31
  • The designer is very limited in what it will render to the developer and also it's just a simulation. From my experience, I had success in relying on the designer for alignment and to set/fix the structure of the control/widget. But to see how it is rendered for graphic-intensive controls/resources please rely on runtime. – Sheikh Ashiqul Islam Pollob Dec 20 '21 at 07:47
  • OK. thank you for your help. – LSQ Dec 20 '21 at 07:51