1

I am using a WPF UserControl inside a Winforms form. I have it working.

I would like the text that I use in the WPF UserControl to use a font that I have as a TTF.

I do not know how to reference this TTF and have the control use it. I am assuming I should load the TTF (this is not an installed font) in the UserControl and tell the control (a label) to use it but I only see reference to the font-family.

amiry jd
  • 27,021
  • 30
  • 116
  • 215
Jeff
  • 2,061
  • 4
  • 27
  • 45

2 Answers2

1

Here is how to load a font in wpf from a TTF font file

<TextBlock FontSize="48" FontFamily="/Assets/Fonts/Algeria.TTF#Algeria"  FontWeight="Normal">test value</TextBlock>                       

Use a Resource to store the font...

enter image description here

Stuart Smith
  • 1,931
  • 15
  • 26
  • This is the line of code I am using It does not work. The file is in the same folder as the bin/debug – Jeff Oct 10 '14 at 15:34
  • Still no – Jeff Oct 10 '14 at 20:24
  • Is your User Control in the same assembly as your main application? Man that is one small font. – Stuart Smith Oct 10 '14 at 23:09
  • It is in the same assemble, – Jeff Oct 11 '14 at 14:44
  • Just went to git hub and downloaded the following font https://github.com/mozilla/Fira/blob/master/ttf/FiraSans-Medium.ttf I am not sure if this is the font you are using but the font name on this font is fira Sans Medium so the Xaml would look like .... – Stuart Smith Oct 11 '14 at 15:36
0

Make sure the font name is correct ....

from git hub I found the following font github.com/mozilla/Fira/blob/master/ttf/FiraSans-Medium.ttf. For this font the font would be fira Sans Medium so the Xaml would look like

   <Label FontFamily="/Resources/firaSans-Medium.ttf#fira Sans Medium" x:Name="TopText" Content="Memory Disk Registry System Program" FontSize="3" Margin="0,-2,0,0"/> 
Stuart Smith
  • 1,931
  • 15
  • 26