PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 2:01 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Oct 13, 2009 2:22 pm 
Offline

Joined: Tue Oct 13, 2009 2:14 pm
Posts: 4
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 636 times
Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 14, 2009 12:53 pm 
Offline

Joined: Tue Oct 13, 2009 2:14 pm
Posts: 4
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));
.......
}


Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 14, 2009 1:03 pm 
Offline

Joined: Tue Oct 13, 2009 2:14 pm
Posts: 4
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.");
......
}


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 45 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group