Method: HexaPDF::Content::Canvas#text_matrix

Defined in:
lib/hexapdf/content/canvas.rb

#text_matrix(a, b, c, d, e, f) ⇒ Object

:call-seq:

canvas.text_matrix(a, b, c, d, e, f)     => canvas

Sets the text matrix (and the text line matrix) to the given matrix and returns self.

The text matrix determines where and how the glyphs are rendered. The most common use is to translate the text space origin since the text drawing operations always use the text space origin as starting point for drawing the glyphs. This translation operation can more easily be specified using #move_text_cursor.

The given values are interpreted as a matrix in the following way:

a b 0
c d 0
e f 1

If the current graphics object is not a text object, #begin_text is automatically called because the text matrix is only available within a text object.

Examples:

#>pdf
canvas.font("Helvetica", size: 10)
canvas.begin_text                         # Not necessary
canvas.text_matrix(1, 0, 0, 1, 50, 100)   # Translate text origin to (50, 100)
canvas.text("This is some text")

canvas.text_matrix(2, 1, 3, 0.5, 50, 50)
canvas.text("This is some text")

See: PDF2.0 s9.4.2, #move_text_cursor, #text_cursor



2132
2133
2134
2135
2136
# File 'lib/hexapdf/content/canvas.rb', line 2132

def text_matrix(a, b, c, d, e, f)
  begin_text
  invoke(:Tm, a, b, c, d, e, f)
  self
end