Using Custom Fonts in Silverlight
This is an extraction of Tim Heuer's video on silverlight.net. As he is pointed out in the video, regarding the licensing agreement of the custom fonts from different vendors, I will be using his custom made font for this demo code. Hope, Tim will not mind this :).
This demo code explains the custom font embedding in Silverlight application. There are around 10 fonts included in Silverlight by default. If we do not specify the font family, the default font will be Portable Interface Font (PIF).
Below is the screen shot of the initial screen
You must have noticed that the font I have used for the last element. This I tried intentionally. When Silverlight does not find any font, It will use the default Silverlight font for display. Thats the reason, the first element and the last element has the same fonts style. Seen the below screen shot for the explanation of another functionality.
Look at the font of the last element. I am setting two font familites to that element. First I am trying with a custom font and then with a delimitter I am adding font "Times New Roman". Since silverlight application does not find the first font, it is using the second for for the display.
In the above screen shot, there are two things to note. The font filename is "timheuer.ttf" and the font name is "Tim Heuer Normal". We need to used these two in a combined way in the application. Before that we need to set build action as of Resource type for the font. Once all the settings is done, the screen should look as below.
During the process the font is compiled into the assembly as a resource.
The running Demo :
Reference Articles
