Method: HexaPDF::Layout::TextFragment#width

Defined in:
lib/hexapdf/layout/text_fragment.rb

#widthObject

The width of the text fragment.

It is the sum of the widths of its items and is calculated by using the algorithm presented in PDF2.0 s9.4.4. By using kerning values as the first and/or last items, the text contained in the fragment may spill over the left and/or right boundary.



330
331
332
# File 'lib/hexapdf/layout/text_fragment.rb', line 330

def width
  @width ||= @items.sum {|item| style.scaled_item_width(item) }
end