O'Reilly logo

Windows® Phone 8 Unleashed by Daniel Vaughan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Leveraging FontSource to Assign a Font Using a Stream

While font embedding is restricted to fonts located within your app’s XAP file, the FontSource property of the TextBlock, TextBox, and PasswordBox allows you to download the font using an external data source, such as a cloud service.

The FontSource class requires a Stream of font data. The following example takes the same embedded font used in the previous example and provides it to a TextBlock object’s FontSource property via a Stream, using the Application.GetResourceStream method as shown:

Uri fontUri = new Uri("ControlExamples/Fonts/orbitron-medium.ttf",                                                    UriKind.Relative);StreamResourceInfo resourceInfo = ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required