/// <summary>
    /// Gets the resource name of the specified font within this page or form.
    /// </summary>
    internal string GetFontName(Font font)
    {
      PdfFont pdfFont;
      string name = null;
      if (this.page != null)
        name = this.page.GetFontName(font.Name, font.FontData, out pdfFont);
      else if (this.form != null)
        name = this.form.GetFontName(font.Name, font.FontData, out pdfFont);
      else if (this.contentDictionary != null)
      {
        Debug.Assert(this.contentStreamDictionary != null);
        name = this.contentStreamDictionary.GetFontName(font.Name, font.FontData, out pdfFont);
      }
      else
      {
        Debug.Assert(false, "Undefined conent target.");
        pdfFont = null;  // supress compiler warning
      }

      Debug.Assert(font.PdfFont == null || Object.ReferenceEquals(font.PdfFont, pdfFont));
      if (font.PdfFont == null)
        font.PdfFont = pdfFont;
      return name;
    }
Beispiel #2
0
      public Font GetFont(string uriString)
      {
        string baseName = IOPath.GetFileNameWithoutExtension(uriString);
        Font font;
        if (this.fonts.TryGetValue(baseName, out font))
          return font;

        byte[] fontData = this.payload.GetFontData(uriString);

        // Create helper name if font data does not contain a name table.
        string name = String.Format("XPS-Font-{0:00}", ++fontCount);
        name = PdfFont.CreateEmbeddedFontSubsetName(name);
        font = new Font(name, fontData);
        this.fonts.Add(baseName, font);
        return font;
      }