eideticpdf 0.9.9 → 1.0.0
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.
- data/lib/epdfafm.rb +14 -6
- data/lib/epdfk.rb +1 -1
- data/lib/epdfpw.rb +5 -1
- data/lib/epdfs.rb +13 -1
- data/test/test.rb +2 -0
- data/test/test_epdfafm.rb +5 -1
- metadata +6 -6
data/lib/epdfafm.rb
CHANGED
|
@@ -15,12 +15,20 @@ module EideticPDF
|
|
|
15
15
|
FontPath = [File.join(File.dirname(__FILE__), '..', 'fonts')]
|
|
16
16
|
|
|
17
17
|
class Codepoints
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
if ''.respond_to?(:encoding) # Ruby 1.9+
|
|
19
|
+
def self.for_encoding(encoding)
|
|
20
|
+
encoding = 'CP1252' if encoding == 'WinAnsiEncoding'
|
|
21
|
+
@@codepoints_by_encoding ||= {}
|
|
22
|
+
@@codepoints_by_encoding[encoding] ||= (0..255).inject('') { |m, n| m << n.chr }.encode('UCS-2BE', encoding, :undef => :replace).unpack('n*')
|
|
23
|
+
end
|
|
24
|
+
else
|
|
25
|
+
def self.for_encoding(encoding)
|
|
26
|
+
require 'iconv'
|
|
27
|
+
encoding = 'CP1252' if encoding == 'WinAnsiEncoding'
|
|
28
|
+
@@codepoints_by_encoding ||= {}
|
|
29
|
+
@@codepoints_by_encoding[encoding] ||= Iconv.open("UCS-2BE//IGNORE", encoding) do |ic|
|
|
30
|
+
(0..255).map { |c| ic.iconv(c.chr) }.map { |s| s.unpack('n') }.map { |a| a.first }
|
|
31
|
+
end
|
|
24
32
|
end
|
|
25
33
|
end
|
|
26
34
|
end
|
data/lib/epdfk.rb
CHANGED
data/lib/epdfpw.rb
CHANGED
|
@@ -1542,7 +1542,11 @@ module EideticPDF
|
|
|
1542
1542
|
end
|
|
1543
1543
|
end
|
|
1544
1544
|
unless text_encoding.nil? or (font.encoding == 'StandardEncoding') or (font.encoding == text_encoding)
|
|
1545
|
-
|
|
1545
|
+
if ''.respond_to?(:encoding) # Ruby 1.9+
|
|
1546
|
+
@ic = FakeIconv.new(iconv_encoding(font.encoding), iconv_encoding(text_encoding))
|
|
1547
|
+
else
|
|
1548
|
+
@ic = Iconv.new(iconv_encoding(font.encoding)+'//IGNORE', iconv_encoding(text_encoding))
|
|
1549
|
+
end
|
|
1546
1550
|
end
|
|
1547
1551
|
font.widths, font.ascent, font.descent = metrics.widths, metrics.ascent, metrics.descent
|
|
1548
1552
|
font.height = font.ascent + font.descent.abs
|
data/lib/epdfs.rb
CHANGED
|
@@ -76,7 +76,9 @@ module EideticPDF
|
|
|
76
76
|
module JpegInfo # :nodoc:
|
|
77
77
|
def jpeg?(image)
|
|
78
78
|
# image[0, 2] == "\xFF\xD8"
|
|
79
|
-
image[0, 2].hash == "\xFF\xD8".hash
|
|
79
|
+
# image[0, 2].hash == "\xFF\xD8".hash
|
|
80
|
+
# String#bytes requires Ruby 1.8.7+
|
|
81
|
+
image.bytes.first(2) == [0xFF, 0xD8]
|
|
80
82
|
end
|
|
81
83
|
|
|
82
84
|
def jpeg_dimensions(image)
|
|
@@ -98,4 +100,14 @@ module EideticPDF
|
|
|
98
100
|
|
|
99
101
|
module_function :jpeg?, :jpeg_dimensions
|
|
100
102
|
end
|
|
103
|
+
|
|
104
|
+
class FakeIconv
|
|
105
|
+
def initialize(to, from)
|
|
106
|
+
@to, @from = to, from
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def iconv(text)
|
|
110
|
+
text.encode(@to, @from, :invalid => :replace, :undef => :replace)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
101
113
|
end
|
data/test/test.rb
CHANGED
|
@@ -569,6 +569,8 @@ def text_encodings(w)
|
|
|
569
569
|
['Symbol', 'StandardEncoding'],
|
|
570
570
|
['ZapfDingbats', 'StandardEncoding']
|
|
571
571
|
]
|
|
572
|
+
fonts.delete(['Helvetica', 'ISO-8859-16']) if ''.respond_to?(:encoding) # Ruby 1.9+
|
|
573
|
+
fonts.delete(['Courier', 'Macintosh']) if ''.respond_to?(:encoding) # Ruby 1.9+
|
|
572
574
|
fonts.each do |name, encoding|
|
|
573
575
|
w.page(:units => :in, :margins => 0.5) do |p|
|
|
574
576
|
p.print "#{name} - #{encoding}", :underline => true
|
data/test/test_epdfafm.rb
CHANGED
|
@@ -197,6 +197,10 @@ class AdobeFontMetricsTestCases < Test::Unit::TestCase
|
|
|
197
197
|
assert_equal(278, fm.widths[32])
|
|
198
198
|
assert_equal(722, fm.widths[65])
|
|
199
199
|
assert_not_nil(fm.differences)
|
|
200
|
-
|
|
200
|
+
if ''.respond_to?(:encoding) # Ruby 1.9+
|
|
201
|
+
assert_equal(83, fm.differences.values.size)
|
|
202
|
+
else
|
|
203
|
+
assert_equal(77, fm.differences.values.size)
|
|
204
|
+
end
|
|
201
205
|
end
|
|
202
206
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: eideticpdf
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 23
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
|
+
- 1
|
|
7
8
|
- 0
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
version: 0.9.9
|
|
9
|
+
- 0
|
|
10
|
+
version: 1.0.0
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Brent Rowland
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2013-03-
|
|
18
|
+
date: 2013-03-27 00:00:00 -07:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies: []
|
|
21
21
|
|
|
@@ -237,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
237
237
|
- 0
|
|
238
238
|
version: "0"
|
|
239
239
|
requirements:
|
|
240
|
-
- Ruby 1.8.
|
|
240
|
+
- Ruby 1.8.7 or 1.9.3
|
|
241
241
|
rubyforge_project: eideticpdf
|
|
242
242
|
rubygems_version: 1.4.2
|
|
243
243
|
signing_key:
|