Sha256: c4c18e1e42b67f98c83a95c7393f35dbe510e946ebfa6caad094c02c5a92ca94

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require_relative 'subset/unicode'
require_relative 'subset/unicode_8bit'
require_relative 'subset/mac_roman'
require_relative 'subset/windows_1252'

module TTFunk
  # Namespace for different types of subsets.
  module Subset
    # Create a subset for the font using the specified encoding.
    #
    # @param original [TTFunk::File]
    # @param encoding [:unicode, :unicode_8bit, :mac_roman, :windows_1252]
    # @raise [NotImplementedError] for unsupported encodings
    # @return [TTFunk::Subset::Unicode, TTFunk::Subset::Unicode8Bit,
    #   TTFunk::Subset::MacRoman, TTFunk::Subset::Windows1252]
    def self.for(original, encoding)
      case encoding.to_sym
      when :unicode then Unicode.new(original)
      when :unicode_8bit then Unicode8Bit.new(original)
      when :mac_roman then MacRoman.new(original)
      when :windows_1252 then Windows1252.new(original) # rubocop: disable Naming/VariableNumber
      else raise NotImplementedError, "encoding #{encoding} is not supported"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ttfunk-1.8.0 lib/ttfunk/subset.rb