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 box 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: glyph_box.lower_left -> [llx, lly].
-
#lower_right ⇒ Object
:call-seq: glyph_box.lower_right -> [lrx, lry].
-
#points ⇒ Object
:call-seq: glyph_box.points -> [llx, lly, lrx, lry, urx, ury, ulx, uly].
-
#upper_left ⇒ Object
:call-seq: glyph_box.upper_left -> [ulx, uly].
-
#upper_right ⇒ Object
:call-seq: glyph_box.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].
95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/hexapdf/content/processor.rb', line 95 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.
87 88 89 |
# File 'lib/hexapdf/content/processor.rb', line 87 def code_point @code_point end |
#string ⇒ Object (readonly)
The Unicode value of the code point.
90 91 92 |
# File 'lib/hexapdf/content/processor.rb', line 90 def string @string end |
Instance Method Details
#lower_left ⇒ Object
:call-seq:
glyph_box.lower_left -> [llx, lly]
Returns the lower left coordinate
111 112 113 |
# File 'lib/hexapdf/content/processor.rb', line 111 def lower_left [@llx, @lly] end |
#lower_right ⇒ Object
:call-seq:
glyph_box.lower_right -> [lrx, lry]
Returns the lower right coordinate
119 120 121 |
# File 'lib/hexapdf/content/processor.rb', line 119 def lower_right [@lrx, @lry] end |
#points ⇒ Object
:call-seq:
glyph_box.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.
145 146 147 |
# File 'lib/hexapdf/content/processor.rb', line 145 def points [@llx, @lly, @lrx, @lry, @ulx + (@lrx - @llx), @uly + (@lry - @lly), @ulx, @uly] end |
#upper_left ⇒ Object
:call-seq:
glyph_box.upper_left -> [ulx, uly]
Returns the upper left coordinate
127 128 129 |
# File 'lib/hexapdf/content/processor.rb', line 127 def upper_left [@ulx, @uly] end |
#upper_right ⇒ Object
:call-seq:
glyph_box.upper_right -> [urx, ury]
Returns the upper right coordinate which is computed by using the other three points of the parallelogram.
136 137 138 |
# File 'lib/hexapdf/content/processor.rb', line 136 def upper_right [@ulx + (@lrx - @llx), @uly + (@lry - @lly)] end |