obf 0.8.4 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/obf/pdf.rb +14 -12
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab2c55d56ca5f570a188f3936a58324965cfb5f9
|
4
|
+
data.tar.gz: b0dc51874a5a7a7b3f010d6f243cd109909ab506
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b90045b54cdb8f01cef1ef31e2c003a4f7ff908d8337f4cab8bb1d06553ecfed2eaeb490de01b3952874501093b1474733bc0a78f112e489d6d6ac53b66c7a4
|
7
|
+
data.tar.gz: 2353646c0179cebd7832a883c5f2242a22e0047119eeb4f8be4ba1aa5b258877ed111cacd466db1abb51b42f3f0fc4fab26dc36c26fd81a3c0b7e306a82e4a6d
|
data/lib/obf/pdf.rb
CHANGED
@@ -32,8 +32,6 @@ module OBF::PDF
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def self.build_pdf(obj, dest_path, zipper, opts={})
|
35
|
-
character_classes = RTL_SCRIPTS.map{ |script| "\\p{#{script}}" }.join
|
36
|
-
rtl_regex = /[#{character_classes}]/
|
37
35
|
OBF::Utils.as_progress_percent(0, 1.0) do
|
38
36
|
# parse obf, draw as pdf
|
39
37
|
pdf = Prawn::Document.new(
|
@@ -76,6 +74,10 @@ module OBF::PDF
|
|
76
74
|
end
|
77
75
|
end
|
78
76
|
|
77
|
+
def self.rtl_regex
|
78
|
+
@res ||= /[#{RTL_SCRIPTS.map{ |script| "\\p{#{script}}" }.join}]/
|
79
|
+
end
|
80
|
+
|
79
81
|
def self.build_page(pdf, obj, options)
|
80
82
|
OBF::Utils.as_progress_percent(0, 1.0) do
|
81
83
|
doc_width = 11*72 - 72
|
@@ -152,19 +154,19 @@ module OBF::PDF
|
|
152
154
|
|
153
155
|
text = (button['label'] || button['vocalization']).to_s
|
154
156
|
direction = text.match(rtl_regex) ? :rtl : :ltr
|
155
|
-
if
|
157
|
+
if options['text_case'] == 'upper'
|
156
158
|
text = text.upcase
|
157
|
-
elsif
|
159
|
+
elsif options['text_case'] == 'lower'
|
158
160
|
text = text.downcase
|
159
161
|
end
|
160
162
|
pdf.text_box text, :at => [0, vertical], :width => button_width, :height => text_height, :align => :center, :valign => :center, :overflow => :shrink_to_fit, :direction => direction
|
161
|
-
if
|
163
|
+
if options['text_only']
|
162
164
|
# render text
|
163
165
|
pdf.fill_color "000000"
|
164
166
|
text = (button['label'] || button['vocalization']).to_s
|
165
|
-
if
|
167
|
+
if options['text_case'] == 'upper'
|
166
168
|
text = text.upcase
|
167
|
-
elsif
|
169
|
+
elsif options['text_case'] == 'lower'
|
168
170
|
text = text.downcase
|
169
171
|
end
|
170
172
|
pdf.text_box text, :at => [0, 0], :width => button_width, :height => button_height, :align => :center, :valign => :center, :overflow => :shrink_to_fit, :direction => direction
|
@@ -187,12 +189,12 @@ module OBF::PDF
|
|
187
189
|
if options['pages'] && button['load_board']
|
188
190
|
page = options['pages'][button['load_board']['id']]
|
189
191
|
if page
|
190
|
-
page_vertical = options['text_on_top'] ?
|
192
|
+
page_vertical = options['text_on_top'] ? -2 + text_height : button_height + 2
|
191
193
|
pdf.fill_color "ffffff"
|
192
194
|
pdf.stroke_color "eeeeee"
|
193
|
-
pdf.fill_and_stroke_rounded_rectangle [button_width -
|
195
|
+
pdf.fill_and_stroke_rounded_rectangle [button_width - 18, page_vertical], 20, text_height, 5
|
194
196
|
pdf.fill_color "000000"
|
195
|
-
pdf.formatted_text_box [{:text => page, :anchor => "page#{page}"}], :at => [button_width -
|
197
|
+
pdf.formatted_text_box [{:text => page, :anchor => "page#{page}"}], :at => [button_width - 18, page_vertical], :width => 20, :height => text_height, :align => :center, :valign => :center
|
196
198
|
end
|
197
199
|
end
|
198
200
|
|
@@ -200,9 +202,9 @@ module OBF::PDF
|
|
200
202
|
pdf.fill_color "000000"
|
201
203
|
vertical = options['text_on_top'] ? button_height : text_height
|
202
204
|
text = (button['label'] || button['vocalization']).to_s
|
203
|
-
if
|
205
|
+
if options['text_case'] == 'upper'
|
204
206
|
text = text.upcase
|
205
|
-
elsif
|
207
|
+
elsif options['text_case'] == 'lower'
|
206
208
|
text = text.downcase
|
207
209
|
end
|
208
210
|
pdf.text_box text, :at => [0, vertical], :width => button_width, :height => text_height, :align => :center, :valign => :center, :overflow => :shrink_to_fit
|