Exemplo n.º 1
0
        internal void Read()
        {
            try
            {
                int tableOffset = this.fontData.Position;

                this.version   = this.fontData.ReadUShort();
                this.numTables = this.fontData.ReadUShort();

                bool success = false;
                for (int idx = 0; idx < this.numTables; idx++)
                {
                    PlatformId    platformId = (PlatformId)this.fontData.ReadUShort();
                    WinEncodingId encodingId = (WinEncodingId)this.fontData.ReadUShort();
                    int           offset     = this.fontData.ReadLong();

                    int currentPosition = this.fontData.Position;

                    // Just read Windows stuff
                    if (platformId == PlatformId.Win && (encodingId == WinEncodingId.Symbol || encodingId == WinEncodingId.Unicode))
                    {
                        this.symbol = encodingId == WinEncodingId.Symbol;

                        this.fontData.Position = tableOffset + offset;
                        this.cmap4             = new CMap4(this.fontData, encodingId);
                        this.fontData.Position = currentPosition;
                        // We have found what we are looking for, so break.
                        success = true;
                        break;
                    }
                }
                if (!success)
                {
                    throw new InvalidOperationException("Font has no usable platform or encoding ID. It cannot be used with PDFsharp.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    internal void Read()
    {
      try
      {
        int tableOffset = this.fontImage.Position;

        this.version = this.fontImage.ReadUShort();
        this.numTables = this.fontImage.ReadUShort();

        bool success = false;
        for (int idx = 0; idx < this.numTables; idx++)
        {
          PlatformId platformId = (PlatformId)this.fontImage.ReadUShort();
          WinEncodingId encodingId = (WinEncodingId)this.fontImage.ReadUShort();
          int offset = this.fontImage.ReadLong();

          int currentPosition = this.fontImage.Position;

          // Just read Windows stuff
          if (platformId == PlatformId.Win && (encodingId == WinEncodingId.Symbol || encodingId == WinEncodingId.Unicode))
          {
            this.symbol = encodingId == WinEncodingId.Symbol;

            this.fontImage.Position = tableOffset + offset;
            this.cmap4 = new CMap4(this.fontImage, encodingId);
            this.fontImage.Position = currentPosition;
            // We have found what we are looking for, so break.
            success = true;
            break;
          }
        }
        if (!success)
          throw new InvalidOperationException("Font has no usable platform or encoding ID. It cannot be used with PDFsharp.");
      }
      catch (Exception ex)
      {
        throw ex;
      }
    }