Module: Pdfrb::Font::Encoding
- Defined in:
- lib/pdfrb/font/encoding.rb,
lib/pdfrb/font/encoding/pdf_doc_encoding.rb,
lib/pdfrb/font/encoding/standard_encoding.rb,
lib/pdfrb/font/encoding/win_ansi_encoding.rb,
lib/pdfrb/font/encoding/mac_roman_encoding.rb,
lib/pdfrb/font/encoding/zapf_dingbats_encoding.rb
Defined Under Namespace
Modules: MacRomanEncoding, PDFDocEncoding, StandardEncoding, WinAnsiEncoding, ZapfDingbatsEncoding
Class Method Summary collapse
-
.decode(encoding_name, bytes) ⇒ Object
Decode
bytes(one byte per glyph) usingencoding_name(a Symbol like :WinAnsiEncoding) to Unicode. - .table_for(name) ⇒ Object
Class Method Details
.decode(encoding_name, bytes) ⇒ Object
Decode bytes (one byte per glyph) using encoding_name
(a Symbol like :WinAnsiEncoding) to Unicode.
15 16 17 18 19 20 21 22 |
# File 'lib/pdfrb/font/encoding.rb', line 15 def decode(encoding_name, bytes) table = table_for(encoding_name) return bytes unless table bytes.each_byte.with_object(+"") do |b, buf| buf << (table[b] ? [table[b]].pack("U") : "?") end.encode("UTF-8") end |
.table_for(name) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/pdfrb/font/encoding.rb', line 24 def table_for(name) case name.to_sym when :WinAnsiEncoding then WinAnsiEncoding::TABLE when :MacRomanEncoding then MacRomanEncoding::TABLE when :StandardEncoding then StandardEncoding::TABLE when :PDFDocEncoding then PDFDocEncoding::TABLE when :ZapfDingbatsEncoding then ZapfDingbatsEncoding::TABLE end end |