Class: TTFunk::Subset::Unicode
- Defined in:
- lib/ttfunk/subset/unicode.rb
Overview
Unicode-based subset.
Constant Summary collapse
- SPACE_CHAR =
Space character code
0x20
Constants inherited from Base
Base::MICROSOFT_PLATFORM_ID, Base::MS_SYMBOL_ENCODING_ID
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#covers?(_character) ⇒ true
Can this subset include the character?.
-
#from_unicode(character) ⇒ Integer
Get character code for Unicode codepoint.
-
#includes?(character) ⇒ Boolean
Does this subset actually has the character?.
-
#initialize(original) ⇒ Unicode
constructor
A new instance of Unicode.
-
#new_cmap_table ⇒ TTFunk::Table::Cmap
Get
cmap
table for this subset. -
#original_glyph_ids ⇒ Array<Integer>
Get the list of Glyph IDs from the original font that are in this subset.
-
#to_unicode_map ⇒ Hash{Integer => Integer}
Get a mapping from this subset to Unicode.
-
#unicode? ⇒ true
Is this a Unicode-based subset?.
-
#use(character) ⇒ void
Add a character to subset.
Methods inherited from Base
#collect_glyphs, #encode, #encoder_klass, #glyphs, #microsoft_symbol?, #new_to_old_glyph, #old_to_new_glyph, #unicode_cmap
Constructor Details
#initialize(original) ⇒ Unicode
Returns a new instance of Unicode.
Source Code
14 | def initialize(original) |
15 | super
|
16 | @subset = Set.new |
17 | use(SPACE_CHAR) |
18 | end
|
Instance Method Details
#covers?(_character) ⇒ true
Can this subset include the character?
Source Code
46 | def covers?(_character) |
47 | true
|
48 | end
|
#from_unicode(character) ⇒ Integer
Get character code for Unicode codepoint.
Source Code
62 | def from_unicode(character) |
63 | character
|
64 | end
|
#includes?(character) ⇒ Boolean
Does this subset actually has the character?
Source Code
54 | def includes?(character) |
55 | @subset.include?(character) |
56 | end
|
#new_cmap_table ⇒ TTFunk::Table::Cmap
Get cmap
table for this subset.
Source Code
69 | def new_cmap_table |
70 | @new_cmap_table ||= |
71 | begin
|
72 | mapping = |
73 | @subset.each_with_object({}) do |code, map| |
74 | map[code] = unicode_cmap[code] |
75 | end
|
76 | |
77 | TTFunk::Table::Cmap.encode(mapping, :unicode) |
78 | end
|
79 | end
|
#original_glyph_ids ⇒ Array<Integer>
Get the list of Glyph IDs from the original font that are in this subset.
Source Code
85 | def original_glyph_ids |
86 | ([0] + @subset.map { |code| unicode_cmap[code] }).uniq.sort |
87 | end
|
#to_unicode_map ⇒ Hash{Integer => Integer}
Get a mapping from this subset to Unicode.
Source Code
30 | def to_unicode_map |
31 | @subset.each_with_object({}) { |code, map| map[code] = code } |
32 | end
|
#unicode? ⇒ true
Is this a Unicode-based subset?
Source Code
23 | def unicode? |
24 | true
|
25 | end
|
#use(character) ⇒ void
This method returns an undefined value.
Add a character to subset.
Source Code
38 | def use(character) |
39 | @subset << character |
40 | end
|