class TTFunk::Subset::Unicode
Unicode-based subset.
Constants
- SPACE_CHAR
Space character code
Public Class Methods
new(original)
click to toggle source
@param original [TTFunk::File]
Calls superclass method
TTFunk::Subset::Base::new
# File lib/ttfunk/subset/unicode.rb, line 14 def initialize(original) super @subset = Set.new use(SPACE_CHAR) end
Public Instance Methods
covers?(_character)
click to toggle source
Can this subset include the character?
@param _character [Integer] Unicode
codepoint @return [true]
# File lib/ttfunk/subset/unicode.rb, line 46 def covers?(_character) true end
from_unicode(character)
click to toggle source
includes?(character)
click to toggle source
Does this subset actually has the character?
@param character [Integer] Unicode
codepoint @return [Boolean]
# File lib/ttfunk/subset/unicode.rb, line 54 def includes?(character) @subset.include?(character) end
new_cmap_table()
click to toggle source
Get ‘cmap` table for this subset.
@return [TTFunk::Table::Cmap]
# File lib/ttfunk/subset/unicode.rb, line 69 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
Get the list of Glyph IDs from the original font that are in this subset.
@return [Array<Integer>]
# File lib/ttfunk/subset/unicode.rb, line 85 def original_glyph_ids ([0] + @subset.map { |code| unicode_cmap[code] }).uniq.sort end
to_unicode_map()
click to toggle source
Get a mapping from this subset to Unicode
.
@return [Hash{Integer => Integer}]
# File lib/ttfunk/subset/unicode.rb, line 30 def to_unicode_map @subset.each_with_object({}) { |code, map| map[code] = code } end
unicode?()
click to toggle source
Is this a Unicode-based subset?
@return [true]
# File lib/ttfunk/subset/unicode.rb, line 23 def unicode? true end
use(character)
click to toggle source
Add a character to subset.
@param character [Integer] Unicode
codepoint @return [void]
# File lib/ttfunk/subset/unicode.rb, line 38 def use(character) @subset << character end