prawn 0.13.0 → 0.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -1
  3. data/README.md +1 -0
  4. data/data/images/16bit.alpha +0 -0
  5. data/data/images/16bit.color +0 -0
  6. data/data/images/dice.alpha +0 -0
  7. data/data/images/dice.color +0 -0
  8. data/data/images/page_white_text.alpha +0 -0
  9. data/data/images/page_white_text.color +0 -0
  10. data/lib/pdf/core/object_store.rb +3 -15
  11. data/lib/pdf/core/pdf_object.rb +8 -33
  12. data/lib/prawn.rb +1 -2
  13. data/lib/prawn/document.rb +2 -3
  14. data/lib/prawn/encoding.rb +1 -2
  15. data/lib/prawn/font/afm.rb +70 -29
  16. data/lib/prawn/font/ttf.rb +10 -2
  17. data/lib/prawn/images/jpg.rb +9 -10
  18. data/lib/prawn/images/png.rb +46 -118
  19. data/lib/prawn/text/formatted/arranger.rb +1 -5
  20. data/lib/prawn/text/formatted/box.rb +1 -1
  21. data/lib/prawn/text/formatted/fragment.rb +5 -11
  22. data/lib/prawn/text/formatted/line_wrap.rb +4 -25
  23. data/lib/prawn/text/formatted/wrap.rb +1 -4
  24. data/manual/example_file.rb +2 -7
  25. data/manual/manual/manual.rb +1 -1
  26. data/prawn.gemspec +0 -1
  27. data/spec/document_spec.rb +5 -7
  28. data/spec/extensions/encoding_helpers.rb +2 -3
  29. data/spec/filters_spec.rb +1 -1
  30. data/spec/font_spec.rb +3 -2
  31. data/spec/formatted_text_box_spec.rb +14 -25
  32. data/spec/images_spec.rb +2 -6
  33. data/spec/line_wrap_spec.rb +2 -2
  34. data/spec/outline_spec.rb +10 -10
  35. data/spec/png_spec.rb +9 -12
  36. data/spec/text_at_spec.rb +11 -26
  37. data/spec/text_box_spec.rb +6 -2
  38. data/spec/text_spec.rb +13 -27
  39. metadata +5 -20
  40. data/data/images/16bit.dat +0 -0
  41. data/data/images/dice.dat +0 -0
  42. data/data/images/page_white_text.dat +0 -0
  43. data/lib/prawn/compatibility.rb +0 -91
@@ -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("utf-8") if expected.respond_to?(: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.first_line.length.should == results_without_accent.first_line.length
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
@@ -313,34 +313,20 @@ describe "#text" do
313
313
  pages[1][:strings].should == [str]
314
314
  end
315
315
 
316
- if "spec".respond_to?(:encode!)
317
- # Handle non utf-8 string encodings in a sane way on M17N aware VMs
318
- it "should raise_error an exception when a utf-8 incompatible string is rendered" do
319
- str = "Blah \xDD"
320
- str.force_encoding("ASCII-8BIT")
321
- lambda { @pdf.text str }.should raise_error(
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
- # Expect that the call to text will not raise an encoding error
330
- @pdf.text(sjis_str)
331
- end
332
- else
333
- # Handle non utf-8 string encodings in a sane way on non-M17N aware VMs
334
- it "should raise_error an exception when a corrupt utf-8 string is rendered" do
335
- str = "Blah \xDD"
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.0
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-16 00:00:00.000000000 Z
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.dat
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.dat
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.dat
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
Binary file
Binary file
@@ -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