obf 0.9.8.34 → 0.9.8.35

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 +29 -24
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e3ce80422b984c3d79960b1caa2f99f3d426239c85b3645d08dda57d42c3bbb
4
- data.tar.gz: 6df4cb745a36781f4a41c90473c5c2abdc1b7889cd6f1af58d02c00768802daf
3
+ metadata.gz: 3274b731d612ffd8a4ce7b39c4f5c24693c15d62ef2e22126df98ce428e8d0ae
4
+ data.tar.gz: e7956b737623c1f5b8471c2fc3465478aebb6dd60b157bae69c7ffa9935da140
5
5
  SHA512:
6
- metadata.gz: 71470ef7e5f775ebd2236988fe0a4ed8563d12c4bc1ea81965022bc78c8644337f561b942e7cd7810712a2af0436f77d4284c5cf42444dae97996fcc4414cfa1
7
- data.tar.gz: a8fc6db87013cda7da8ac5362c7b25b03b92400eec81f6b7d794a5c12990afcacc4196ad640fec2be41e900902cb40d48ec75ada67a4bae5099daf52dcf062c6
6
+ metadata.gz: fc988d4f31a72cf4e64db2256e6610dfbfbf397937f65822689cb89751a80475de8ff4e93cface38edab88821f077a79c5f9352de5c7a233f6d5e4e65a62bd59
7
+ data.tar.gz: d93c9e458967e25de8b6d79feeffac73cef7f4ef674f57b15432aa3f66312017aa932c921c2afeb770f352557f382ef16409b6f871d2feae021232ada4d650bd
@@ -31,6 +31,32 @@ module OBF::PDF
31
31
  build_pdf(obj, dest_path, zipper, opts)
32
32
  return dest_path
33
33
  end
34
+
35
+ def self.load_fonts(pdf, opts)
36
+ # remember: https://www.alphabet-type.com/tools/charset-checker/
37
+ pdf.font_families.update('THFahKwangBold' => {
38
+ normal: File.expand_path('../../THFahKwangBold.ttf', __FILE__)
39
+ })
40
+ pdf.font_families.update('MiedingerBook' => {
41
+ normal: File.expand_path('../../MiedingerBook.ttf', __FILE__)
42
+ })
43
+ pdf.font_families.update('Arial' => {
44
+ normal: File.expand_path('../../Arial.ttf', __FILE__)
45
+ })
46
+ pdf.font_families.update('TimesNewRoman' => {
47
+ normal: File.expand_path('../../TimesNewRoman.ttf', __FILE__)
48
+ })
49
+ default_font = 'TimesNewRoman'
50
+ if opts['font'] && !opts['font'].match(/TimesNewRoman/) && File.exists?(opts['font'])
51
+ pdf.font_families.update('DocDefault' => {
52
+ normal: opts['font']
53
+ })
54
+ default_font = 'DocDefault'
55
+ end
56
+ pdf.fallback_fonts = ['TimesNewRoman', 'THFahKwangBold', 'MiedingerBook', 'Helvetica']
57
+ pdf.font(default_font)
58
+ default_font
59
+ end
34
60
 
35
61
  def self.build_pdf(obj, dest_path, zipper, opts={})
36
62
  OBF::Utils.as_progress_percent(0, 1.0) do
@@ -43,32 +69,11 @@ module OBF::PDF
43
69
  }
44
70
  }
45
71
  pdf = Prawn::Document.new(doc_opts)
46
- # remember: https://www.alphabet-type.com/tools/charset-checker/
47
- pdf.font_families.update('THFahKwangBold' => {
48
- normal: File.expand_path('../../THFahKwangBold.ttf', __FILE__)
49
- })
50
- pdf.font_families.update('MiedingerBook' => {
51
- normal: File.expand_path('../../MiedingerBook.ttf', __FILE__)
52
- })
53
- pdf.font_families.update('Arial' => {
54
- normal: File.expand_path('../../Arial.ttf', __FILE__)
55
- })
56
- pdf.font_families.update('TimesNewRoman' => {
57
- normal: File.expand_path('../../TimesNewRoman.ttf', __FILE__)
58
- })
59
- default_font = 'TimesNewRoman'
60
- if opts['font'] && !opts['font'].match(/TimesNewRoman/) && File.exists?(opts['font'])
61
- pdf.font_families.update('DocDefault' => {
62
- normal: opts['font']
63
- })
64
- default_font = 'DocDefault'
65
- end
66
- pdf.fallback_fonts = ['TimesNewRoman', 'THFahKwangBold', 'MiedingerBook', 'Helvetica']
67
- pdf.font(default_font)
72
+ default_font = load_fonts(pdf, opts)
68
73
 
69
74
  multi_render_paths = []
70
75
  if obj['boards']
71
- multi_render = obj['boards'].length > 20
76
+ multi_render = obj['boards'].length > 20 && `which gs`.length > 0
72
77
  obj['backlinks'] = {}
73
78
  if obj['pages']
74
79
  obj['boards'].each do |board|
@@ -89,10 +94,10 @@ module OBF::PDF
89
94
  OBF::Utils.as_progress_percent(pre, post) do
90
95
  # if more than 20 pages, build each page individually
91
96
  # and combine them afterwards
92
-
93
97
  if multi_render
94
98
  path = OBF::Utils.temp_path("stash-#{idx}.pdf")
95
99
  pdf = Prawn::Document.new(doc_opts)
100
+ load_fonts(pdf, opts)
96
101
  else
97
102
  pdf.start_new_page unless idx == 0
98
103
  end
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.34
4
+ version: 0.9.8.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Whitmer