While working on a Windows Phone 7 project, I got a customer request to use a custom font instead of just the Segoe WP font that is included with Windows Phone 7.
I have done this before on Windows Mobile so I’ll re-cap how to do it pre Windows Phone 7.
We have automated this process through a custom a setup DLL (which is native code) with an installer and alleviates the pain for the customer to do this manual process. But still somewhat of a pain to automate this process.
Using Silverlight for Windows Phone 7, this process is simplified and considering as a third party developer you don’t have access to the file system or the ability to write native code this is a good thing.
Here is a quick tutorial on getting this working with Visual Studio Express for Windows Phone 7. In this tutorial I’ll be using the standard Windows Phone 7 project that comes with Visual Studio.
Adding Custom Font With Visual Studio
The first thing you need to do is create a Fonts folder in your project as follows
Now that we have the font in our project we need to use the font with the application.
<Grid x:Name="ContentGrid" Grid.Row="1"> <TextBlock FontSize="48" HorizontalAlignment="Left" Margin="36,225,0,0" Name="textBlock1" Text="Sample Text Font" VerticalAlignment="Top" /></Grid>
<
<Grid x:Name="ContentGrid" Grid.Row="1"> <TextBlock FontFamily=".\Fonts\BuxtonSketch.ttf#Buxton Sketch"FontSize="48" HorizontalAlignment="Left" Margin="36,225,0,0" Name="textBlock1" Text="Sample Text Font" VerticalAlignment="Top" /></Grid>
You should be able to embed any True Type Font within your Windows Phone 7 application. In the next post I’ll follow up on how to use custom fonts with Expression Blend.
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