Embedded Fonts

Topics: Prism v2 - Silverlight 2
Jun 14, 2009 at 4:15 PM

I can't seem to load embedded fonts into the shell using the following notation:

<TextBlock x:Name="Header" FontFamily="timheuer.ttf#Tim Heuer Normal" />

I have been able to do this in other silverlight apps, but not when using Prism.  Can you tell me how to do this?

Jul 1, 2009 at 2:46 PM

Ozzy1: Were you able to resolve this? I'm running into the same issue and the Composite docs simply refer to the general "Using Fonts in Silverlight" articles which clearly don't account for Composite differences.


Jul 3, 2009 at 10:49 AM
Edited Jul 3, 2009 at 10:52 AM

Sort of. I ended up loading the font in the ShellView, which works but isn't really satisfactory because when the app starts the default font is shown briefly before the custom font is loaded. There is probably a way to preload the font, but I haven't yet tried to improve on this.

        void LoadCustomFont()
            WebClient client = new WebClient();
            client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
            client.OpenReadAsync(new Uri("/Fonts/MINYN___.TTF", UriKind.RelativeOrAbsolute));

        void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
            if (e.Error == null && !e.Cancelledl)
                FontSource fontSource = new FontSource(e.Result);
                AppHeaderTitle.FontSource = fontSource;
                AppHeaderTitle.FontFamily = new FontFamily("Minya Nouvelle");