Class: Pdfrb::Font::CMap::Writer
- Inherits:
-
Object
- Object
- Pdfrb::Font::CMap::Writer
- Defined in:
- lib/pdfrb/font/cmap/writer.rb
Overview
Writes a CMap text file from a bfchar mapping. Used when
embedding CID fonts with a subset of glyphs.
Instance Attribute Summary collapse
-
#cid_system_info ⇒ Object
readonly
Returns the value of attribute cid_system_info.
-
#cmap_name ⇒ Object
readonly
Returns the value of attribute cmap_name.
-
#mapping ⇒ Object
readonly
Returns the value of attribute mapping.
Instance Method Summary collapse
-
#initialize(cmap_name:, cid_system_info:, mapping:) ⇒ Writer
constructor
A new instance of Writer.
- #to_s ⇒ Object
Constructor Details
#initialize(cmap_name:, cid_system_info:, mapping:) ⇒ Writer
Returns a new instance of Writer.
11 12 13 14 15 |
# File 'lib/pdfrb/font/cmap/writer.rb', line 11 def initialize(cmap_name:, cid_system_info:, mapping:) @cmap_name = cmap_name @cid_system_info = cid_system_info @mapping = mapping end |
Instance Attribute Details
#cid_system_info ⇒ Object (readonly)
Returns the value of attribute cid_system_info.
9 10 11 |
# File 'lib/pdfrb/font/cmap/writer.rb', line 9 def cid_system_info @cid_system_info end |
#cmap_name ⇒ Object (readonly)
Returns the value of attribute cmap_name.
9 10 11 |
# File 'lib/pdfrb/font/cmap/writer.rb', line 9 def cmap_name @cmap_name end |
#mapping ⇒ Object (readonly)
Returns the value of attribute mapping.
9 10 11 |
# File 'lib/pdfrb/font/cmap/writer.rb', line 9 def mapping @mapping end |
Instance Method Details
#to_s ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pdfrb/font/cmap/writer.rb', line 17 def to_s buffer = +"" buffer << "/CIDInit /ProcSet findresource begin\n" buffer << "12 dict begin\n" buffer << "begincmap\n" buffer << "/CIDSystemInfo <<\n" buffer << " /Registry (Adobe)\n" buffer << " /Ordering (#{@cid_system_info[:ordering]})\n" buffer << " /Supplement #{@cid_system_info[:supplement]}\n" buffer << ">> def\n" buffer << "/CMapName /#{@cmap_name} def\n" buffer << "/CMapType 1 def\n" buffer << "1 begincodespacerange\n" buffer << " <0000> <FFFF>\n" buffer << "endcodespacerange\n" buffer << "#{@mapping.length} beginbfchar\n" @mapping.each do |code, unicode| buffer << "<%04X> <%04X>\n" % [code, unicode] end buffer << "endbfchar\n" buffer << "endcmap\n" buffer << "CMapName currentdict /CMap defineresource pop\n" buffer << "end\n" buffer << "end\n" buffer.force_encoding(Encoding::BINARY) end |