WPF - copy/paste selection with custom font family
- by summergoat
I have a custom font family embedded in my WPF application which I can reference by specifying a base URI and font family name.
new FontFamily(new Uri("pack://application:,,,/Fonts/"), "./#My Custom Font Family");
However, when I copy a selection which uses this font the xaml on the clipboard resembles the following
<Run Text="Foo" FontFamily="./#My Custom Font Family" />
When I paste into the same RichTextBox I lose the font as it falls back to the system default because -
When a FontFamily is specified as an attribute in markup, the base URI value is always implied—its value is the URI of the XAML page. http://msdn.microsoft.com/en-us/library/system.windows.media.fontfamily.aspx
and my xaml page is not located in the same directory as the custom font family.
Any ideas for a workaround?