Profile

Click to view full profile
Hi, I'm Veerapat Sriarunrungrueang, an expert in technology field, especially full stack web development and performance testing.This is my coding diary. I usually develop and keep code snippets or some tricks, and update to this diary when I have time. Nowadays, I've been giving counsel to many well-known firms in Thailand.
view more...

Wednesday, May 30, 2012

Embed Fonts in Windows Phone

To embed external fonts into Windows Phone, it is not difficult. First, you need to have fonts (*.ttf). Then, you add it into your Windows Phone project. Next, at your font properties, copy to output directory to copy if newer. Finally, in FontFamily property of your control. Refer to your font file followed by # then a font name, which contained in your font file.
// For example my font file name is RSU_Regular.ttf, and it is under fonts folder in my project.
// Refer to font name "RSU" which contained in RSU_Regular.ttf.
<UserControl ... FontFamily="fonts/RSU_Regular.ttf#RSU" ...> 
     ... 
</UserControl>
If you want to change control's font in C# file, you can do it by:
this.FontFamily = new FontFamily("fonts/RSU_Regular.ttf#RSU");

No comments:

Post a Comment