class HexaPDF::Content::Processor::GlyphBox

Represents an (immutable) glyph box with positioning information.

Since the glyph may have been transformed by an affine matrix, the bounding may not be a rectangle in all cases but it is always a parallelogram.

Attributes

code_point[R]

The code point representing the glyph.

string[R]

The Unicode value of the code point.

Public Class Methods

new(code_point, string, llx, lly, lrx, lry, ulx, uly) click to toggle source

Creates a new glyph box for the given code point/Unicode value pair with the lower left coordinate [llx, lly], the lower right coordinate [lrx, lry], and the upper left coordinate [ulx, uly].

# File lib/hexapdf/content/processor.rb, line 94
def initialize(code_point, string, llx, lly, lrx, lry, ulx, uly)
  @code_point = code_point
  @string = string.freeze
  @llx = llx
  @lly = lly
  @lrx = lrx
  @lry = lry
  @ulx = ulx
  @uly = uly
  freeze
end

Public Instance Methods

lower_left → [llx, lly] click to toggle source

Returns the lower left coordinate

# File lib/hexapdf/content/processor.rb, line 110
def lower_left
  [@llx, @lly]
end
lower_right → [lrx, lry] click to toggle source

Returns the lower right coordinate

# File lib/hexapdf/content/processor.rb, line 118
def lower_right
  [@lrx, @lry]
end
points → [llx, lly, lrx, lry, urx, ury, ulx, uly] click to toggle source

Returns the four corners of the box as an array of coordinates, starting with the lower left corner and going counterclockwise.

# File lib/hexapdf/content/processor.rb, line 144
def points
  [@llx, @lly, @lrx, @lry, @ulx + (@lrx - @llx), @uly + (@lry - @lly), @ulx, @uly]
end
upper_left → [ulx, uly] click to toggle source

Returns the upper left coordinate

# File lib/hexapdf/content/processor.rb, line 126
def upper_left
  [@ulx, @uly]
end
upper_right → [urx, ury] click to toggle source

Returns the upper right coordinate which is computed by using the other three points of the parallelogram.

# File lib/hexapdf/content/processor.rb, line 135
def upper_right
  [@ulx + (@lrx - @llx), @uly + (@lry - @lly)]
end