Permalink
Browse files

give mac-roman and windows-1252 subsets a to_unicode_cmap

  • Loading branch information...
1 parent c5a8171 commit 900032abee9272485e77f6b68e87c9ad6346f69b @jamis jamis committed Jan 23, 2009
View
2 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,
View
2 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,
View
4 lib/ttfunk/subset/mac_roman.rb
@@ -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
View
4 lib/ttfunk/subset/windows_1252.rb
@@ -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

0 comments on commit 900032a

Please sign in to comment.