Method: CombinePDF::Fonts::Font#encode

Defined in:
lib/combine_pdf/fonts.rb

#encode(text) ⇒ Object

This function translate a unicode string, to a character glyph ID stream.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/combine_pdf/fonts.rb', line 48

def encode(text)
  # FIXME: embed RTL text convertion
  return format_string_to_pdf(text) unless cmap
  coded_array = text.chars.map do |c|
    if cmap[c]
      cmap[c]
    else
      warn "CombinePDF ERROR: couldn't encode string - characters not supported by the chosen font."
      ''
    end
  end
  coded_array.unshift '<'
  coded_array.push '>'
  coded_array.join
end