prawn 0.13.0 → 0.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/README.md +1 -0
- data/data/images/16bit.alpha +0 -0
- data/data/images/16bit.color +0 -0
- data/data/images/dice.alpha +0 -0
- data/data/images/dice.color +0 -0
- data/data/images/page_white_text.alpha +0 -0
- data/data/images/page_white_text.color +0 -0
- data/lib/pdf/core/object_store.rb +3 -15
- data/lib/pdf/core/pdf_object.rb +8 -33
- data/lib/prawn.rb +1 -2
- data/lib/prawn/document.rb +2 -3
- data/lib/prawn/encoding.rb +1 -2
- data/lib/prawn/font/afm.rb +70 -29
- data/lib/prawn/font/ttf.rb +10 -2
- data/lib/prawn/images/jpg.rb +9 -10
- data/lib/prawn/images/png.rb +46 -118
- data/lib/prawn/text/formatted/arranger.rb +1 -5
- data/lib/prawn/text/formatted/box.rb +1 -1
- data/lib/prawn/text/formatted/fragment.rb +5 -11
- data/lib/prawn/text/formatted/line_wrap.rb +4 -25
- data/lib/prawn/text/formatted/wrap.rb +1 -4
- data/manual/example_file.rb +2 -7
- data/manual/manual/manual.rb +1 -1
- data/prawn.gemspec +0 -1
- data/spec/document_spec.rb +5 -7
- data/spec/extensions/encoding_helpers.rb +2 -3
- data/spec/filters_spec.rb +1 -1
- data/spec/font_spec.rb +3 -2
- data/spec/formatted_text_box_spec.rb +14 -25
- data/spec/images_spec.rb +2 -6
- data/spec/line_wrap_spec.rb +2 -2
- data/spec/outline_spec.rb +10 -10
- data/spec/png_spec.rb +9 -12
- data/spec/text_at_spec.rb +11 -26
- data/spec/text_box_spec.rb +6 -2
- data/spec/text_spec.rb +13 -27
- metadata +5 -20
- data/data/images/16bit.dat +0 -0
- data/data/images/dice.dat +0 -0
- data/data/images/page_white_text.dat +0 -0
- data/lib/prawn/compatibility.rb +0 -91
data/spec/text_box_spec.rb
CHANGED
@@ -992,7 +992,7 @@ describe "Text::Box wrapping" do
|
|
992
992
|
|
993
993
|
expected = "©" * 25 + "\n" + "©" * 5
|
994
994
|
@pdf.font.normalize_encoding!(expected)
|
995
|
-
expected = expected.force_encoding(
|
995
|
+
expected = expected.force_encoding(Encoding::UTF_8)
|
996
996
|
text_box.text.should == expected
|
997
997
|
end
|
998
998
|
|
@@ -1009,7 +1009,7 @@ describe "Text::Box wrapping" do
|
|
1009
1009
|
text_box.render
|
1010
1010
|
results_without_accent = text_box.text
|
1011
1011
|
|
1012
|
-
results_with_accent.
|
1012
|
+
first_line(results_with_accent).length.should == first_line(results_without_accent).length
|
1013
1013
|
end
|
1014
1014
|
end
|
1015
1015
|
|
@@ -1028,3 +1028,7 @@ end
|
|
1028
1028
|
def reduce_precision(float)
|
1029
1029
|
("%.5f" % float).to_f
|
1030
1030
|
end
|
1031
|
+
|
1032
|
+
def first_line(str)
|
1033
|
+
str.each_line { |line| return line }
|
1034
|
+
end
|
data/spec/text_spec.rb
CHANGED
@@ -313,34 +313,20 @@ describe "#text" do
|
|
313
313
|
pages[1][:strings].should == [str]
|
314
314
|
end
|
315
315
|
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
Prawn::Errors::IncompatibleStringEncoding)
|
323
|
-
end
|
324
|
-
it "should_not raise_error an exception when a shift-jis string is rendered" do
|
325
|
-
datafile = "#{Prawn::DATADIR}/shift_jis_text.txt"
|
326
|
-
sjis_str = File.open(datafile, "r:shift_jis") { |f| f.gets }
|
327
|
-
@pdf.font("#{Prawn::DATADIR}/fonts/gkai00mp.ttf")
|
316
|
+
it "should raise_error an exception when a utf-8 incompatible string is rendered" do
|
317
|
+
str = "Blah \xDD"
|
318
|
+
str.force_encoding(Encoding::ASCII_8BIT)
|
319
|
+
lambda { @pdf.text str }.should raise_error(
|
320
|
+
Prawn::Errors::IncompatibleStringEncoding)
|
321
|
+
end
|
328
322
|
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
lambda { @pdf.text str }.should raise_error(
|
337
|
-
Prawn::Errors::IncompatibleStringEncoding)
|
338
|
-
end
|
339
|
-
it "should raise_error an exception when a shift-jis string is rendered" do
|
340
|
-
sjis_str = File.read("#{Prawn::DATADIR}/shift_jis_text.txt")
|
341
|
-
lambda { @pdf.text sjis_str }.should raise_error(
|
342
|
-
Prawn::Errors::IncompatibleStringEncoding)
|
343
|
-
end
|
323
|
+
it "should_not raise_error an exception when a shift-jis string is rendered" do
|
324
|
+
datafile = "#{Prawn::DATADIR}/shift_jis_text.txt"
|
325
|
+
sjis_str = File.open(datafile, "r:shift_jis") { |f| f.gets }
|
326
|
+
@pdf.font("#{Prawn::DATADIR}/fonts/gkai00mp.ttf")
|
327
|
+
|
328
|
+
# Expect that the call to text will not raise an encoding error
|
329
|
+
@pdf.text(sjis_str)
|
344
330
|
end
|
345
331
|
|
346
332
|
it "should call move_past_bottom when printing more text than can fit" +
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prawn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregory Brown
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2013-12-
|
15
|
+
date: 2013-12-23 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: pdf-reader
|
@@ -56,20 +56,6 @@ dependencies:
|
|
56
56
|
- - '>='
|
57
57
|
- !ruby/object:Gem::Version
|
58
58
|
version: '0'
|
59
|
-
- !ruby/object:Gem::Dependency
|
60
|
-
name: afm
|
61
|
-
requirement: !ruby/object:Gem::Requirement
|
62
|
-
requirements:
|
63
|
-
- - '>='
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version: '0'
|
66
|
-
type: :runtime
|
67
|
-
prerelease: false
|
68
|
-
version_requirements: !ruby/object:Gem::Requirement
|
69
|
-
requirements:
|
70
|
-
- - '>='
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version: '0'
|
73
59
|
- !ruby/object:Gem::Dependency
|
74
60
|
name: pdf-inspector
|
75
61
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,7 +133,6 @@ files:
|
|
147
133
|
- lib/pdf/core/stream.rb
|
148
134
|
- lib/pdf/core/text.rb
|
149
135
|
- lib/pdf/core.rb
|
150
|
-
- lib/prawn/compatibility.rb
|
151
136
|
- lib/prawn/document/bounding_box.rb
|
152
137
|
- lib/prawn/document/column_box.rb
|
153
138
|
- lib/prawn/document/graphics_state.rb
|
@@ -375,13 +360,13 @@ files:
|
|
375
360
|
- manual/text/win_ansi_charset.rb
|
376
361
|
- data/encodings/win_ansi.txt
|
377
362
|
- data/images/16bit.alpha
|
378
|
-
- data/images/16bit.
|
363
|
+
- data/images/16bit.color
|
379
364
|
- data/images/16bit.png
|
380
365
|
- data/images/arrow.png
|
381
366
|
- data/images/arrow2.png
|
382
367
|
- data/images/barcode_issue.png
|
383
368
|
- data/images/dice.alpha
|
384
|
-
- data/images/dice.
|
369
|
+
- data/images/dice.color
|
385
370
|
- data/images/dice.png
|
386
371
|
- data/images/dice_interlaced.png
|
387
372
|
- data/images/fractal.jpg
|
@@ -389,7 +374,7 @@ files:
|
|
389
374
|
- data/images/indexed_color.png
|
390
375
|
- data/images/letterhead.jpg
|
391
376
|
- data/images/page_white_text.alpha
|
392
|
-
- data/images/page_white_text.
|
377
|
+
- data/images/page_white_text.color
|
393
378
|
- data/images/page_white_text.png
|
394
379
|
- data/images/pigs.jpg
|
395
380
|
- data/images/prawn.png
|
data/data/images/16bit.dat
DELETED
Binary file
|
data/data/images/dice.dat
DELETED
Binary file
|
Binary file
|
data/lib/prawn/compatibility.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
#
|
3
|
-
# Compatibility layer to smooth over differences between Ruby implementations
|
4
|
-
# The oldest version of Ruby which is supported is MRI 1.8.7
|
5
|
-
# Ideally, all version-specific or implementation-specific code should be
|
6
|
-
# kept in this file (but that ideal has not been attained yet)
|
7
|
-
|
8
|
-
class String #:nodoc:
|
9
|
-
def first_line
|
10
|
-
self.each_line { |line| return line }
|
11
|
-
end
|
12
|
-
|
13
|
-
unless "".respond_to?(:codepoints)
|
14
|
-
def codepoints(&block)
|
15
|
-
if block_given?
|
16
|
-
unpack("U*").each(&block)
|
17
|
-
else
|
18
|
-
unpack("U*")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def each_codepoint(&block)
|
23
|
-
unpack("U*").each(&block)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
if "".respond_to?(:encode)
|
28
|
-
def normalize_to_utf8
|
29
|
-
begin
|
30
|
-
encode(Encoding::UTF_8)
|
31
|
-
rescue
|
32
|
-
raise Prawn::Errors::IncompatibleStringEncoding, "Encoding " +
|
33
|
-
"#{text.encoding} can not be transparently converted to UTF-8. " +
|
34
|
-
"Please ensure the encoding of the string you are attempting " +
|
35
|
-
"to use is set correctly"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
alias :unicode_characters :each_char
|
39
|
-
alias :unicode_length :length
|
40
|
-
|
41
|
-
else
|
42
|
-
def normalize_to_utf8
|
43
|
-
begin
|
44
|
-
# use unpack as a hackish way to verify the string is valid utf-8
|
45
|
-
unpack("U*")
|
46
|
-
return dup
|
47
|
-
rescue
|
48
|
-
raise Prawn::Errors::IncompatibleStringEncoding, "The string you " +
|
49
|
-
"are attempting to render is not encoded in valid UTF-8."
|
50
|
-
end
|
51
|
-
end
|
52
|
-
def unicode_characters
|
53
|
-
if block_given?
|
54
|
-
unpack("U*").each { |c| yield [c].pack("U") }
|
55
|
-
else
|
56
|
-
unpack("U*").map { |c| [c].pack("U") }
|
57
|
-
end
|
58
|
-
end
|
59
|
-
def unicode_length
|
60
|
-
unpack("U*").length
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
unless File.respond_to?(:binread)
|
66
|
-
def File.binread(file) #:nodoc:
|
67
|
-
File.open(file,"rb") { |f| f.read }
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
if RUBY_VERSION < "1.9"
|
72
|
-
|
73
|
-
def ruby_18 #:nodoc:
|
74
|
-
yield
|
75
|
-
end
|
76
|
-
|
77
|
-
def ruby_19 #:nodoc:
|
78
|
-
false
|
79
|
-
end
|
80
|
-
|
81
|
-
else
|
82
|
-
|
83
|
-
def ruby_18 #:nodoc:
|
84
|
-
false
|
85
|
-
end
|
86
|
-
|
87
|
-
def ruby_19 #:nodoc:
|
88
|
-
yield
|
89
|
-
end
|
90
|
-
|
91
|
-
end
|