Silverlight gives the developer the possibility of completely customizing the developed application in all aspects. Defining fonts used for displaying text is no exception. However there are multiple ways on how to go ahead with specifying fonts to use, this article attempts to summarize the options.
In Silverlight, using fonts can be done in three ways:
- Built-in fonts
Silverlight can use a limited number of “built-in” fonts to display text such as Arial, Verdana, Times New Roman and a couple of more. The list is limited and it’s also worth noting that Silverlight can only use these fonts if they are installed on the client machine as the runtime does not ship with any fonts.
- Embedded custom fonts
Custom font files can be embedded in Silverlight applications and then shipped within the xap files. This option makes sure that the font will be rendered as wanted regardless of wether the font is installed on the client machine or not.
- Streamed (dynamically downloaded) custom fonts
The problem with embedding fonts in Silverlight is that it increases the xap size. If a font is only needed in certain cases the font file can be dynamically loaded from a remote location making the initial download time faster.
For details on how to implement the above use cases and some sample applications with source code check out my blog post on the Scott Logic website: Using built-in, embedded and streamed fonts in Silverlight.