Skip to content

Commit

Permalink
give mac-roman and windows-1252 subsets a to_unicode_cmap
Browse files Browse the repository at this point in the history
  • Loading branch information
jamis committed Jan 23, 2009
1 parent c5a8171 commit 900032a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/ttfunk/encoding/mac_roman.rb
@@ -1,7 +1,7 @@
module TTFunk
module Encoding
class MacRoman
TO_UNICODE = Hash.new { |h,k| k }
TO_UNICODE = Hash[*(0..255).zip(0..255).flatten]
TO_UNICODE.update(
0x81 => 0x00C5, 0x82 => 0x00C7, 0x83 => 0x00C9, 0x84 => 0x00D1, 0x85 => 0x00D6,
0x86 => 0x00DC, 0x87 => 0x00E1, 0x88 => 0x00E0, 0x89 => 0x00E2, 0x8A => 0x00E4,
Expand Down
2 changes: 1 addition & 1 deletion lib/ttfunk/encoding/windows_1252.rb
@@ -1,7 +1,7 @@
module TTFunk
module Encoding
class Windows1252
TO_UNICODE = Hash.new { |h,k| k }
TO_UNICODE = Hash[*(0..255).zip(0..255).flatten]
TO_UNICODE.update(
0x80 => 0x20AC, 0x82 => 0x201A, 0x83 => 0x0192, 0x84 => 0x201E, 0x85 => 0x2026,
0x86 => 0x2020, 0x87 => 0x2021, 0x88 => 0x02C6, 0x89 => 0x2030, 0x8A => 0x0160,
Expand Down
4 changes: 4 additions & 0 deletions lib/ttfunk/subset/mac_roman.rb
Expand Up @@ -10,6 +10,10 @@ def initialize(original)
@subset = Array.new(256)
end

def to_unicode_map
Encoding::MacRoman::TO_UNICODE
end

def use(character)
@subset[Encoding::MacRoman::FROM_UNICODE[character]] = character
end
Expand Down
4 changes: 4 additions & 0 deletions lib/ttfunk/subset/windows_1252.rb
Expand Up @@ -10,6 +10,10 @@ def initialize(original)
@subset = Array.new(256)
end

def to_unicode_map
Encoding::Windows1252::TO_UNICODE
end

def use(character)
@subset[Encoding::Windows1252::FROM_UNICODE[character]] = character
end
Expand Down

0 comments on commit 900032a

Please sign in to comment.