Sha256: 59a66a5888a1ae507751266810ff82e4bf70b36d4c8baa417c35ac7d10c4758d

Contents?: true

Size: 951 Bytes

Versions: 4

Compression:

Stored size: 951 Bytes

Contents

module TTFunk
  class Table
    class Cmap < Table
      attr_reader :version
      attr_reader :tables

      def self.encode(charmap, encoding)
        result = Cmap::Subtable.encode(charmap, encoding)

        # pack 'version' and 'table-count'
        result[:table] = [0, 1, result.delete(:subtable)].pack('nnA*')
        result
      end

      def unicode
        # Because most callers just call .first on the result, put tables with
        # highest-number format first. Unsupported formats will be ignored.
        @unicode ||= @tables
                     .select { |table| table.unicode? && table.supported? }
                     .sort { |a, b| b.format <=> a.format }
      end

      private

      def parse!
        @version, table_count = read(4, 'nn')
        @tables = []

        table_count.times do
          @tables << Cmap::Subtable.new(file, offset)
        end
      end
    end
  end
end

require_relative 'cmap/subtable'

Version data entries

4 entries across 3 versions & 2 rubygems

Version Path
embulk-input-druginfo_interview_form-0.1.0 vendor/bundle/ruby/2.4.0/gems/ttfunk-1.5.1/lib/ttfunk/table/cmap.rb
embulk-input-druginfo_interview_form-0.1.0 vendor/bundle/ruby/2.5.0/gems/ttfunk-1.5.1/lib/ttfunk/table/cmap.rb
ttfunk-1.5.1 lib/ttfunk/table/cmap.rb
ttfunk-1.5.0 lib/ttfunk/table/cmap.rb