5

I have a weird problem with the Windows Phone 8 emulator! I have a small test app where I change the 'page name' textbox on the mainpage so that it shows using a custom font. Now in the visual studio designer I see that font and when running the app I also see it in the emulator, so all is well...

But when I move the main page into a folder called View and change the WMAppManifest.xml to reflect this move > Navigation page is now set to View/MainPage.xaml. I'm still seeing this custom font in my designer, but not anymore in the emulator!!

I don't own a wp8 device yet... so can anyone verify this for me, if this problem is the same when you try to deploy the failure project to the phone?

And does anybody have any clue why this is happening? Very annoying not able to see the correct design in the emulator.

Working and failing projects

3 Answers 3

9

Ok found the solution myself... it's because of the reference to the font inside the styles.xaml.

It should be a full path! So instead of setting:

<Setter Property="FontFamily" Value="Fonts/ClementePDae-Light.ttf#ClementePDae" />

Set this:

<Setter Property="FontFamily" Value="/PhoneApp1;component/Fonts/ClementePDae-Light.ttf#ClementePDae" />

Than everything works!

3
  • i have tried this but still facing the same problem that i am able to see custom font in my designer but not in the emulator.
    – zap92
    Commented Mar 25, 2014 at 6:14
  • This is my code <Grid x:Name="ContentPanel" > <TextBlock Text="Lorem Ipsum" FontSize="20" TextWrapping="Wrap" Foreground="#fac258" FontFamily="/Casino;component/Fonts/impact.ttf#impact" Margin="81,194,81,-14" ></TextBlock> </Grid>
    – zap92
    Commented Mar 25, 2014 at 6:16
  • The name of the font has to be exact! Maybe something wrong with that?
    – Depechie
    Commented Mar 25, 2014 at 10:41
3

I hope you found the solution already. Please check out How to add Custom Fonts

This worked for me on Windows Phone 8 (Lumia 920)
It is very important to hashtag the font name after the .ttf
You can find the font name if you preview the ttf file on your PC and write the exact same font name.

0

First of all, you should save the external ttf into your project(If you want to use external font).

Then, you can use this:

FontFamily="Helvetica.ttf#Helvetica"

FontFamily="Cookies.ttf#Cookies"    

When the .ttf font file is in the root folder, works fine in Design and Runtime.

FontFamily="/FontsTestApp;component/Cookies.ttf#Cookies"    

Same as above.

FontFamily="/Font/Cookies.ttf#Cookies

When the .ttf font file is in the sub folder "font". Works fine in Design and Runtime.

FontFamily="../Fonts/Cookies.ttf#Cookies";

When the XAML file which uses the font resides in another subfolder. Works fine in Design and Runtime.

FontFamily="../Fonts/Cookies.ttf#Cookies";  

If the XAML file is in the root folder, the font gets applied only at runtime not at design time.

Not the answer you're looking for? Browse other questions tagged or ask your own question.