Sha256: 0b78a2fcd6d88bb6ea6e9c9dc5302b2b501704e41922e1bd62df7ba20fd4cccc

Contents?: true

Size: 942 Bytes

Versions: 4

Compression:

Stored size: 942 Bytes

Contents

require 'set'
require_relative 'base'

module TTFunk
  module Subset
    class Unicode < Base
      def initialize(original)
        super
        @subset = Set.new
      end

      def unicode?
        true
      end

      def to_unicode_map
        @subset.each_with_object({}) { |code, map| map[code] = code }
      end

      def use(character)
        @subset << character
      end

      def covers?(_character)
        true
      end

      def includes?(character)
        @subset.includes(character)
      end

      def from_unicode(character)
        character
      end

      protected

      def new_cmap_table(_options)
        mapping = @subset.each_with_object({}) do |code, map|
          map[code] = unicode_cmap[code]
        end
        TTFunk::Table::Cmap.encode(mapping, :unicode)
      end

      def original_glyph_ids
        ([0] + @subset.map { |code| unicode_cmap[code] }).uniq.sort
      end
    end
  end
end

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/subset/unicode.rb
embulk-input-druginfo_interview_form-0.1.0 vendor/bundle/ruby/2.5.0/gems/ttfunk-1.5.1/lib/ttfunk/subset/unicode.rb
ttfunk-1.5.1 lib/ttfunk/subset/unicode.rb
ttfunk-1.5.0 lib/ttfunk/subset/unicode.rb