title: WPF - Load Font from Stream?
body: <p>I have a MemoryStream with the contents of a Font File (.ttf) and I would like to be able to create a FontFamily WPF object from that stream <strong>WITHOUT</strong> writing the contents of the stream to disk. I know this is possible with a System.Drawing.FontFamily but I cannot find out how to do it with System.Windows.Media.FontFamily.</p>
  <p>Note: I will only have the stream, so I can't pack it as a resource in the application and because of disk permissions issues, will not be able to write the font file to disk for reference as &quot;content&quot;</p>
  <p><strong>UPDATE:</strong></p>
  <p>The <a href="https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.fontfamily?view=netframework-4.6.1" rel="nofollow noreferrer">API docs</a> how describe how an application resource can be used, though it is not clear to me whether that is an Embedded resource in the assembly or a file on disk.</p>
  <blockquote>
  <p>You can use a base URI value when you reference a font that is packaged as part of the application. For example, the base URI value can be a &quot;pack://application&quot; URI, which lets you reference fonts that are packaged as application resources. The following code example shows a font reference that is composed of a base URI value and a relative URI value.</p>
  </blockquote>