Skip to content

Commit

Permalink
Expose the mapping from subset code to unicode
Browse files Browse the repository at this point in the history
This lets us more easily build ToUnicode cmaps in PDF's
  • Loading branch information
jamis committed Jan 2, 2009
1 parent 62c766b commit fe7d7e5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/ttfunk/subset/base.rb
Expand Up @@ -18,6 +18,14 @@ def initialize(original)
@original = original @original = original
end end


def unicode?
false
end

def to_unicode_map
{}
end

def encode(options={}) def encode(options={})
cmap_table = new_cmap_table(options) cmap_table = new_cmap_table(options)
glyphs = collect_glyphs(original_glyph_ids) glyphs = collect_glyphs(original_glyph_ids)
Expand Down
8 changes: 8 additions & 0 deletions lib/ttfunk/subset/unicode.rb
Expand Up @@ -9,6 +9,14 @@ def initialize(original)
@subset = Set.new @subset = Set.new
end end


def unicode?
true
end

def to_unicode_map
@subset.inject({}) { |map, code| map[code] = code; map }
end

def use(character) def use(character)
@subset << character @subset << character
end end
Expand Down
8 changes: 8 additions & 0 deletions lib/ttfunk/subset/unicode_8bit.rb
Expand Up @@ -11,6 +11,14 @@ def initialize(original)
@next = 0x21 # apparently, PDF's don't like to use chars between 0-31 @next = 0x21 # apparently, PDF's don't like to use chars between 0-31
end end


def unicode?
true
end

def to_unicode_map
@subset.dup
end

def use(character) def use(character)
if !@unicodes.key?(character) if !@unicodes.key?(character)
@subset[@next] = character @subset[@next] = character
Expand Down

0 comments on commit fe7d7e5

Please sign in to comment.