Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

An advice for parsing the PDF

skyspace
2012-01-10
2013-01-26
  • skyspace
    skyspace
    2012-01-10

    File: OpenFontParser.cs
    Function:private void LoadCMap( )
    Code:

    int offset = FontData.ReadInt();
            switch(platformID)
            {
              case PlatformID_Macintosh:
                switch(encodingID)
                {
                  case 0: // Symbolic font.
                    cmap10Offset = offset;
                    break;
                }
                break;
              case PlatformID_Microsoft:
                switch(encodingID)
                {
                  case 0: // Symbolic font.
                    break;
                  case 1: // Nonsymbolic font.
                    cmap31Offset = offset;
                    break;
                }
                break;
            }
          }

          /*
            NOTE: Symbolic fonts use specific (non-standard, i.e. neither Unicode nor
            platform-standard) font encodings.
          */
          if(cmap31Offset > 0) // Nonsymbolic.
          {
            Metrics.IsCustomEncoding = false;
            // Go to the beginning of the subtable!
            FontData.Seek(tableOffset + cmap31Offset);
          }
          else if(cmap10Offset > 0) // Symbolic.
          {
            Metrics.IsCustomEncoding = true;
            // Go to the beginning of the subtable!
            FontData.Seek(tableOffset + cmap10Offset);
          }
          else
            throw new ParseException("CMAP table unavailable.");

    Comment:  There is a logic bug for these code. Sometimes we will read the pdf file created from Apple iOS on windows and vice versa. So it is nice if you make more flexible correction for these code.

     
  • That code excerpt you deemed as "buggy" is based on § 5.5.5 of PDF Reference 1.7; if you don't submit any PDF file which demonstrates your assertion, your report is practically useless.

    So please open a bug tracker entry and accompany your report with proven arguments, thank you.
    Stefano