Private fonts work only with the WPF build of PDFsharp 1.31.
We only have code that loads the fonts from resources - that's what the sample does, that's what we need and we know it works.
You are trying to load a true type font file from HTTP. We never tried that and I don't have time to try it this week.
So you can load the fonts from resources like the sample does - or continue your approach with the TTF via HTTP, but I cannot help with that.
The task is adding a font to System.Windows.Media.FontFamily - this has nothing to do with PDFsharp, this is a .NET task. Maybe you can find suitable samples on the web.
We embed fonts in resources. If you can use the same approach, then you can rely on the sample provided.
Syntax will be slightly different if fonts are in a different assembly (not the main EXE):
Code:
if (privateFontCollection == null)
{
privateFontCollection = new PdfSharp.Drawing.XPrivateFontCollection();
Uri uri = new Uri("pack://application:,,,/");
privateFontCollection.Add(uri, "Qbx.Reha.Customization.SampleAssembly;component/FrutigerFonts/#FrutigerLight");
privateFontCollection.Add(uri, "Qbx.Reha.Customization.SampleAssembly;component/FrutigerFonts/#Frutiger");
}
Before ";component" you specify the name of the assembly, after ";component" you specify the location of the font inside the assembly. You don't specify the name(s) of the TTF files anywhere (fonts families normally consist of more than 1 TTF file).
Maybe that's why HTTP doesn't work: with "pack:" protocol you don't specify filenames, the system searches appropriate files; searching probably doesn't work with HTTP.