Sha256: b8f13b6a3079b244ee345a3b0288c893b235b1885addf5242281719bca6a7b2c

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

module TTFunk
  class Table
    class Dsig < Table
      class SignatureRecord
        attr_reader :format, :length, :offset, :signature

        def initialize(format, length, offset, signature)
          @format = format
          @length = length
          @offset = offset
          @signature = signature
        end
      end

      attr_reader :version, :flags, :signatures

      TAG = 'DSIG'

      def self.encode(dsig)
        return nil unless dsig

        # Don't attempt to re-sign or anything - just use dummy values.
        # Since we're subsetting that should be permissible.
        [dsig.version, 0, 0].pack('Nnn')
      end

      def tag
        TAG
      end

      private

      def parse!
        @version, num_signatures, @flags = read(8, 'Nnn')

        @signatures = Array.new(num_signatures) do
          format, length, sig_offset = read(12, 'N3')
          signature = parse_from(offset + sig_offset) do
            _, _, sig_length = read(8, 'nnN')
            read(sig_length, 'C*')
          end

          SignatureRecord.new(format, length, sig_offset, signature)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ttfunk-1.6.2.1 lib/ttfunk/table/dsig.rb
ttfunk-1.6.2 lib/ttfunk/table/dsig.rb
ttfunk-1.6.1 lib/ttfunk/table/dsig.rb
ttfunk-1.6.0 lib/ttfunk/table/dsig.rb