Sha256: 492625f3932e477afa7d046f3c213ac088f0358f723c7b5261180b5f76318e06

Contents?: true

Size: 1.05 KB

Versions: 14

Compression:

Stored size: 1.05 KB

Contents

require 'set'
require 'ttfunk/subset/base'
require 'ttfunk/encoding/mac_roman'

module TTFunk
  module Subset
    class MacRoman < Base
      def initialize(original)
        super
        @subset = Array.new(256)
      end

      def use(character)
        @subset[Encoding::MacRoman::FROM_UNICODE[character]] = character
      end

      def covers?(character)
        Encoding::MacRoman.covers?(character)
      end

      def includes?(character)
        code = Encoding::MacRoman::FROM_UNICODE[character]
        code && @subset[code]
      end

      def from_unicode(character)
        Encoding::MacRoman::FROM_UNICODE[character]
      end

      protected

        def new_cmap_table(options)
          mapping = {}
          @subset.each_with_index do |unicode, roman|
            mapping[roman] = unicode_cmap[unicode] if roman
          end

          TTFunk::Table::Cmap.encode(mapping, :mac_roman)
        end

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

Version data entries

14 entries across 14 versions & 4 rubygems

Version Path
prawn-core-0.8.4 vendor/ttfunk/lib/ttfunk/subset/mac_roman.rb
prawn-graph-0.0.2 vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset/mac_roman.rb
prawn-graph-0.0.1 vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset/mac_roman.rb
prawn-core-0.7.2 vendor/ttfunk/lib/ttfunk/subset/mac_roman.rb
prawn-core-0.7.1 vendor/ttfunk/lib/ttfunk/subset/mac_roman.rb
prawn-layout-0.3.2 vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset/mac_roman.rb
prawn-core-0.6.3 vendor/ttfunk/lib/ttfunk/subset/mac_roman.rb
prawn-core-0.6.2 vendor/ttfunk/lib/ttfunk/subset/mac_roman.rb
prawn-layout-0.3.1 vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset/mac_roman.rb
prawn-core-0.6.1 vendor/ttfunk/lib/ttfunk/subset/mac_roman.rb
prawn-core-0.5.1 vendor/ttfunk/lib/ttfunk/subset/mac_roman.rb
prawn-core-0.5.0.1 vendor/ttfunk/lib/ttfunk/subset/mac_roman.rb
prawn-0.4.0 vendor/ttfunk/lib/ttfunk/subset/mac_roman.rb
prawn-0.4.1 vendor/ttfunk/lib/ttfunk/subset/mac_roman.rb