PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

Support for Symbol Fonts broken.
http://forum.pdfsharp.com/viewtopic.php?f=3&t=909
Page 1 of 1

Author:  BlueSky [ Tue Oct 13, 2009 2:22 pm ]
Post subject:  Support for Symbol Fonts broken.

I use PDFSharp to convert xps documents to pdf.
Yesterday I updated to Version 1.30 and now Symbol fonts are not working anymore.
A quick help would be highly appreciated.

Attached is a sample XPS and an output PDF.

Attachments:
Test_Docs.zip [81.1 KiB]
Downloaded 678 times

Author:  BlueSky [ Wed Oct 14, 2009 12:53 pm ]
Post subject:  Re: Support for Symbol Fonts broken.

Found the Bug:
Code:
PdfSharp.Xps\PdfSharp.Xps.Rendering\PdfContentWriter-Glyphs.cs
private void WriteGlyphs_ClusterMapping(Glyphs glyphs)
{
.......
          // get index of current glyph
          if (mapping.HasGlyphIndex)
              glyphIndex = mapping.GlyphIndex;
          else
          {
             
             // original:  glyphIndex = descriptor.CharCodeToGlyphIndex(unicodeString[codeIdx]);

              // new: Included index shifting for symbol fonts from other code parts (seems to have been forgotten here)
              if (realizedFont.IsSymbolFont)
              {
                  int idx = (int)(unicodeString[codeIdx]);
                  glyphIndex = idx + (descriptor.fontData.os2.usFirstCharIndex & 0xFF00);
                  glyphIndex = descriptor.CharCodeToGlyphIndex((char)glyphIndex);
              }
              else
              {
                  glyphIndex = descriptor.CharCodeToGlyphIndex(unicodeString[codeIdx]);
              }
          }

          // add glyph index to the fonts 'used glyph table'
          realizedFont.AddGlyphIndices(new string((char)glyphIndex, 1));
.......
}

Author:  BlueSky [ Wed Oct 14, 2009 1:03 pm ]
Post subject:  Re: Support for Symbol Fonts broken.

Another one:

Happens with truetype Barcode fonts.

PdfSharp\PdfSharp.Fonts.OpenType\OpenTypeDescriptor.cs
Code:
void Initialize()
{
......
      if (fontData.os2.sTypoDescender != 0)
      {
        this.descender = fontData.os2.usWinDescent;
        Debug.Assert(this.descender > 0, "PDFsharp internal: Font with non positive ascender value found.");
        // Force sign from hhea.descender
        // TODO:
        this.descender = Math.Abs(this.descender) * Math.Sign(fontData.hhea.descender);
      }
      else
        this.descender = fontData.hhea.descender;

      // original: Debug.Assert(this.descender < 0, "PDFsharp internal: Ascender should be less than 0.");
      // new: In some fonts (i.e. Barcode fonts) descender may be 0
      Debug.Assert(this.descender <= 0, "PDFsharp internal: Descender should be less than 1.");
......
}

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/