Class: TTFunk::Encoding::MacRoman
- Inherits:
-
Object
- Object
- TTFunk::Encoding::MacRoman
- Defined in:
- lib/ttfunk/encoding/mac_roman.rb
Constant Summary collapse
- TO_UNICODE =
XXX: Ruby 1.9.2 on OS X Lion segfaults on range1.zip(range2)
Hash[*(0..255).zip((0..255).to_a).flatten]
- FROM_UNICODE =
{}
- POSTSCRIPT_GLYPH_MAPPING =
Maps MacRoman codes to their corresponding index in the Postscript glyph table (see TTFunk::Table::Post::Format10). If any entry in this array is a string, it is a postscript glyph that is not in the standard list, and which should be emitted specially in the TTF postscript table (‘post’, see format 2).
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, # 0x0F 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, # 0x1F 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, # 0x2F 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, # 0x3F 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, # 0x4F 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, # 0x5F 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, # 0x6F 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 0, # 0x7F 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, # 0x8F 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, # 0x9F 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, # 0xAF 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, # 0xBF 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, # 0xCF 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, "Euro", 190, 191, 192, 193, # 0xDF 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, # 0xEF 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225 # 0xFF ]
Class Method Summary collapse
- .covers?(character) ⇒ Boolean
- .from_unicode(string) ⇒ Object
- .from_unicode_codepoints(array) ⇒ Object
- .from_utf8(string) ⇒ Object
- .to_unicode(string) ⇒ Object
- .to_unicode_codepoints(array) ⇒ Object
- .to_utf8(string) ⇒ Object
Class Method Details
.covers?(character) ⇒ Boolean
61 62 63 |
# File 'lib/ttfunk/encoding/mac_roman.rb', line 61 def self.covers?(character) !FROM_UNICODE[character].nil? end |
.from_unicode(string) ⇒ Object
77 78 79 |
# File 'lib/ttfunk/encoding/mac_roman.rb', line 77 def self.from_unicode(string) from_unicode_codepoints(string.unpack("n*")).pack("C*") end |
.from_unicode_codepoints(array) ⇒ Object
85 86 87 |
# File 'lib/ttfunk/encoding/mac_roman.rb', line 85 def self.from_unicode_codepoints(array) array.map { |code| FROM_UNICODE[code] || 0 } end |
.from_utf8(string) ⇒ Object
73 74 75 |
# File 'lib/ttfunk/encoding/mac_roman.rb', line 73 def self.from_utf8(string) from_unicode_codepoints(string.unpack("U*")).pack("C*") end |
.to_unicode(string) ⇒ Object
69 70 71 |
# File 'lib/ttfunk/encoding/mac_roman.rb', line 69 def self.to_unicode(string) to_unicode_codepoints(string.unpack("C*")).pack("n*") end |
.to_unicode_codepoints(array) ⇒ Object
81 82 83 |
# File 'lib/ttfunk/encoding/mac_roman.rb', line 81 def self.to_unicode_codepoints(array) array.map { |code| TO_UNICODE[code] } end |
.to_utf8(string) ⇒ Object
65 66 67 |
# File 'lib/ttfunk/encoding/mac_roman.rb', line 65 def self.to_utf8(string) to_unicode_codepoints(string.unpack("C*")).pack("U*") end |