class TTFunk::Subset::Unicode

Constants

SPACE_CHAR

Public Class Methods

new(original) click to toggle source
Calls superclass method TTFunk::Subset::Base.new
# File lib/ttfunk/subset/unicode.rb, line 10
def initialize(original)
  super
  @subset = Set.new
  use(SPACE_CHAR)
end

Public Instance Methods

covers?(_character) click to toggle source
# File lib/ttfunk/subset/unicode.rb, line 28
def covers?(_character)
  true
end
from_unicode(character) click to toggle source
# File lib/ttfunk/subset/unicode.rb, line 36
def from_unicode(character)
  character
end
includes?(character) click to toggle source
# File lib/ttfunk/subset/unicode.rb, line 32
def includes?(character)
  @subset.include?(character)
end
new_cmap_table() click to toggle source
# File lib/ttfunk/subset/unicode.rb, line 40
def new_cmap_table
  @new_cmap_table ||=
    begin
      mapping =
        @subset.each_with_object({}) do |code, map|
          map[code] = unicode_cmap[code]
        end

      TTFunk::Table::Cmap.encode(mapping, :unicode)
    end
end
original_glyph_ids() click to toggle source
# File lib/ttfunk/subset/unicode.rb, line 52
def original_glyph_ids
  ([0] + @subset.map { |code| unicode_cmap[code] }).uniq.sort
end
to_unicode_map() click to toggle source
# File lib/ttfunk/subset/unicode.rb, line 20
def to_unicode_map
  @subset.each_with_object({}) { |code, map| map[code] = code }
end
unicode?() click to toggle source
# File lib/ttfunk/subset/unicode.rb, line 16
def unicode?
  true
end
use(character) click to toggle source
# File lib/ttfunk/subset/unicode.rb, line 24
def use(character)
  @subset << character
end