obf 0.9.8.32 → 0.9.8.33

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/obf/pdf.rb +108 -111
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16b1632c3cbc9a1ae6257270d4efb70929ded87aa79c1b73a5ed7c553e452df6
4
- data.tar.gz: 37d0c8a2c6eed4b4ce9ba26bf97f76d12040b33def794d1524cc2ea4028ab0ad
3
+ metadata.gz: 65381b28a81a2f51dbd9274cb1f58bf474bc9386f4f508c818485551e25160bd
4
+ data.tar.gz: dc6ba54c37d84ccf783bf766ab5c477723c144df634d6081c13549449b5fc2b6
5
5
  SHA512:
6
- metadata.gz: 236aefcd275d5d2323895a6c463b7d08028f4b6b746e41df12efd723ca3829324edfd5030c07ac2a4e9b7f54999660f2a9efc5d40b97790ee24c90b395fdb3bd
7
- data.tar.gz: 2f5fe9234e980e76d4bfd23affa13a0966ab1bd6c8f394a7cb2fc7f614c0f8baac92662a0ecd3b48632e282ea0747a1c751c31441fa086bb349da05553197848
6
+ metadata.gz: b0232d5e377bdf2c0d1882a4e9d473b73c2fab8e931333114bbc354a36ef8455ce1462af7c3686e5a949901f0b703f29c69ab4528b457622f3e65313bcf7a381
7
+ data.tar.gz: 2cd07ffd2f3cbf8fd665f4a42b3054a5df678f58adc2348db4fe14dbd9af85293f2942db838a095fd1d81c5d1ebb6768e3c4d28e078302e81136f7999ced3be3
data/lib/obf/pdf.rb CHANGED
@@ -45,24 +45,23 @@ module OBF::PDF
45
45
  pdf = Prawn::Document.new(doc_opts)
46
46
  # remember: https://www.alphabet-type.com/tools/charset-checker/
47
47
  pdf.font_families.update('THFahKwangBold' => {
48
- normal: {font: 'THFahKwangBold', file: File.expand_path('../../THFahKwangBold.ttf', __FILE__)}
48
+ normal: File.expand_path('../../THFahKwangBold.ttf', __FILE__)
49
49
  })
50
50
  pdf.font_families.update('MiedingerBook' => {
51
- normal: {font: 'MiedingerBook', file: File.expand_path('../../MiedingerBook.ttf', __FILE__)}
51
+ normal: File.expand_path('../../MiedingerBook.ttf', __FILE__)
52
52
  })
53
53
  pdf.font_families.update('Arial' => {
54
- normal: {font: 'Arial', file: File.expand_path('../../Arial.ttf', __FILE__)}
54
+ normal: File.expand_path('../../Arial.ttf', __FILE__)
55
55
  })
56
56
  pdf.font_families.update('TimesNewRoman' => {
57
- normal: {font: 'TimesNewRoman', file: File.expand_path('../../TimesNewRoman.ttf', __FILE__)}
57
+ normal: File.expand_path('../../TimesNewRoman.ttf', __FILE__)
58
58
  })
59
59
  default_font = 'TimesNewRoman'
60
60
  if opts['font'] && !opts['font'].match(/TimesNewRoman/) && File.exists?(opts['font'])
61
61
  pdf.font_families.update('DocDefault' => {
62
- normal: {font: 'DocDefault', file: font}
62
+ normal: file: opts['font']
63
63
  })
64
64
  default_font = 'DocDefault'
65
- else
66
65
  end
67
66
  pdf.fallback_fonts = ['TimesNewRoman', 'THFahKwangBold', 'MiedingerBook', 'Helvetica']
68
67
  pdf.font(default_font)
@@ -119,7 +118,7 @@ module OBF::PDF
119
118
  else
120
119
  build_page(pdf, obj, {
121
120
  'headerless' => !!opts['headerless'],
122
- 'font' => font,
121
+ 'font' => default_font,
123
122
  'text_on_top' => !!opts['text_on_top'],
124
123
  'transparent_background' => !!opts['transparent_background'],
125
124
  'symbol_background' => opts['symbol_background'],
@@ -154,98 +153,112 @@ module OBF::PDF
154
153
  page_num = options['pages'][obj['id']].to_i
155
154
  pdf.add_dest("page#{page_num}", pdf.dest_fit) if options['links']
156
155
  end
157
- # header
158
- if !options['headerless']
159
- header_height = 80
160
- pdf.bounding_box([0, doc_height], :width => doc_width, :height => header_height) do
161
- pdf.font('Arial')
162
- pdf.line_width = 2
163
- pdf.font_size 16
164
- pdf.fill_color "eeeeee"
165
- pdf.stroke_color "888888"
166
-
167
- include_back = options['pages'] && page_num != 1 && page_num != 0
168
- # Go Back
169
- if include_back
170
- OBF::Utils.log " board backlinks #{obj['id']} #{options['backlinks'].to_json}"
171
- options['backlinks'] ||= []
172
- if options['backlinks'].length > 0
173
- x = 110
174
- pdf.fill_and_stroke_rounded_rectangle [x, header_height], 100, header_height, default_radius
175
- pdf.fill_color "6D81D1"
176
- pdf.fill_and_stroke_polygon([x + 5, 45], [x + 35, 70], [x + 35, 60], [x + 95, 60], [x + 95, 30], [x + 35, 30], [x + 35, 20])
177
- pdf.fill_color "666666"
178
- text_options = {:text => "Go Back"}
179
- text_options[:anchor] = "page1" if options['links']
180
- pdf.formatted_text_box [text_options], :at => [x + 10, header_height], :width => 80, :height => 80, :align => :center, :valign => :bottom, :overflow => :shrink_to_fit
181
- backlinks = (options['backlinks'] || []).join(',')
182
- pdf.fill_color "ffffff"
183
- pdf.formatted_text_box [{:text => backlinks}], :at => [x + 20, header_height + 5 - 25], :width => 70, :height => 30, :align => :center, :valign => :center, :overflow => :shrink_to_fit
184
- end
185
- end
156
+ pdf.font('Arial') do
157
+ # header
158
+ if !options['headerless']
159
+ header_height = 80
160
+ pdf.bounding_box([0, doc_height], :width => doc_width, :height => header_height) do
161
+ pdf.line_width = 2
162
+ pdf.font_size 16
163
+ pdf.fill_color "eeeeee"
164
+ pdf.stroke_color "888888"
165
+ include_back = options['pages'] && page_num != 1 && page_num != 0
166
+ # Go Back
167
+ if include_back
168
+ OBF::Utils.log " board backlinks #{obj['id']} #{options['backlinks'].to_json}"
169
+ options['backlinks'] ||= []
170
+ if options['backlinks'].length > 0
171
+ x = 110
172
+ pdf.fill_and_stroke_rounded_rectangle [x, header_height], 100, header_height, default_radius
173
+ pdf.fill_color "6D81D1"
174
+ pdf.fill_and_stroke_polygon([x + 5, 45], [x + 35, 70], [x + 35, 60], [x + 95, 60], [x + 95, 30], [x + 35, 30], [x + 35, 20])
175
+ pdf.fill_color "666666"
176
+ text_options = {:text => "Go Back"}
177
+ text_options[:anchor] = "page1" if options['links']
178
+ pdf.formatted_text_box [text_options], :at => [x + 10, header_height], :width => 80, :height => 80, :align => :center, :valign => :bottom, :overflow => :shrink_to_fit
179
+ backlinks = (options['backlinks'] || []).join(',')
180
+ pdf.fill_color "ffffff"
181
+ pdf.formatted_text_box [{:text => backlinks}], :at => [x + 20, header_height + 5 - 25], :width => 70, :height => 30, :align => :center, :valign => :center, :overflow => :shrink_to_fit
182
+ end
183
+ end
186
184
 
187
- # Say it Out Loud
188
- pdf.fill_color "ffffff"
189
- shift = include_back ? 0 : 55
190
- offset = include_back ? 110 : 55
191
- box_shift = include_back ? 110 : 0
192
-
193
- pdf.fill_and_stroke_rounded_rectangle [110 + box_shift, header_height], 170 + shift + shift, header_height, default_radius
194
- pdf.fill_color "DDDB54"
195
- pdf.fill_and_stroke do
196
- pdf.move_to 160 + offset, 40
197
- pdf.line_to 190 + offset, 55
198
- pdf.curve_to [125 + offset, 40], :bounds => [[180 + offset, 80], [125 + offset, 80]]
199
- pdf.curve_to [190 + offset, 25], :bounds => [[125 + offset, 0], [180 + offset, 0]]
200
- pdf.line_to 160 + offset, 40
201
- end
202
- pdf.fill_color "444444"
203
- pdf.text_box "Say that out loud for me", :at => [210 + offset, header_height], :width => 60, :height => 80, :align => :center, :valign => :center, :overflow => :shrink_to_fit
185
+ # Say it Out Loud
186
+ pdf.fill_color "ffffff"
187
+ shift = include_back ? 0 : 55
188
+ offset = include_back ? 110 : 55
189
+ box_shift = include_back ? 110 : 0
190
+
191
+ pdf.fill_and_stroke_rounded_rectangle [110 + box_shift, header_height], 170 + shift + shift, header_height, default_radius
192
+ pdf.fill_color "DDDB54"
193
+ pdf.fill_and_stroke do
194
+ pdf.move_to 160 + offset, 40
195
+ pdf.line_to 190 + offset, 55
196
+ pdf.curve_to [125 + offset, 40], :bounds => [[180 + offset, 80], [125 + offset, 80]]
197
+ pdf.curve_to [190 + offset, 25], :bounds => [[125 + offset, 0], [180 + offset, 0]]
198
+ pdf.line_to 160 + offset, 40
199
+ end
200
+ pdf.fill_color "444444"
201
+ pdf.text_box "Say that out loud for me", :at => [210 + offset, header_height], :width => 60, :height => 80, :align => :center, :valign => :center, :overflow => :shrink_to_fit
204
202
 
205
- # Start Over
206
- x = doc_width
207
- pdf.fill_color "eeeeee"
208
- pdf.fill_and_stroke_rounded_rectangle [(doc_width - x), header_height], 100, header_height, default_radius
209
- pdf.fill_color "5c9c6d"
210
- pdf.stroke_color "25783b"
211
- pdf.fill_and_stroke_polygon([doc_width - x + 50, 75], [doc_width - x + 80, 50], [doc_width - x + 80, 20], [doc_width - x + 20, 20], [doc_width - x + 20, 50])
212
- pdf.stroke_color "888888"
213
- pdf.fill_color "666666"
214
- pdf.text_box "Start Over", :styles => [:bold], :at => [(doc_width - x + 10), header_height], :width => 80, :height => 80, :align => :center, :valign => :bottom, :overflow => :shrink_to_fit
203
+ # Start Over
204
+ x = doc_width
205
+ pdf.fill_color "eeeeee"
206
+ pdf.fill_and_stroke_rounded_rectangle [(doc_width - x), header_height], 100, header_height, default_radius
207
+ pdf.fill_color "5c9c6d"
208
+ pdf.stroke_color "25783b"
209
+ pdf.fill_and_stroke_polygon([doc_width - x + 50, 75], [doc_width - x + 80, 50], [doc_width - x + 80, 20], [doc_width - x + 20, 20], [doc_width - x + 20, 50])
210
+ pdf.stroke_color "888888"
211
+ pdf.fill_color "666666"
212
+ pdf.text_box "Start Over", :styles => [:bold], :at => [(doc_width - x + 10), header_height], :width => 80, :height => 80, :align => :center, :valign => :bottom, :overflow => :shrink_to_fit
215
213
 
216
- # Oops
217
- x = 210
218
- pdf.fill_color "eeeeee"
219
- pdf.fill_and_stroke_rounded_rectangle [(doc_width - x), header_height], 100, header_height, default_radius
220
- pdf.fill_color "6653a6"
221
- pdf.stroke_color "554a78"
222
- pdf.fill_and_stroke_polygon([doc_width - x + 50 - 7, 75], [doc_width - x + 50 + 7, 75], [doc_width - x + 50 + 7, 40], [doc_width - x + 50 - 7, 40])
223
- pdf.fill_and_stroke_polygon([doc_width - x + 50 - 7, 33], [doc_width - x + 50 + 7, 33], [doc_width - x + 50 + 7, 20], [doc_width - x + 50 - 7, 20])
224
- pdf.stroke_color "888888"
225
- pdf.fill_color "666666"
226
- pdf.text_box "Oops", :at => [(doc_width - x + 10), header_height], :width => 80, :height => 80, :align => :center, :valign => :bottom, :overflow => :shrink_to_fit
214
+ # Oops
215
+ x = 210
216
+ pdf.fill_color "eeeeee"
217
+ pdf.fill_and_stroke_rounded_rectangle [(doc_width - x), header_height], 100, header_height, default_radius
218
+ pdf.fill_color "6653a6"
219
+ pdf.stroke_color "554a78"
220
+ pdf.fill_and_stroke_polygon([doc_width - x + 50 - 7, 75], [doc_width - x + 50 + 7, 75], [doc_width - x + 50 + 7, 40], [doc_width - x + 50 - 7, 40])
221
+ pdf.fill_and_stroke_polygon([doc_width - x + 50 - 7, 33], [doc_width - x + 50 + 7, 33], [doc_width - x + 50 + 7, 20], [doc_width - x + 50 - 7, 20])
222
+ pdf.stroke_color "888888"
223
+ pdf.fill_color "666666"
224
+ pdf.text_box "Oops", :at => [(doc_width - x + 10), header_height], :width => 80, :height => 80, :align => :center, :valign => :bottom, :overflow => :shrink_to_fit
227
225
 
228
- # Stop
229
- x = 320
230
- pdf.fill_color "eeeeee"
231
- pdf.fill_and_stroke_rounded_rectangle [(doc_width - x), header_height], 100, header_height, default_radius
232
- pdf.fill_color "944747"
233
- pdf.stroke_color "693636"
234
- pdf.fill_and_stroke_polygon([doc_width - x + 39, 70], [doc_width - x + 61, 70], [doc_width - x + 75, 56], [doc_width - x + 75, 34], [doc_width - x + 61, 20], [doc_width - x + 39, 20], [doc_width - x + 25, 34], [doc_width - x + 25, 56])
235
- pdf.stroke_color "888888"
236
- pdf.fill_color "666666"
237
- pdf.text_box "Stop", :at => [(doc_width - x + 10), header_height], :width => 80, :height => 80, :align => :center, :valign => :bottom, :overflow => :shrink_to_fit
238
-
239
- # Clear
240
- x = 100
241
- pdf.fill_color "eeeeee"
242
- pdf.fill_and_stroke_rounded_rectangle [(doc_width - x), header_height], 100, header_height, default_radius
243
- pdf.stroke_color "666666"
244
- pdf.fill_color "888888"
245
- pdf.fill_and_stroke_polygon([doc_width - x + 10, 45], [doc_width - x + 35, 70], [doc_width - x + 90, 70], [doc_width - x + 90, 20], [doc_width - x + 35, 20])
246
- pdf.stroke_color "888888"
247
- pdf.fill_color "666666"
248
- pdf.text_box "Clear", :at => [(doc_width - x + 10), header_height], :width => 80, :height => 80, :align => :center, :valign => :bottom, :overflow => :shrink_to_fit
226
+ # Stop
227
+ x = 320
228
+ pdf.fill_color "eeeeee"
229
+ pdf.fill_and_stroke_rounded_rectangle [(doc_width - x), header_height], 100, header_height, default_radius
230
+ pdf.fill_color "944747"
231
+ pdf.stroke_color "693636"
232
+ pdf.fill_and_stroke_polygon([doc_width - x + 39, 70], [doc_width - x + 61, 70], [doc_width - x + 75, 56], [doc_width - x + 75, 34], [doc_width - x + 61, 20], [doc_width - x + 39, 20], [doc_width - x + 25, 34], [doc_width - x + 25, 56])
233
+ pdf.stroke_color "888888"
234
+ pdf.fill_color "666666"
235
+ pdf.text_box "Stop", :at => [(doc_width - x + 10), header_height], :width => 80, :height => 80, :align => :center, :valign => :bottom, :overflow => :shrink_to_fit
236
+
237
+ # Clear
238
+ x = 100
239
+ pdf.fill_color "eeeeee"
240
+ pdf.fill_and_stroke_rounded_rectangle [(doc_width - x), header_height], 100, header_height, default_radius
241
+ pdf.stroke_color "666666"
242
+ pdf.fill_color "888888"
243
+ pdf.fill_and_stroke_polygon([doc_width - x + 10, 45], [doc_width - x + 35, 70], [doc_width - x + 90, 70], [doc_width - x + 90, 20], [doc_width - x + 35, 20])
244
+ pdf.stroke_color "888888"
245
+ pdf.fill_color "666666"
246
+ pdf.text_box "Clear", :at => [(doc_width - x + 10), header_height], :width => 80, :height => 80, :align => :center, :valign => :bottom, :overflow => :shrink_to_fit
247
+ end
248
+ end
249
+ # footer
250
+ pdf.fill_color "bbbbbb"
251
+ obj['name'] = nil if obj['name'] == 'Unnamed Board'
252
+ if OBF::PDF.footer_text || obj['name']
253
+ text = [obj['name'], OBF::PDF.footer_text].compact.join(', ')
254
+ offset = options['pages'] ? 400 : 300
255
+ pdf.formatted_text_box [{:text => text, :link => OBF::PDF.footer_url}], :at => [doc_width - offset, text_height], :width => 300, :height => text_height, :align => :right, :valign => :center, :overflow => :shrink_to_fit
256
+ end
257
+ pdf.fill_color "000000"
258
+ if options['pages'] && page_num != 0
259
+ text_options = {:text => page_num.to_s}
260
+ text_options[:anchor] = "page1" if options['links']
261
+ pdf.formatted_text_box [text_options], :at => [doc_width - 100, text_height], :width => 100, :height => text_height, :align => :right, :valign => :center, :overflow => :shrink_to_fit
249
262
  end
250
263
  end
251
264
 
@@ -413,22 +426,6 @@ module OBF::PDF
413
426
  end
414
427
  end
415
428
  end
416
-
417
- # footer
418
- pdf.fill_color "bbbbbb"
419
- obj['name'] = nil if obj['name'] == 'Unnamed Board'
420
- pdf.font('Arial')
421
- if OBF::PDF.footer_text || obj['name']
422
- text = [obj['name'], OBF::PDF.footer_text].compact.join(', ')
423
- offset = options['pages'] ? 400 : 300
424
- pdf.formatted_text_box [{:text => text, :link => OBF::PDF.footer_url}], :at => [doc_width - offset, text_height], :width => 300, :height => text_height, :align => :right, :valign => :center, :overflow => :shrink_to_fit
425
- end
426
- pdf.fill_color "000000"
427
- if options['pages'] && page_num != 0
428
- text_options = {:text => page_num.to_s}
429
- text_options[:anchor] = "page1" if options['links']
430
- pdf.formatted_text_box [text_options], :at => [doc_width - 100, text_height], :width => 100, :height => text_height, :align => :right, :valign => :center, :overflow => :shrink_to_fit
431
- end
432
429
  end
433
430
  end
434
431
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.8.32
4
+ version: 0.9.8.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Whitmer