Permalink
Browse files

Expose the mapping from subset code to unicode

This lets us more easily build ToUnicode cmaps in PDF's
  • Loading branch information...
1 parent 62c766b commit fe7d7e53d76ade78f754bb0e8a0a1511158032b7 @jamis jamis committed Jan 2, 2009
Showing with 24 additions and 0 deletions.
  1. +8 −0 lib/ttfunk/subset/base.rb
  2. +8 −0 lib/ttfunk/subset/unicode.rb
  3. +8 −0 lib/ttfunk/subset/unicode_8bit.rb
@@ -18,6 +18,14 @@ def initialize(original)
@original = original
end
+ def unicode?
+ false
+ end
+
+ def to_unicode_map
+ {}
+ end
+
def encode(options={})
cmap_table = new_cmap_table(options)
glyphs = collect_glyphs(original_glyph_ids)
@@ -9,6 +9,14 @@ def initialize(original)
@subset = Set.new
end
+ def unicode?
+ true
+ end
+
+ def to_unicode_map
+ @subset.inject({}) { |map, code| map[code] = code; map }
+ end
+
def use(character)
@subset << character
end
@@ -11,6 +11,14 @@ def initialize(original)
@next = 0x21 # apparently, PDF's don't like to use chars between 0-31
end
+ def unicode?
+ true
+ end
+
+ def to_unicode_map
+ @subset.dup
+ end
+
def use(character)
if !@unicodes.key?(character)
@subset[@next] = character

0 comments on commit fe7d7e5

Please sign in to comment.