D'Arcy from Winnipeg
Solution Architecture, Business & Entrepreneurship, Microsoft, and Adoption

Embedding Fonts in a Silverlight App Using Blend

Sunday, December 14, 2008 10:04 AM


In a previous post I talked about how when you install the Silverlight runtime on the client it only installs with a subset of fonts, and if you want to use a font that isn’t part of the default package you have to add it to your project.

Now you can easily do this by adding the font file by going Add>Existing Item, but I stumbled on a built in Font Manager feature of Blend that makes this much easier.

Go to Tools and click Font Manager…

image

This brings up the font manager dialog, which gives you a font browser to select the fonts you want included in your application.

image

When you click OK, Blend will add a Fonts folder in your project and place all font files within it.

image

If you set the font for an element in Blend from the properties window, you’ll now see that your added font will show up in the list with a different icon, and when you hover over it with your mouse you’ll get a tool tip saying “Font added to project’.

image

Now by default it will set the build action for the font file to ‘BlendEmbeddedFont’. From a ‘running your application’ point of view, I didn’t see any difference between that and setting the build action to ‘Resource’ In fact, regardless of whether its an embedded font or a resource for the build action, you still need to include the path to the actual file within your XAML.

image

One final note on the font import tool: Some fonts that you select will enable the bottom section of the dialog…

image

This allows you to select only those parts that you require for your application (i.e. only lowercase, uppercase, numbers, etc.). Because keeping the size of the package as small as possible is a key facet to Silverlight development, this is a great feature to ensure that you only send down the parts of a font that you actually need. For example, if you had an Algerian calculator which will only need numbers and not letters, you can specify only numbers get sent to the client.

So some notes on another way to skin the font cat within Silverlight.

D




Feedback

# re: Embedding Fonts in a Silverlight App Using Blend

All this is good, but here is a problem I can foresee. When you deploy the application to the web, the font file also gets deployed in the XAP file to the client. (At least his was how it was in the beta.)

If you have a customer who wants to use proprietary fonts, they do not want it distributed out to the public. I know that Flash/Flex can import the font into the final SWF solution without distributing the font file; the previous version of Silverlight distributed the font. Do you know if the full release still distributes the font out? (I would assume so so it is an interpreter on the client alongside the browser version of the framework to make the silverlight app work, and it will need the font stored locally on the client machine.) 12/22/2008 5:42 PM | Kelly

# re: Embedding Fonts in a Silverlight App Using Blend

Pixel Fonts for Silverlight and WPF at CodePlex.com

http://pixelfonts.codeplex.com/ 8/27/2010 5:17 AM | Koistya `Navin

Post a comment