prawn-graph 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (314) hide show
  1. data/README.markdown +51 -2
  2. data/Rakefile +16 -2
  3. data/lib/prawn/graph.rb +1 -4
  4. data/lib/prawn/graph/bar.rb +39 -143
  5. data/lib/prawn/graph/base.rb +207 -0
  6. data/lib/prawn/graph/errors.rb +2 -1
  7. data/lib/prawn/graph/grid.rb +5 -0
  8. data/lib/prawn/graph/line.rb +40 -1
  9. data/lib/prawn/graph/theme.rb +24 -0
  10. metadata +19 -312
  11. data/vendor/prawn-core/COPYING +0 -340
  12. data/vendor/prawn-core/HACKING +0 -46
  13. data/vendor/prawn-core/LICENSE +0 -56
  14. data/vendor/prawn-core/README +0 -138
  15. data/vendor/prawn-core/Rakefile +0 -75
  16. data/vendor/prawn-core/bench/afm_text_bench.rb +0 -18
  17. data/vendor/prawn-core/bench/png_type_6.rb +0 -15
  18. data/vendor/prawn-core/bench/ttf_text_bench.rb +0 -19
  19. data/vendor/prawn-core/bugs/indentation_across_pagebreaks.rb +0 -15
  20. data/vendor/prawn-core/bugs/resolved/canvas_sets_y_to_0.rb +0 -15
  21. data/vendor/prawn-core/bugs/resolved/png_barcode_issue.rb +0 -11
  22. data/vendor/prawn-core/bugs/resolved/transaction_page_number_issue_79.rb +0 -21
  23. data/vendor/prawn-core/bugs/resolved/ttf_fails_in_transactions.rb +0 -24
  24. data/vendor/prawn-core/data/encodings/win_ansi.txt +0 -29
  25. data/vendor/prawn-core/data/fonts/Action Man.dfont +0 -0
  26. data/vendor/prawn-core/data/fonts/Activa.ttf +0 -0
  27. data/vendor/prawn-core/data/fonts/Chalkboard.ttf +0 -0
  28. data/vendor/prawn-core/data/fonts/Courier-Bold.afm +0 -342
  29. data/vendor/prawn-core/data/fonts/Courier-BoldOblique.afm +0 -342
  30. data/vendor/prawn-core/data/fonts/Courier-Oblique.afm +0 -342
  31. data/vendor/prawn-core/data/fonts/Courier.afm +0 -342
  32. data/vendor/prawn-core/data/fonts/DejaVuSans.ttf +0 -0
  33. data/vendor/prawn-core/data/fonts/Dustismo_Roman.ttf +0 -0
  34. data/vendor/prawn-core/data/fonts/Helvetica-Bold.afm +0 -2827
  35. data/vendor/prawn-core/data/fonts/Helvetica-BoldOblique.afm +0 -2827
  36. data/vendor/prawn-core/data/fonts/Helvetica-Oblique.afm +0 -3051
  37. data/vendor/prawn-core/data/fonts/Helvetica.afm +0 -3051
  38. data/vendor/prawn-core/data/fonts/MustRead.html +0 -19
  39. data/vendor/prawn-core/data/fonts/Symbol.afm +0 -213
  40. data/vendor/prawn-core/data/fonts/Times-Bold.afm +0 -2588
  41. data/vendor/prawn-core/data/fonts/Times-BoldItalic.afm +0 -2384
  42. data/vendor/prawn-core/data/fonts/Times-Italic.afm +0 -2667
  43. data/vendor/prawn-core/data/fonts/Times-Roman.afm +0 -2419
  44. data/vendor/prawn-core/data/fonts/ZapfDingbats.afm +0 -225
  45. data/vendor/prawn-core/data/fonts/comicsans.ttf +0 -0
  46. data/vendor/prawn-core/data/fonts/gkai00mp.ttf +0 -0
  47. data/vendor/prawn-core/data/images/16bit.alpha +0 -0
  48. data/vendor/prawn-core/data/images/16bit.dat +0 -0
  49. data/vendor/prawn-core/data/images/16bit.png +0 -0
  50. data/vendor/prawn-core/data/images/arrow.png +0 -0
  51. data/vendor/prawn-core/data/images/arrow2.png +0 -0
  52. data/vendor/prawn-core/data/images/barcode_issue.png +0 -0
  53. data/vendor/prawn-core/data/images/dice.alpha +0 -0
  54. data/vendor/prawn-core/data/images/dice.dat +0 -0
  55. data/vendor/prawn-core/data/images/dice.png +0 -0
  56. data/vendor/prawn-core/data/images/dice_interlaced.png +0 -0
  57. data/vendor/prawn-core/data/images/fractal.jpg +0 -0
  58. data/vendor/prawn-core/data/images/letterhead.jpg +0 -0
  59. data/vendor/prawn-core/data/images/page_white_text.alpha +0 -0
  60. data/vendor/prawn-core/data/images/page_white_text.dat +0 -0
  61. data/vendor/prawn-core/data/images/page_white_text.png +0 -0
  62. data/vendor/prawn-core/data/images/pigs.jpg +0 -0
  63. data/vendor/prawn-core/data/images/rails.dat +0 -0
  64. data/vendor/prawn-core/data/images/rails.png +0 -0
  65. data/vendor/prawn-core/data/images/ruport.png +0 -0
  66. data/vendor/prawn-core/data/images/ruport_data.dat +0 -0
  67. data/vendor/prawn-core/data/images/ruport_transparent.png +0 -0
  68. data/vendor/prawn-core/data/images/ruport_type0.png +0 -0
  69. data/vendor/prawn-core/data/images/stef.jpg +0 -0
  70. data/vendor/prawn-core/data/images/tru256.bmp +0 -0
  71. data/vendor/prawn-core/data/images/web-links.dat +0 -1
  72. data/vendor/prawn-core/data/images/web-links.png +0 -0
  73. data/vendor/prawn-core/data/shift_jis_text.txt +0 -1
  74. data/vendor/prawn-core/examples/bounding_box/bounding_boxes.rb +0 -43
  75. data/vendor/prawn-core/examples/bounding_box/indentation.rb +0 -34
  76. data/vendor/prawn-core/examples/bounding_box/russian_boxes.rb +0 -36
  77. data/vendor/prawn-core/examples/bounding_box/stretched_nesting.rb +0 -67
  78. data/vendor/prawn-core/examples/column_box/column_box_example.rb +0 -43
  79. data/vendor/prawn-core/examples/example_helper.rb +0 -3
  80. data/vendor/prawn-core/examples/general/background.rb +0 -23
  81. data/vendor/prawn-core/examples/general/canvas.rb +0 -15
  82. data/vendor/prawn-core/examples/general/context_sensitive_headers.rb +0 -37
  83. data/vendor/prawn-core/examples/general/float.rb +0 -11
  84. data/vendor/prawn-core/examples/general/margin.rb +0 -36
  85. data/vendor/prawn-core/examples/general/measurement_units.rb +0 -51
  86. data/vendor/prawn-core/examples/general/metadata-info.rb +0 -16
  87. data/vendor/prawn-core/examples/general/multi_page_layout.rb +0 -18
  88. data/vendor/prawn-core/examples/general/outlines.rb +0 -50
  89. data/vendor/prawn-core/examples/general/page_geometry.rb +0 -31
  90. data/vendor/prawn-core/examples/general/page_numbering.rb +0 -15
  91. data/vendor/prawn-core/examples/general/repeaters.rb +0 -47
  92. data/vendor/prawn-core/examples/general/stamp.rb +0 -41
  93. data/vendor/prawn-core/examples/graphics/basic_images.rb +0 -23
  94. data/vendor/prawn-core/examples/graphics/cmyk.rb +0 -12
  95. data/vendor/prawn-core/examples/graphics/curves.rb +0 -11
  96. data/vendor/prawn-core/examples/graphics/hexagon.rb +0 -13
  97. data/vendor/prawn-core/examples/graphics/image_fit.rb +0 -15
  98. data/vendor/prawn-core/examples/graphics/image_flow.rb +0 -37
  99. data/vendor/prawn-core/examples/graphics/image_position.rb +0 -17
  100. data/vendor/prawn-core/examples/graphics/line.rb +0 -32
  101. data/vendor/prawn-core/examples/graphics/png_types.rb +0 -22
  102. data/vendor/prawn-core/examples/graphics/polygons.rb +0 -16
  103. data/vendor/prawn-core/examples/graphics/remote_images.rb +0 -12
  104. data/vendor/prawn-core/examples/graphics/rounded_polygons.rb +0 -19
  105. data/vendor/prawn-core/examples/graphics/rounded_rectangle.rb +0 -20
  106. data/vendor/prawn-core/examples/graphics/ruport_style_helpers.rb +0 -19
  107. data/vendor/prawn-core/examples/graphics/stroke_bounds.rb +0 -20
  108. data/vendor/prawn-core/examples/graphics/stroke_cap_and_join.rb +0 -45
  109. data/vendor/prawn-core/examples/graphics/stroke_dash.rb +0 -42
  110. data/vendor/prawn-core/examples/graphics/transformations.rb +0 -52
  111. data/vendor/prawn-core/examples/graphics/transparency.rb +0 -26
  112. data/vendor/prawn-core/examples/m17n/chinese_text_wrapping.rb +0 -17
  113. data/vendor/prawn-core/examples/m17n/euro.rb +0 -15
  114. data/vendor/prawn-core/examples/m17n/sjis.rb +0 -28
  115. data/vendor/prawn-core/examples/m17n/utf8.rb +0 -13
  116. data/vendor/prawn-core/examples/m17n/win_ansi_charset.rb +0 -54
  117. data/vendor/prawn-core/examples/text/alignment.rb +0 -18
  118. data/vendor/prawn-core/examples/text/dfont.rb +0 -48
  119. data/vendor/prawn-core/examples/text/family_based_styling.rb +0 -24
  120. data/vendor/prawn-core/examples/text/font_calculations.rb +0 -91
  121. data/vendor/prawn-core/examples/text/font_size.rb +0 -33
  122. data/vendor/prawn-core/examples/text/indent_paragraphs.rb +0 -18
  123. data/vendor/prawn-core/examples/text/kerning.rb +0 -30
  124. data/vendor/prawn-core/examples/text/rotated.rb +0 -98
  125. data/vendor/prawn-core/examples/text/simple_text.rb +0 -17
  126. data/vendor/prawn-core/examples/text/simple_text_ttf.rb +0 -17
  127. data/vendor/prawn-core/examples/text/span.rb +0 -29
  128. data/vendor/prawn-core/examples/text/text_box.rb +0 -88
  129. data/vendor/prawn-core/examples/text/text_box_returning_excess.rb +0 -51
  130. data/vendor/prawn-core/examples/text/text_flow.rb +0 -67
  131. data/vendor/prawn-core/lib/prawn/byte_string.rb +0 -7
  132. data/vendor/prawn-core/lib/prawn/compatibility.rb +0 -51
  133. data/vendor/prawn-core/lib/prawn/core.rb +0 -87
  134. data/vendor/prawn-core/lib/prawn/core/page.rb +0 -88
  135. data/vendor/prawn-core/lib/prawn/core/text.rb +0 -65
  136. data/vendor/prawn-core/lib/prawn/document.rb +0 -596
  137. data/vendor/prawn-core/lib/prawn/document/annotations.rb +0 -65
  138. data/vendor/prawn-core/lib/prawn/document/bounding_box.rb +0 -402
  139. data/vendor/prawn-core/lib/prawn/document/column_box.rb +0 -113
  140. data/vendor/prawn-core/lib/prawn/document/destinations.rb +0 -92
  141. data/vendor/prawn-core/lib/prawn/document/graphics_state.rb +0 -49
  142. data/vendor/prawn-core/lib/prawn/document/internals.rb +0 -153
  143. data/vendor/prawn-core/lib/prawn/document/page_geometry.rb +0 -136
  144. data/vendor/prawn-core/lib/prawn/document/snapshot.rb +0 -80
  145. data/vendor/prawn-core/lib/prawn/document/span.rb +0 -55
  146. data/vendor/prawn-core/lib/prawn/encoding.rb +0 -121
  147. data/vendor/prawn-core/lib/prawn/errors.rb +0 -83
  148. data/vendor/prawn-core/lib/prawn/font.rb +0 -329
  149. data/vendor/prawn-core/lib/prawn/font/afm.rb +0 -217
  150. data/vendor/prawn-core/lib/prawn/font/dfont.rb +0 -34
  151. data/vendor/prawn-core/lib/prawn/font/ttf.rb +0 -341
  152. data/vendor/prawn-core/lib/prawn/graphics.rb +0 -321
  153. data/vendor/prawn-core/lib/prawn/graphics/cap_style.rb +0 -38
  154. data/vendor/prawn-core/lib/prawn/graphics/color.rb +0 -205
  155. data/vendor/prawn-core/lib/prawn/graphics/dash.rb +0 -71
  156. data/vendor/prawn-core/lib/prawn/graphics/join_style.rb +0 -38
  157. data/vendor/prawn-core/lib/prawn/graphics/transformation.rb +0 -157
  158. data/vendor/prawn-core/lib/prawn/graphics/transparency.rb +0 -99
  159. data/vendor/prawn-core/lib/prawn/images.rb +0 -337
  160. data/vendor/prawn-core/lib/prawn/images/jpg.rb +0 -46
  161. data/vendor/prawn-core/lib/prawn/images/png.rb +0 -219
  162. data/vendor/prawn-core/lib/prawn/literal_string.rb +0 -14
  163. data/vendor/prawn-core/lib/prawn/measurement_extensions.rb +0 -46
  164. data/vendor/prawn-core/lib/prawn/measurements.rb +0 -71
  165. data/vendor/prawn-core/lib/prawn/name_tree.rb +0 -166
  166. data/vendor/prawn-core/lib/prawn/object_store.rb +0 -93
  167. data/vendor/prawn-core/lib/prawn/outline.rb +0 -278
  168. data/vendor/prawn-core/lib/prawn/pdf_object.rb +0 -83
  169. data/vendor/prawn-core/lib/prawn/reference.rb +0 -92
  170. data/vendor/prawn-core/lib/prawn/repeater.rb +0 -129
  171. data/vendor/prawn-core/lib/prawn/stamp.rb +0 -128
  172. data/vendor/prawn-core/lib/prawn/text.rb +0 -271
  173. data/vendor/prawn-core/lib/prawn/text/box.rb +0 -414
  174. data/vendor/prawn-core/meta/Rakefile +0 -36
  175. data/vendor/prawn-core/meta/lib/prawn.rb +0 -2
  176. data/vendor/prawn-core/reference_pdfs/alignment.pdf +0 -229
  177. data/vendor/prawn-core/reference_pdfs/background.pdf +0 -0
  178. data/vendor/prawn-core/reference_pdfs/basic_images.pdf +0 -0
  179. data/vendor/prawn-core/reference_pdfs/bounding_boxes.pdf +0 -128
  180. data/vendor/prawn-core/reference_pdfs/canvas.pdf +0 -78
  181. data/vendor/prawn-core/reference_pdfs/chinese_flow.pdf +0 -0
  182. data/vendor/prawn-core/reference_pdfs/cmyk.pdf +0 -0
  183. data/vendor/prawn-core/reference_pdfs/column_box.pdf +0 -3671
  184. data/vendor/prawn-core/reference_pdfs/context_sensitive_headers.pdf +0 -2331
  185. data/vendor/prawn-core/reference_pdfs/curves.pdf +0 -62
  186. data/vendor/prawn-core/reference_pdfs/dfont.pdf +0 -0
  187. data/vendor/prawn-core/reference_pdfs/euro.pdf +0 -75
  188. data/vendor/prawn-core/reference_pdfs/family_style.pdf +0 -286
  189. data/vendor/prawn-core/reference_pdfs/flow.pdf +0 -964
  190. data/vendor/prawn-core/reference_pdfs/font_calculations.pdf +0 -0
  191. data/vendor/prawn-core/reference_pdfs/font_size.pdf +0 -142
  192. data/vendor/prawn-core/reference_pdfs/hexagon.pdf +0 -61
  193. data/vendor/prawn-core/reference_pdfs/image-flow.pdf +0 -0
  194. data/vendor/prawn-core/reference_pdfs/image_fit.pdf +0 -0
  195. data/vendor/prawn-core/reference_pdfs/image_position.pdf +0 -0
  196. data/vendor/prawn-core/reference_pdfs/indentation.pdf +0 -124
  197. data/vendor/prawn-core/reference_pdfs/kerning.pdf +0 -0
  198. data/vendor/prawn-core/reference_pdfs/landscape_a4.pdf +0 -52
  199. data/vendor/prawn-core/reference_pdfs/landscape_legal.pdf +0 -52
  200. data/vendor/prawn-core/reference_pdfs/landscape_letter.pdf +0 -52
  201. data/vendor/prawn-core/reference_pdfs/lines.pdf +0 -116
  202. data/vendor/prawn-core/reference_pdfs/margin.pdf +0 -3850
  203. data/vendor/prawn-core/reference_pdfs/measurement_units.pdf +0 -4667
  204. data/vendor/prawn-core/reference_pdfs/metadata-info.pdf +0 -88
  205. data/vendor/prawn-core/reference_pdfs/multi-layout.pdf +0 -209
  206. data/vendor/prawn-core/reference_pdfs/page_with_numbering.pdf +0 -156
  207. data/vendor/prawn-core/reference_pdfs/png_types.pdf +0 -0
  208. data/vendor/prawn-core/reference_pdfs/portrait_a4.pdf +0 -52
  209. data/vendor/prawn-core/reference_pdfs/portrait_legal.pdf +0 -52
  210. data/vendor/prawn-core/reference_pdfs/portrait_letter.pdf +0 -52
  211. data/vendor/prawn-core/reference_pdfs/pretty_polygons.pdf +0 -122
  212. data/vendor/prawn-core/reference_pdfs/remote_images.pdf +0 -0
  213. data/vendor/prawn-core/reference_pdfs/ruport.pdf +0 -101
  214. data/vendor/prawn-core/reference_pdfs/russian_boxes.pdf +0 -2780
  215. data/vendor/prawn-core/reference_pdfs/simple_text.pdf +0 -136
  216. data/vendor/prawn-core/reference_pdfs/simple_text_ttf.pdf +0 -0
  217. data/vendor/prawn-core/reference_pdfs/sjis.pdf +0 -0
  218. data/vendor/prawn-core/reference_pdfs/span.pdf +0 -1975
  219. data/vendor/prawn-core/reference_pdfs/stamp.pdf +0 -649
  220. data/vendor/prawn-core/reference_pdfs/stretched_nesting.pdf +0 -200
  221. data/vendor/prawn-core/reference_pdfs/stroke_bounds.pdf +0 -135
  222. data/vendor/prawn-core/reference_pdfs/stroke_cap_and_join.pdf +0 -80
  223. data/vendor/prawn-core/reference_pdfs/stroke_dash.pdf +0 -457
  224. data/vendor/prawn-core/reference_pdfs/text_box.pdf +0 -962
  225. data/vendor/prawn-core/reference_pdfs/text_box_returning_excess.pdf +0 -271
  226. data/vendor/prawn-core/reference_pdfs/transparency.pdf +0 -347
  227. data/vendor/prawn-core/reference_pdfs/utf8.pdf +0 -0
  228. data/vendor/prawn-core/reference_pdfs/win-ansi.pdf +0 -6172
  229. data/vendor/prawn-core/spec/annotations_spec.rb +0 -90
  230. data/vendor/prawn-core/spec/bounding_box_spec.rb +0 -185
  231. data/vendor/prawn-core/spec/destinations_spec.rb +0 -15
  232. data/vendor/prawn-core/spec/document_spec.rb +0 -408
  233. data/vendor/prawn-core/spec/font_spec.rb +0 -314
  234. data/vendor/prawn-core/spec/graphics_spec.rb +0 -438
  235. data/vendor/prawn-core/spec/images_spec.rb +0 -79
  236. data/vendor/prawn-core/spec/jpg_spec.rb +0 -25
  237. data/vendor/prawn-core/spec/measurement_units_spec.rb +0 -23
  238. data/vendor/prawn-core/spec/name_tree_spec.rb +0 -112
  239. data/vendor/prawn-core/spec/object_store_spec.rb +0 -75
  240. data/vendor/prawn-core/spec/outline_spec.rb +0 -229
  241. data/vendor/prawn-core/spec/pdf_object_spec.rb +0 -122
  242. data/vendor/prawn-core/spec/png_spec.rb +0 -236
  243. data/vendor/prawn-core/spec/reference_spec.rb +0 -82
  244. data/vendor/prawn-core/spec/repeater_spec.rb +0 -96
  245. data/vendor/prawn-core/spec/snapshot_spec.rb +0 -138
  246. data/vendor/prawn-core/spec/span_spec.rb +0 -49
  247. data/vendor/prawn-core/spec/spec_helper.rb +0 -24
  248. data/vendor/prawn-core/spec/stamp_spec.rb +0 -108
  249. data/vendor/prawn-core/spec/stroke_styles_spec.rb +0 -152
  250. data/vendor/prawn-core/spec/text_at_spec.rb +0 -119
  251. data/vendor/prawn-core/spec/text_box_spec.rb +0 -603
  252. data/vendor/prawn-core/spec/text_spec.rb +0 -308
  253. data/vendor/prawn-core/spec/transparency_spec.rb +0 -75
  254. data/vendor/prawn-core/vendor/pdf-inspector/README +0 -18
  255. data/vendor/prawn-core/vendor/pdf-inspector/lib/pdf/inspector.rb +0 -26
  256. data/vendor/prawn-core/vendor/pdf-inspector/lib/pdf/inspector/extgstate.rb +0 -18
  257. data/vendor/prawn-core/vendor/pdf-inspector/lib/pdf/inspector/graphics.rb +0 -131
  258. data/vendor/prawn-core/vendor/pdf-inspector/lib/pdf/inspector/page.rb +0 -25
  259. data/vendor/prawn-core/vendor/pdf-inspector/lib/pdf/inspector/text.rb +0 -31
  260. data/vendor/prawn-core/vendor/pdf-inspector/lib/pdf/inspector/xobject.rb +0 -19
  261. data/vendor/prawn-core/vendor/ttfunk/data/fonts/DejaVuSans.ttf +0 -0
  262. data/vendor/prawn-core/vendor/ttfunk/data/fonts/comicsans.ttf +0 -0
  263. data/vendor/prawn-core/vendor/ttfunk/example.rb +0 -45
  264. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk.rb +0 -102
  265. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/directory.rb +0 -17
  266. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/encoding/mac_roman.rb +0 -88
  267. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/encoding/windows_1252.rb +0 -69
  268. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/reader.rb +0 -44
  269. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/resource_file.rb +0 -78
  270. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset.rb +0 -18
  271. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset/base.rb +0 -141
  272. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset/mac_roman.rb +0 -46
  273. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset/unicode.rb +0 -48
  274. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset/unicode_8bit.rb +0 -63
  275. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset/windows_1252.rb +0 -51
  276. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/subset_collection.rb +0 -72
  277. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table.rb +0 -46
  278. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/cmap.rb +0 -34
  279. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/cmap/format00.rb +0 -54
  280. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/cmap/format04.rb +0 -126
  281. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/cmap/subtable.rb +0 -79
  282. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/glyf.rb +0 -64
  283. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/glyf/compound.rb +0 -81
  284. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/glyf/simple.rb +0 -37
  285. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/head.rb +0 -44
  286. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/hhea.rb +0 -41
  287. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/hmtx.rb +0 -47
  288. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/kern.rb +0 -79
  289. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/kern/format0.rb +0 -62
  290. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/loca.rb +0 -43
  291. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/maxp.rb +0 -40
  292. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/name.rb +0 -119
  293. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/os2.rb +0 -78
  294. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/post.rb +0 -91
  295. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/post/format10.rb +0 -43
  296. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/post/format20.rb +0 -35
  297. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/post/format25.rb +0 -23
  298. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/post/format30.rb +0 -17
  299. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/post/format40.rb +0 -17
  300. data/vendor/prawn-core/vendor/ttfunk/lib/ttfunk/table/simple.rb +0 -14
  301. data/vendor/prawn-core/www/index.html +0 -196
  302. data/vendor/prawn-core/www/media/bounding_boxes.pdf +0 -146
  303. data/vendor/prawn-core/www/media/bounding_boxes.png +0 -0
  304. data/vendor/prawn-core/www/media/bounding_boxes_out.png +0 -0
  305. data/vendor/prawn-core/www/media/fancy_table.pdf +0 -350
  306. data/vendor/prawn-core/www/media/image.pdf +0 -0
  307. data/vendor/prawn-core/www/media/images.png +0 -0
  308. data/vendor/prawn-core/www/media/prawn_logo.png +0 -0
  309. data/vendor/prawn-core/www/media/tables.png +0 -0
  310. data/vendor/prawn-core/www/media/utf8.pdf +0 -0
  311. data/vendor/prawn-core/www/media/utf8.png +0 -0
  312. data/vendor/prawn-core/www/prawn-Chinese.html +0 -113
  313. data/vendor/prawn-core/www/prawn.css +0 -86
  314. data/vendor/prawn-core/www/twilight.css +0 -266
@@ -1,119 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
4
-
5
- describe "#draw_text" do
6
- before(:each) { create_pdf }
7
-
8
- it "should raise ArgumentError if :at option omitted" do
9
- lambda { @pdf.draw_text("hai", { }) }.should.raise(ArgumentError)
10
- end
11
-
12
- it "should raise ArgumentError if :align option included" do
13
- lambda { @pdf.draw_text("hai", :at => [0, 0], :align => :center) }.should.raise(ArgumentError)
14
- end
15
-
16
- it "should default to 12 point helvetica" do
17
- @pdf.draw_text("Blah", :at => [100,100])
18
- text = PDF::Inspector::Text.analyze(@pdf.render)
19
- text.font_settings[0][:name].should == :Helvetica
20
- text.font_settings[0][:size].should == 12
21
- text.strings.first.should == "Blah"
22
- end
23
-
24
- it "should allow setting font size" do
25
- @pdf.draw_text("Blah", :at => [100,100], :size => 16)
26
- text = PDF::Inspector::Text.analyze(@pdf.render)
27
- text.font_settings[0][:size].should == 16
28
- end
29
-
30
- it "should allow setting a default font size" do
31
- @pdf.font_size = 16
32
- @pdf.draw_text("Blah", :at => [0, 0])
33
- text = PDF::Inspector::Text.analyze(@pdf.render)
34
- text.font_settings[0][:size].should == 16
35
- end
36
-
37
- it "should allow overriding default font for a single instance" do
38
- @pdf.font_size = 16
39
-
40
- @pdf.draw_text("Blah", :size => 11, :at => [0, 0])
41
- @pdf.draw_text("Blaz", :at => [0, 0])
42
- text = PDF::Inspector::Text.analyze(@pdf.render)
43
- text.font_settings[0][:size].should == 11
44
- text.font_settings[1][:size].should == 16
45
- end
46
-
47
- it "should allow setting a font size transaction with a block" do
48
- @pdf.font_size 16 do
49
- @pdf.draw_text('Blah', :at => [0, 0])
50
- end
51
-
52
- @pdf.draw_text('blah', :at => [0, 0])
53
-
54
- text = PDF::Inspector::Text.analyze(@pdf.render)
55
- text.font_settings[0][:size].should == 16
56
- text.font_settings[1][:size].should == 12
57
- end
58
-
59
- it "should allow manual setting the font size " +
60
- "when in a font size block" do
61
- @pdf.font_size(16) do
62
- @pdf.draw_text('Foo', :at => [0, 0])
63
- @pdf.draw_text('Blah', :size => 11, :at => [0, 0])
64
- @pdf.draw_text('Blaz', :at => [0, 0])
65
- end
66
- text = PDF::Inspector::Text.analyze(@pdf.render)
67
- text.font_settings[0][:size].should == 16
68
- text.font_settings[1][:size].should == 11
69
- text.font_settings[2][:size].should == 16
70
- end
71
-
72
- it "should allow registering of built-in font_settings on the fly" do
73
- @pdf.font "Times-Roman"
74
- @pdf.draw_text("Blah", :at => [100,100], :at => [0, 0])
75
- @pdf.font "Courier"
76
- @pdf.draw_text("Blaz", :at => [150,150], :at => [0, 0])
77
- text = PDF::Inspector::Text.analyze(@pdf.render)
78
- text.font_settings[0][:name].should == :"Times-Roman"
79
- text.font_settings[1][:name].should == :Courier
80
- end
81
-
82
- it "should raise an exception when an unknown font is used" do
83
- lambda { @pdf.font "Pao bu" }.should.raise(Prawn::Errors::UnknownFont)
84
- end
85
-
86
- it "should correctly render a utf-8 string when using a built-in font" do
87
- str = "©" # copyright symbol
88
- @pdf.draw_text(str, :at => [0, 0])
89
-
90
- # grab the text from the rendered PDF and ensure it matches
91
- text = PDF::Inspector::Text.analyze(@pdf.render)
92
- text.strings.first.should == str
93
- end
94
-
95
- if "spec".respond_to?(:encode!)
96
- # Handle non utf-8 string encodings in a sane way on M17N aware VMs
97
- it "should raise an exception when a utf-8 incompatible string is rendered" do
98
- str = "Blah \xDD"
99
- str.force_encoding("ASCII-8BIT")
100
- lambda { @pdf.draw_text(str, :at => [0, 0]) }.should.raise(ArgumentError)
101
- end
102
- it "should not raise an exception when a shift-jis string is rendered" do
103
- datafile = "#{Prawn::BASEDIR}/data/shift_jis_text.txt"
104
- sjis_str = File.open(datafile, "r:shift_jis") { |f| f.gets }
105
- @pdf.font("#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf")
106
- lambda { @pdf.draw_text(sjis_str, :at => [0, 0]) }.should.not.raise(ArgumentError)
107
- end
108
- else
109
- # Handle non utf-8 string encodings in a sane way on non-M17N aware VMs
110
- it "should raise an exception when a corrupt utf-8 string is rendered" do
111
- str = "Blah \xDD"
112
- lambda { @pdf.draw_text(str, :at => [0, 0]) }.should.raise(ArgumentError)
113
- end
114
- it "should raise an exception when a shift-jis string is rendered" do
115
- sjis_str = File.read("#{Prawn::BASEDIR}/data/shift_jis_text.txt")
116
- lambda { @pdf.draw_text(sjis_str, :at => [0, 0]) }.should.raise(ArgumentError)
117
- end
118
- end
119
- end
@@ -1,603 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
4
-
5
-
6
- describe "Text::Box#render" do
7
- it "should not fail if height is smaller than 1 line" do
8
- create_pdf
9
- @text = "Oh hai text rect. " * 10
10
- @options = {
11
- :height => @pdf.font.height * 0.5,
12
- :document => @pdf
13
- }
14
- text_box = Prawn::Text::Box.new(@text, @options)
15
- text_box.render
16
- text_box.text.should == ""
17
- end
18
- it "should draw content to the page" do
19
- create_pdf
20
- @text = "Oh hai text rect. " * 10
21
- @options = { :document => @pdf }
22
- text_box = Prawn::Text::Box.new(@text, @options)
23
- text_box.render()
24
- text = PDF::Inspector::Text.analyze(@pdf.render)
25
- text.strings.should.not.be.empty
26
- end
27
- it "should not draw a transformation matrix" do
28
- create_pdf
29
- @text = "Oh hai text rect. " * 10
30
- @options = { :document => @pdf }
31
- text_box = Prawn::Text::Box.new(@text, @options)
32
- text_box.render()
33
- matrices = PDF::Inspector::Graphics::Matrix.analyze(@pdf.render)
34
- matrices.matrices.length.should == 0
35
- end
36
- end
37
-
38
- describe "Text::Box#render(:single_line => true)" do
39
- it "should draw only one line to the page" do
40
- create_pdf
41
- @text = "Oh hai text rect. " * 10
42
- @options = { :document => @pdf,
43
- :single_line => true }
44
- text_box = Prawn::Text::Box.new(@text, @options)
45
- text_box.render()
46
- text = PDF::Inspector::Text.analyze(@pdf.render)
47
- text.strings.length.should == 1
48
- end
49
- end
50
-
51
- describe "Text::Box#render(:dry_run => true)" do
52
- it "should not draw any content to the page" do
53
- create_pdf
54
- @text = "Oh hai text rect. " * 10
55
- @options = { :document => @pdf }
56
- text_box = Prawn::Text::Box.new(@text, @options)
57
- text_box.render(:dry_run => true)
58
- text = PDF::Inspector::Text.analyze(@pdf.render)
59
- text.strings.should.be.empty
60
- end
61
- it "subsequent calls to render should not raise an ArgumentError exception" do
62
- create_pdf
63
- @text = "™©"
64
- @options = { :document => @pdf }
65
- text_box = Prawn::Text::Box.new(@text, @options)
66
- text_box.render(:dry_run => true)
67
- lambda { text_box.render }.should.not.raise(ArgumentError)
68
- end
69
- end
70
-
71
- describe "Text::Box#render with :rotation option of 30)" do
72
- before(:each) do
73
- create_pdf
74
- rotation = 30
75
- @x = 300
76
- @y = 70
77
- @width = 100
78
- @height = 50
79
- @cos = Math.cos(rotation * Math::PI / 180)
80
- @sin = Math.sin(rotation * Math::PI / 180)
81
- @text = "Oh hai text rect. " * 10
82
- @options = { :document => @pdf,
83
- :rotation => rotation,
84
- :at => [@x, @y],
85
- :width => @width,
86
- :height => @height }
87
- end
88
- context ":rotate_around option of :center" do
89
- it "should draw content to the page rotated about the center of the text" do
90
- @options[:rotate_around] = :center
91
- text_box = Prawn::Text::Box.new(@text, @options)
92
- text_box.render()
93
-
94
- matrices = PDF::Inspector::Graphics::Matrix.analyze(@pdf.render)
95
- x = @x + @width / 2
96
- y = @y - @height / 2
97
- x_prime = x * @cos - y * @sin
98
- y_prime = x * @sin + y * @cos
99
- matrices.matrices[0].should == [1, 0, 0, 1,
100
- reduce_precision(x - x_prime),
101
- reduce_precision(y - y_prime)]
102
- matrices.matrices[1].should == [reduce_precision(@cos),
103
- reduce_precision(@sin),
104
- reduce_precision(-@sin),
105
- reduce_precision(@cos), 0, 0]
106
-
107
- text = PDF::Inspector::Text.analyze(@pdf.render)
108
- text.strings.should.not.be.empty
109
- end
110
- end
111
- context ":rotate_around option of :upper_left" do
112
- it "should draw content to the page rotated about the upper left corner of the text" do
113
- @options[:rotate_around] = :upper_left
114
- text_box = Prawn::Text::Box.new(@text, @options)
115
- text_box.render()
116
-
117
- matrices = PDF::Inspector::Graphics::Matrix.analyze(@pdf.render)
118
- x = @x
119
- y = @y
120
- x_prime = x * @cos - y * @sin
121
- y_prime = x * @sin + y * @cos
122
- matrices.matrices[0].should == [1, 0, 0, 1,
123
- reduce_precision(x - x_prime),
124
- reduce_precision(y - y_prime)]
125
- matrices.matrices[1].should == [reduce_precision(@cos),
126
- reduce_precision(@sin),
127
- reduce_precision(-@sin),
128
- reduce_precision(@cos), 0, 0]
129
-
130
- text = PDF::Inspector::Text.analyze(@pdf.render)
131
- text.strings.should.not.be.empty
132
- end
133
- end
134
- context "default :rotate_around" do
135
- it "should draw content to the page rotated about the upper left corner of the text" do
136
- text_box = Prawn::Text::Box.new(@text, @options)
137
- text_box.render()
138
-
139
- matrices = PDF::Inspector::Graphics::Matrix.analyze(@pdf.render)
140
- x = @x
141
- y = @y
142
- x_prime = x * @cos - y * @sin
143
- y_prime = x * @sin + y * @cos
144
- matrices.matrices[0].should == [1, 0, 0, 1,
145
- reduce_precision(x - x_prime),
146
- reduce_precision(y - y_prime)]
147
- matrices.matrices[1].should == [reduce_precision(@cos),
148
- reduce_precision(@sin),
149
- reduce_precision(-@sin),
150
- reduce_precision(@cos), 0, 0]
151
-
152
- text = PDF::Inspector::Text.analyze(@pdf.render)
153
- text.strings.should.not.be.empty
154
- end
155
- end
156
- context ":rotate_around option of :upper_right" do
157
- it "should draw content to the page rotated about the upper right corner of the text" do
158
- @options[:rotate_around] = :upper_right
159
- text_box = Prawn::Text::Box.new(@text, @options)
160
- text_box.render()
161
-
162
- matrices = PDF::Inspector::Graphics::Matrix.analyze(@pdf.render)
163
- x = @x + @width
164
- y = @y
165
- x_prime = x * @cos - y * @sin
166
- y_prime = x * @sin + y * @cos
167
- matrices.matrices[0].should == [1, 0, 0, 1,
168
- reduce_precision(x - x_prime),
169
- reduce_precision(y - y_prime)]
170
- matrices.matrices[1].should == [reduce_precision(@cos),
171
- reduce_precision(@sin),
172
- reduce_precision(-@sin),
173
- reduce_precision(@cos), 0, 0]
174
-
175
- text = PDF::Inspector::Text.analyze(@pdf.render)
176
- text.strings.should.not.be.empty
177
- end
178
- end
179
- context ":rotate_around option of :lower_right" do
180
- it "should draw content to the page rotated about the lower right corner of the text" do
181
- @options[:rotate_around] = :lower_right
182
- text_box = Prawn::Text::Box.new(@text, @options)
183
- text_box.render()
184
-
185
- matrices = PDF::Inspector::Graphics::Matrix.analyze(@pdf.render)
186
- x = @x + @width
187
- y = @y - @height
188
- x_prime = x * @cos - y * @sin
189
- y_prime = x * @sin + y * @cos
190
- matrices.matrices[0].should == [1, 0, 0, 1,
191
- reduce_precision(x - x_prime),
192
- reduce_precision(y - y_prime)]
193
- matrices.matrices[1].should == [reduce_precision(@cos),
194
- reduce_precision(@sin),
195
- reduce_precision(-@sin),
196
- reduce_precision(@cos), 0, 0]
197
-
198
- text = PDF::Inspector::Text.analyze(@pdf.render)
199
- text.strings.should.not.be.empty
200
- end
201
- end
202
- context ":rotate_around option of :lower_left" do
203
- it "should draw content to the page rotated about the lower left corner of the text" do
204
- @options[:rotate_around] = :lower_left
205
- text_box = Prawn::Text::Box.new(@text, @options)
206
- text_box.render()
207
-
208
- matrices = PDF::Inspector::Graphics::Matrix.analyze(@pdf.render)
209
- x = @x
210
- y = @y - @height
211
- x_prime = x * @cos - y * @sin
212
- y_prime = x * @sin + y * @cos
213
- matrices.matrices[0].should == [1, 0, 0, 1,
214
- reduce_precision(x - x_prime),
215
- reduce_precision(y - y_prime)]
216
- matrices.matrices[1].should == [reduce_precision(@cos),
217
- reduce_precision(@sin),
218
- reduce_precision(-@sin),
219
- reduce_precision(@cos), 0, 0]
220
-
221
- text = PDF::Inspector::Text.analyze(@pdf.render)
222
- text.strings.should.not.be.empty
223
- end
224
- end
225
- end
226
-
227
- describe "Text::Box default height" do
228
- it "should be the height from the bottom bound to document.y" do
229
- create_pdf
230
- target_height = @pdf.y - @pdf.bounds.bottom
231
- @text = "Oh hai\n" * 60
232
- @options = { :document => @pdf }
233
- text_box = Prawn::Text::Box.new(@text, @options)
234
- text_box.render
235
- text_box.height.should.be.close(target_height, @pdf.font.height)
236
- end
237
- end
238
-
239
- describe "Text::Box default at" do
240
- it "should be the left corner of the bounds, and the current document.y" do
241
- create_pdf
242
- target_at = [@pdf.bounds.left, @pdf.y]
243
- @text = "Oh hai text rect. " * 100
244
- @options = { :document => @pdf }
245
- text_box = Prawn::Text::Box.new(@text, @options)
246
- text_box.render
247
- text_box.at.should == target_at
248
- end
249
- end
250
-
251
- describe "Text::Box with text than can fit in the box" do
252
- before(:each) do
253
- create_pdf
254
- @text = "Oh hai text rect. " * 10
255
- @options = {
256
- :width => 162.0,
257
- :height => 162.0,
258
- :document => @pdf
259
- }
260
- end
261
-
262
- it "printed text should match requested text, except for trailing or leading white space and that spaces may be replaced by newlines" do
263
- text_box = Prawn::Text::Box.new(@text, @options)
264
- text_box.render
265
- text_box.text.gsub("\n", " ").should == @text.strip
266
- end
267
-
268
- it "render should return an empty string because no text remains unprinted" do
269
- text_box = Prawn::Text::Box.new(@text, @options)
270
- text_box.render.should == ""
271
- end
272
-
273
- it "should be truncated when the leading is set high enough to prevent all the lines from being printed" do
274
- @options[:leading] = 40
275
- text_box = Prawn::Text::Box.new(@text, @options)
276
- text_box.render
277
- text_box.text.gsub("\n", " ").should.not == @text.strip
278
- end
279
- end
280
-
281
- describe "Text::Box with text than can fit in the box with :ellipses overflow and :valign => :bottom" do
282
- it "should not print ellipses" do
283
- create_pdf
284
- @text = "Oh hai text rect. " * 10
285
- @options = {
286
- :width => 162.0,
287
- :height => 162.0,
288
- :overflow => :ellipses,
289
- :valign => :bottom,
290
- :document => @pdf
291
- }
292
- @text_box = Prawn::Text::Box.new(@text, @options)
293
- @text_box.render
294
- @text_box.text.should.not =~ /\.\.\./
295
- end
296
- end
297
-
298
-
299
-
300
- describe "Text::Box printing UTF-8 string with higher bit characters" do
301
- before(:each) do
302
- create_pdf
303
- @text = "©"
304
- # not enough height to print any text, so we can directly compare against
305
- # the input string
306
- bounding_height = 1.0
307
- options = {
308
- :height => bounding_height,
309
- :document => @pdf
310
- }
311
- @text_box = Prawn::Text::Box.new(@text, options)
312
- end
313
- describe "when using a TTF font" do
314
- it "unprinted text should be in UTF-8 encoding" do
315
- @pdf.font("#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf")
316
- remaining_text = @text_box.render
317
- remaining_text.should == @text
318
- end
319
- it "subsequent calls to Text::Box need not include the" +
320
- " :skip_encoding => true option" do
321
- @pdf.font("#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf")
322
- remaining_text = @text_box.render
323
- lambda {
324
- @pdf.text_box(remaining_text, :document => @pdf)
325
- }.should.not.raise(ArgumentError)
326
- end
327
- end
328
- describe "when using an AFM font" do
329
- it "unprinted text should be in WinAnsi encoding" do
330
- remaining_text = @text_box.render
331
- remaining_text.should == @pdf.font.normalize_encoding(@text)
332
- end
333
- it "subsequent calls to Text::Box must include the" +
334
- " :skip_encoding => true option" do
335
- remaining_text = @text_box.render
336
- lambda {
337
- @pdf.text_box(remaining_text, :document => @pdf)
338
- }.should.raise(ArgumentError)
339
- lambda {
340
- @pdf.text_box(remaining_text, :skip_encoding => true,
341
- :document => @pdf)
342
- }.should.not.raise(ArgumentError)
343
- end
344
- end
345
- end
346
-
347
-
348
- describe "Text::Box with more text than can fit in the box" do
349
- before(:each) do
350
- create_pdf
351
- @text = "Oh hai text rect. " * 30
352
- @bounding_height = 162.0
353
- @options = {
354
- :width => 162.0,
355
- :height => @bounding_height,
356
- :document => @pdf
357
- }
358
- end
359
-
360
- context "truncated overflow" do
361
- before(:each) do
362
- @options[:overflow] = :truncate
363
- @text_box = Prawn::Text::Box.new(@text, @options)
364
- end
365
- it "should not display ellipses" do
366
- @text_box.render
367
- @text_box.text.should.not =~ /\.\.\./
368
- end
369
- it "should be truncated" do
370
- @text_box.render
371
- @text_box.text.gsub("\n", " ").should.not == @text.strip
372
- end
373
- it "render should not return an empty string because some text remains unprinted" do
374
- @text_box.render.should.not == ""
375
- end
376
- it "#height should be no taller than the specified height" do
377
- @text_box.render
378
- @text_box.height.should.be <= @bounding_height
379
- end
380
- it "#height should be within one font height of the specified height" do
381
- @text_box.render
382
- @bounding_height.should.be.close(@text_box.height, @pdf.font.height)
383
- end
384
- context "with :rotation option" do
385
- it "unrendered text should be the same as when not rotated" do
386
- remaining_text = @text_box.render
387
-
388
- rotation = 30
389
- x = 300
390
- y = 70
391
- width = @options[:width]
392
- height = @options[:height]
393
- @options[:document] = @pdf
394
- @options[:rotation] = rotation
395
- @options[:at] = [x, y]
396
- rotated_text_box = Prawn::Text::Box.new(@text, @options)
397
- rotated_text_box.render.should == remaining_text
398
- end
399
- end
400
- end
401
-
402
- context "ellipses overflow" do
403
- before(:each) do
404
- @options[:overflow] = :ellipses
405
- @text_box = Prawn::Text::Box.new(@text, @options)
406
- end
407
- it "should display ellipses" do
408
- @text_box.render
409
- @text_box.text.should =~ /\.\.\./
410
- end
411
- it "render should not return an empty string because some text remains unprinted" do
412
- @text_box.render.should.not == ""
413
- end
414
- end
415
-
416
- context "expand overflow" do
417
- before(:each) do
418
- @options[:overflow] = :expand
419
- @text_box = Prawn::Text::Box.new(@text, @options)
420
- end
421
- it "height should expand to encompass all the text (but not exceed the height of the page)" do
422
- @text_box.render
423
- @text_box.height.should > @bounding_height
424
- end
425
- it "should display the entire string (as long as there was space remaining on the page to print all the text)" do
426
- @text_box.render
427
- @text_box.text.gsub("\n", " ").should == @text.strip
428
- end
429
- it "render should return an empty string because no text remains unprinted(as long as there was space remaining on the page to print all the text)" do
430
- @text_box.render.should == ""
431
- end
432
- end
433
-
434
- context "shrink_to_fit overflow" do
435
- before(:each) do
436
- @options[:overflow] = :shrink_to_fit
437
- @options[:min_font_size] = 2
438
- @text_box = Prawn::Text::Box.new(@text, @options)
439
- end
440
- it "should display the entire text" do
441
- @text_box.render
442
- @text_box.text.gsub("\n", " ").should == @text.strip
443
- end
444
- it "render should return an empty string because no text remains unprinted" do
445
- @text_box.render.should == ""
446
- end
447
- end
448
- end
449
-
450
- describe "Text::Box with a solid block of Chinese characters" do
451
- it "printed text should match requested text, except for newlines" do
452
- create_pdf
453
- @text = "写中国字" * 10
454
- @options = {
455
- :width => 162.0,
456
- :height => 162.0,
457
- :document => @pdf
458
- }
459
- @pdf.font "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf"
460
- @options[:overflow] = :truncate
461
- text_box = Prawn::Text::Box.new(@text, @options)
462
- text_box.render
463
- text_box.text.gsub("\n", "").should == @text.strip
464
- end
465
- end
466
-
467
-
468
- describe "drawing bounding boxes" do
469
-
470
- before(:each) { create_pdf }
471
-
472
- it "should restore the margin box when bounding box exits" do
473
- margin_box = @pdf.bounds
474
-
475
- @pdf.text_box "Oh hai text box. " * 11, :height => @pdf.font.height * 10
476
-
477
- @pdf.bounds.should == margin_box
478
-
479
- end
480
-
481
- end
482
-
483
-
484
- describe 'Text::Box wrapping' do
485
- before(:each) do
486
- create_pdf
487
- end
488
-
489
- it "should wrap text" do
490
- text = "Please wrap this text about HERE. More text that should be wrapped"
491
- expect = "Please wrap this text about\nHERE. More text that should be\nwrapped"
492
-
493
- @pdf.font "Courier"
494
- text_box = Prawn::Text::Box.new(text,
495
- :width => 220,
496
- :overflow => :expand,
497
- :document => @pdf)
498
- text_box.render
499
- text_box.text.should == expect
500
- end
501
-
502
- it "should respect end of line when wrapping text" do
503
- text = "Please wrap only before\nTHIS word. Don't wrap this"
504
- expect = text
505
-
506
- @pdf.font "Courier"
507
- text_box = Prawn::Text::Box.new(text,
508
- :width => 220,
509
- :overflow => :expand,
510
- :document => @pdf)
511
- text_box.render
512
- text_box.text.should == expect
513
- end
514
-
515
- it "should respect multiple newlines when wrapping text" do
516
- text = "Please wrap only before THIS\n\nword. Don't wrap this"
517
- expect= "Please wrap only before\nTHIS\n\nword. Don't wrap this"
518
-
519
- @pdf.font "Courier"
520
- text_box = Prawn::Text::Box.new(text,
521
- :width => 200,
522
- :overflow => :expand,
523
- :document => @pdf)
524
- text_box.render
525
- text_box.text.should == expect
526
- end
527
-
528
- it "should respect multiple newlines when wrapping text when those newlines coincide with a line break" do
529
- text = "Please wrap only before\n\nTHIS word. Don't wrap this"
530
- expect = text
531
-
532
- @pdf.font "Courier"
533
- text_box = Prawn::Text::Box.new(text,
534
- :width => 220,
535
- :overflow => :expand,
536
- :document => @pdf)
537
- text_box.render
538
- text_box.text.should == expect
539
- end
540
-
541
- it "should respect initial newlines" do
542
- text = "\nThis should be on line 2"
543
- expect = text
544
-
545
- @pdf.font "Courier"
546
- text_box = Prawn::Text::Box.new(text,
547
- :width => 220,
548
- :overflow => :expand,
549
- :document => @pdf)
550
- text_box.render
551
- text_box.text.should == expect
552
- end
553
-
554
- it "should wrap lines comprised of a single word of the bounds when wrapping text" do
555
- text = "You_can_wrap_this_text_HERE"
556
- expect = "You_can_wrap_this_text_HE\nRE"
557
-
558
- @pdf.font "Courier"
559
- text_box = Prawn::Text::Box.new(text,
560
- :width => 180,
561
- :overflow => :expand,
562
- :document => @pdf)
563
- text_box.render
564
- text_box.text.should == expect
565
- end
566
-
567
- it "should wrap lines comprised of a single word of the bounds when wrapping text" do
568
- text = '©' * 30
569
-
570
- @pdf.font "Courier"
571
- text_box = Prawn::Text::Box.new(text, :width => 180,
572
- :overflow => :expand,
573
- :document => @pdf)
574
-
575
- text_box.render
576
-
577
- expected = '©'*25 + "\n" + '©' * 5
578
- @pdf.font.normalize_encoding!(expected)
579
-
580
- text_box.text.should == expected
581
- end
582
-
583
- it "should wrap non-unicode strings using single-byte word-wrapping" do
584
- text = "continúa esforzandote " * 5
585
- text_box = Prawn::Text::Box.new(text, :width => 180,
586
- :document => @pdf)
587
- text_box.render
588
- results_with_accent = text_box.text
589
-
590
- text = "continua esforzandote " * 5
591
- text_box = Prawn::Text::Box.new(text, :width => 180,
592
- :document => @pdf)
593
- text_box.render
594
- results_without_accent = text_box.text
595
-
596
- results_with_accent.first_line.length.should == results_without_accent.first_line.length
597
- end
598
-
599
- end
600
-
601
- def reduce_precision(float)
602
- ("%.5f" % float).to_f
603
- end