Method: Prawn::Fonts::AFM#encode_text

Defined in:
lib/prawn/fonts/afm.rb

#encode_text(text, options = {}) ⇒ Array<Array(0, (String, Array)>]

Perform any changes to the string that need to happen before it is rendered to the canvas. Returns an array of subset “chunks”, where each chunk is an array of two elements. The first element is the font subset number, and the second is either a string or an array (for kerned text).

For Adobe fonts, there is only ever a single subset, so the first element of the array is ‘0`, and the second is the string itself (or an array, if kerning is performed).

The ‘text` argument must be in WinAnsi encoding (cp1252).

Parameters:

  • text (String)
  • options (Hash{Symbol => any}) (defaults to: {})

Options Hash (options):

  • :kerning (Boolean)

Returns:

  • (Array<Array(0, (String, Array)>])

    Array<Array(0, (String, Array)>]



185
186
187
# File 'lib/prawn/fonts/afm.rb', line 185

def encode_text(text, options = {})
  [[0, options[:kerning] ? kern(text) : text]]
end