Visual Studio Available Fonts

Ken Krugh 116 Reputation points
2021-12-17T15:55:44.353+00:00

While trying to use a particular font in a WPF / VB app I found that when listing available fonts for selection in the properties of a control VS doesn't simply list the fonts that are loaded on the computer. For example, when setting the Text property of a list box:
158624-capture.jpg

Initially, the font I needed wasn't showing in the list, even though it was loaded and shows in most (probably all) other apps on the computer. Apparently this was because the font was loaded as a shortcut, because when I removed it and loaded it again, NOT as a shortcut, it showed.

I also noticed that VS is showing other fonts that are NOT even loaded on the computer, and therefore, not seen by any other apps on the computer. :-/

Does anyone know why the heck VS doesn't just read the fonts available on the computer and/or where/how VS gets the fonts it displays for selection in the properties menus?

Thank you,
Ken

Developer technologies | Windows Presentation Foundation
Developer technologies | VB
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Hui Liu-MSFT 48,681 Reputation points Microsoft External Staff
    2021-12-20T07:37:43.977+00:00

    You could try the following steps for adding fonts to the Text displayed under the properties.

    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.

    Project structure:
    158924-image.png
    The code:

      <StackPanel>  
            <TextBlock Text="hello" FontSize="28" Background="LightGreen"  Height="50" FontFamily="/;component/#Pacifico" />  
            <TextBlock Text="hello" FontSize="28" Background="LightGreen"  Height="50" FontFamily="/;component/#Pacifico" />  
            <TextBlock Text="hi" FontSize="20" FontFamily="/;component/#Jura" />  
        </StackPanel>  
    

    The result:
    158961-image.png
    Run-time result graph:
    158953-image.png


    If the response is helpful, please click "Accept Answer" and upvote it.
     Note: Please follow the steps in our [documentation][5] to enable e-mail notifications if you want to receive the related email notification for this thread. 

    [5]: https://learn.microsoft.com/en-us/answers/articles/67444/email-notifications.html

    0 comments No comments

  2. Ken Krugh 116 Reputation points
    2021-12-22T02:21:11.307+00:00

    I thought that was possible and figured we'd end up doing that, hadn't looked into it yet, though. Thanks very much for the great example, HuiLiu, saved me some searching.

    Would be interested for future reference as to why VS was showing fonts in the list that aren't loaded on the computer opening the project.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.