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 = ...

Get Windows® Phone 8 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.