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 mapping of glyph codes to Unicode strings. Used when embedding CID fonts with a subset of glyphs to provide /ToUnicode CMap data.
Supports both 1-byte and 2-byte codespaceranges, supplementary Unicode planes (via UTF-16 surrogate pairs), and automatic chunking of bfchar sections (max 100 entries per section per the PDF spec).
Constant Summary collapse
- MAX_BFCHAR_ENTRIES =
100
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:, code_size: 2) ⇒ Writer
constructor
A new instance of Writer.
- #to_s ⇒ Object
Constructor Details
#initialize(cmap_name:, cid_system_info:, mapping:, code_size: 2) ⇒ Writer
Returns a new instance of Writer.
23 24 25 26 27 28 |
# File 'lib/pdfrb/font/cmap/writer.rb', line 23 def initialize(cmap_name:, cid_system_info:, mapping:, code_size: 2) @cmap_name = cmap_name.to_s @cid_system_info = cid_system_info @mapping = mapping @code_size = code_size end |
Instance Attribute Details
#cid_system_info ⇒ Object (readonly)
Returns the value of attribute cid_system_info.
17 18 19 |
# File 'lib/pdfrb/font/cmap/writer.rb', line 17 def cid_system_info @cid_system_info end |
#cmap_name ⇒ Object (readonly)
Returns the value of attribute cmap_name.
17 18 19 |
# File 'lib/pdfrb/font/cmap/writer.rb', line 17 def cmap_name @cmap_name end |
#mapping ⇒ Object (readonly)
Returns the value of attribute mapping.
17 18 19 |
# File 'lib/pdfrb/font/cmap/writer.rb', line 17 def mapping @mapping end |
Instance Method Details
#to_s ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/pdfrb/font/cmap/writer.rb', line 30 def to_s buffer = +"" emit_header(buffer) emit_codespacerange(buffer) emit_bfchar(buffer) (buffer) buffer.force_encoding(::Encoding::BINARY) end |