@@ -7,15 +7,16 @@ class PDF::Reader
7
7
class TextRun
8
8
include Comparable
9
9
10
- attr_reader :origin , :width , :font_size , :text
10
+ attr_reader :origin , :width , :font_size , :text , :state
11
11
12
12
alias :to_s :text
13
13
14
- def initialize ( x , y , width , font_size , text )
14
+ def initialize ( x , y , width , font_size , text , state )
15
15
@origin = PDF ::Reader ::Point . new ( x , y )
16
16
@width = width
17
17
@font_size = font_size
18
18
@text = text
19
+ @state = state
19
20
end
20
21
21
22
# Allows collections of TextRun objects to be sorted. They will be sorted
@@ -62,14 +63,14 @@ def +(other)
62
63
raise ArgumentError , "#{ other } cannot be merged with this run" unless mergable? ( other )
63
64
64
65
if ( other . x - endx ) <( font_size * 0.2 )
65
- TextRun . new ( x , y , other . endx - x , font_size , text + other . text )
66
+ TextRun . new ( x , y , other . endx - x , font_size , text + other . text , { } )
66
67
else
67
- TextRun . new ( x , y , other . endx - x , font_size , "#{ text } #{ other . text } " )
68
+ TextRun . new ( x , y , other . endx - x , font_size , "#{ text } #{ other . text } " , { } )
68
69
end
69
70
end
70
71
71
72
def inspect
72
- "#{ text } w:#{ width } f:#{ font_size } @#{ x } ,#{ y } "
73
+ "#{ text } w:#{ width } f:#{ font_size } @#{ x } ,#{ y } #{ @state . inspect } "
73
74
end
74
75
75
76
def intersect? ( other_run )
0 commit comments