summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Dobrowolski <admin@tastycode.pl>2017-09-25 13:37:13 +0200
committerPiotr Dobrowolski <admin@tastycode.pl>2017-09-25 13:37:13 +0200
commit4cab9f4707f4615d1c5de559dec2cb125d345fcc (patch)
treef0948f94a56e962ab1849782688ea5efc51424ff
parent3a98c2383837d5dfeafc74cc059da52f94a18bff (diff)
downloadspejstore-labelmaker-4cab9f4707f4615d1c5de559dec2cb125d345fcc.tar.gz
spejstore-labelmaker-4cab9f4707f4615d1c5de559dec2cb125d345fcc.tar.bz2
spejstore-labelmaker-4cab9f4707f4615d1c5de559dec2cb125d345fcc.zip
Fix text wrapping
-rw-r--r--main.rb22
1 files changed, 19 insertions, 3 deletions
diff --git a/main.rb b/main.rb
index 32b5ab9..aaa9dd3 100644
--- a/main.rb
+++ b/main.rb
@@ -12,10 +12,26 @@ require 'zlib'
include Prawn::Measurements
+module Prawn
+ module Text
+ module Formatted #:nodoc:
+ # @private
+ class LineWrap #:nodoc:
+ def whitespace()
+ # Wrap by these special characters as well
+ "&:/\\" +
+ "\s\t#{zero_width_space()}"
+ end
+ end
+ end
+ end
+end
+
+
module Excon
class Response
def json!()
- puts body
+ # Convenience function
JSON.parse(body)
end
end
@@ -80,8 +96,8 @@ def render_label(label)
# Left side
bounding_box(bounds.top_left, :width => bounds.width-rw) do
text_box label['item']['name'],
- size: 30, align: :center, valign: :center,
- inline_format: true, overflow: :shrink_to_fit
+ size: 40, align: :center, valign: :center, width: bounds.width-10,
+ inline_format: true, overflow: :shrink_to_fit, disable_wrap_by_char: true
end
end