In my previous post I went through how to use custom fonts in a Windows Phone 7 application using Visual Studio. In this part I’ll go through how to use Expression Blend for Windows Phone to leverage custom fonts.
Expression Blend is primarily used for designing your applications and offers a more intuitive interface to help design your Windows Phone 7 applications. I don’t use it to code and fall back to Visual Studio when code needs to be written. Unlike Visual Studio, it also renders any custom fonts you are using in the visual designer so you get a better representation of what your application will look like.
In Expression Blend, you can change the FontFamily property using the properties tab as follows
Here I changed ‘page name’ TextBlock and you will notice it will render in the visual designer nicely
But when deployed to the emulator the font will fallback to the Segoe WP default font
As you can see, the TextBlock that we added in the previous post is using the custom font but the ‘page name’ falls back to the regular font.
In the following steps, I’ll outline how to fix this building off the project from the previous post but instead we’ll use Expression Blend.
IN the following steps, I’ll go through making the custom font a resource so it can be leveraged in other controls within the Windows Phone 7 application. Making the font as a resource allows you to easily reference the font on other controls. So instead of copying FontFamily=".\Fonts\BuxtonSketch.ttf#Buxton Sketch" everywhere, you simply point it to your static resource.
<Application.Resources> <FontFamily x:Key="BuxtonSketchFont">.\Fonts\BuxtonSketch.ttf#Buxton Sketch</FontFamily> </Application.Resources>
There you have it, using custom fonts in Windows Phone 7 applications. Of course you don’t have to use custom fonts and can just use the default Segoe WP font. But you never know when a customer might say ‘hmmm…don’t like that font, what else you got?”
Questions, ping me via this blog or via twitter @MarkArteaga or just add a comment!
Powered by: newtelligence dasBlog 1.9.7174.0
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.
E-mail
Theme design by Jelle Druyts