title: PDFsharp add private/installed font
body: <p>I want to apply Trade gothic font to my pdf text using PDFsharp, I have installed the font and use below line of code to apply </p>
  
  <pre><code>XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);
  // var options = new XPdfFontOptions(PdfFontEmbedding.Always);
  XFont font = new XFont("TRADE GOTHIC BOLD CONDENSED NO. 20", 20, XFontStyle.Bold, options);
  </code></pre>
  
  <p>But it does not work!!.
  Also I wanted to know in production I'm using Windows server 2008, is there a way I can dynamically add this font in production server even it is not there?</p>
  
  <p>As suggested I followed the pdfsharp forum ,
   this is my sample code</p>
  
  <pre><code>XPrivateFontCollection privateFontCollection = XPrivateFontCollection.Global;
   // Uri fontUri = new Uri(MappedApplicationPath + "Fonts\\trade-gothic-no-20-condensed-bold-1361518746.ttf");
   Uri fontUri = new Uri("C:\\inetpub\\wwwroot\\wss\\VirtualDirectories\\80\\Fonts\\trade-gothic-no-20-condensed-bold-1361518746.ttf");
  
  LoadPrivateFont(privateFontCollection, fontUri, "./#TradeGothicNo.20-Condensed"); 
  </code></pre>
  
  <p>I tried all possible combination of path and file name , the name as mentioned in .ttf file but still getting exception . I have a sharepoint Visual webpart, and  on page load event of that webpart m writing this code..</p>
  
  <p>This is load method</p>
  
  <pre><code>protected void LoadPrivateFont(PdfSharp.Drawing.XPrivateFontCollection privateFontCollection, Uri fontUri, string sFontFamilyname)
          {
  
              try
              {
                  privateFontCollection.Add(fontUri, sFontFamilyname);
              }
              catch
              {
              }
          }
  </code></pre>
  
  <p>I have followed this post
  <a href="http://forum.pdfsharp.net/viewtopic.php?f=2&amp;t=1880" rel="nofollow">http://forum.pdfsharp.net/viewtopic.php?f=2&amp;t=1880</a></p>
  
  <p>Thanks</p>