Class: HexaPDF::Content::Processor::GlyphBox
- Inherits:
-
Object
- Object
- HexaPDF::Content::Processor::GlyphBox
- Defined in:
- lib/hexapdf/content/processor.rb
Overview
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.
Instance Attribute Summary collapse
-
#code_point ⇒ Object
readonly
The code point representing the glyph.
-
#string ⇒ Object
readonly
The Unicode value of the code point.
Instance Method Summary collapse
-
#initialize(code_point, string, llx, lly, lrx, lry, ulx, uly) ⇒ GlyphBox
constructor
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].
-
#lower_left ⇒ Object
:call-seq: fragment.lower_left -> [llx, lly].
-
#lower_right ⇒ Object
:call-seq: fragment.lower_right -> [lrx, lry].
-
#points ⇒ Object
:call-seq: fragment.points -> [llx, lly, lrx, lry, urx, ury, ulx, uly].
-
#upper_left ⇒ Object
:call-seq: fragment.upper_left -> [ulx, uly].
-
#upper_right ⇒ Object
:call-seq: fragment.upper_right -> [urx, ury].
Constructor Details
#initialize(code_point, string, llx, lly, lrx, lry, ulx, uly) ⇒ GlyphBox
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].
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/hexapdf/content/processor.rb', line 92 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 |
Instance Attribute Details
#code_point ⇒ Object (readonly)
The code point representing the glyph.
84 85 86 |
# File 'lib/hexapdf/content/processor.rb', line 84 def code_point @code_point end |
#string ⇒ Object (readonly)
The Unicode value of the code point.
87 88 89 |
# File 'lib/hexapdf/content/processor.rb', line 87 def string @string end |
Instance Method Details
#lower_left ⇒ Object
:call-seq:
fragment.lower_left -> [llx, lly]
Returns the lower left coordinate
108 109 110 |
# File 'lib/hexapdf/content/processor.rb', line 108 def lower_left [@llx, @lly] end |
#lower_right ⇒ Object
:call-seq:
fragment.lower_right -> [lrx, lry]
Returns the lower right coordinate
116 117 118 |
# File 'lib/hexapdf/content/processor.rb', line 116 def lower_right [@lrx, @lry] end |
#points ⇒ Object
:call-seq:
fragment.points -> [llx, lly, lrx, lry, urx, ury, ulx, uly]
Returns the four corners of the box as an array of coordinates, starting with the lower left corner and going counterclockwise.
142 143 144 |
# File 'lib/hexapdf/content/processor.rb', line 142 def points [@llx, @lly, @lrx, @lry, @ulx + (@lrx - @llx), @uly + (@lry - @lly), @ulx, @uly] end |
#upper_left ⇒ Object
:call-seq:
fragment.upper_left -> [ulx, uly]
Returns the upper left coordinate
124 125 126 |
# File 'lib/hexapdf/content/processor.rb', line 124 def upper_left [@ulx, @uly] end |
#upper_right ⇒ Object
:call-seq:
fragment.upper_right -> [urx, ury]
Returns the upper right coordinate which is computed by using the other three points of the parallelogram.
133 134 135 |
# File 'lib/hexapdf/content/processor.rb', line 133 def upper_right [@ulx + (@lrx - @llx), @uly + (@lry - @lly)] end |