prawn 2.4.0 → 2.5.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/prawn/document/bounding_box.rb +213 -141
- data/lib/prawn/document/column_box.rb +61 -26
- data/lib/prawn/document/internals.rb +25 -16
- data/lib/prawn/document/span.rb +20 -18
- data/lib/prawn/document.rb +257 -171
- data/lib/prawn/encoding.rb +2 -5
- data/lib/prawn/errors.rb +23 -34
- data/lib/prawn/font.rb +248 -135
- data/lib/prawn/font_metric_cache.rb +11 -10
- data/lib/prawn/fonts/afm.rb +85 -45
- data/lib/prawn/fonts/dfont.rb +7 -1
- data/lib/prawn/fonts/otf.rb +4 -1
- data/lib/prawn/fonts/to_unicode_cmap.rb +151 -0
- data/lib/prawn/fonts/ttc.rb +7 -2
- data/lib/prawn/fonts/ttf.rb +305 -93
- data/lib/prawn/fonts.rb +14 -0
- data/lib/prawn/graphics/blend_mode.rb +25 -28
- data/lib/prawn/graphics/cap_style.rb +9 -12
- data/lib/prawn/graphics/color.rb +57 -34
- data/lib/prawn/graphics/dash.rb +45 -42
- data/lib/prawn/graphics/join_style.rb +17 -11
- data/lib/prawn/graphics/patterns.rb +190 -69
- data/lib/prawn/graphics/transformation.rb +48 -41
- data/lib/prawn/graphics/transparency.rb +16 -40
- data/lib/prawn/graphics.rb +363 -253
- data/lib/prawn/grid.rb +184 -57
- data/lib/prawn/image_handler.rb +27 -10
- data/lib/prawn/images/image.rb +8 -10
- data/lib/prawn/images/jpg.rb +42 -19
- data/lib/prawn/images/png.rb +92 -41
- data/lib/prawn/images.rb +44 -57
- data/lib/prawn/measurement_extensions.rb +39 -8
- data/lib/prawn/measurements.rb +60 -5
- data/lib/prawn/outline.rb +114 -108
- data/lib/prawn/repeater.rb +51 -35
- data/lib/prawn/security/arcfour.rb +4 -4
- data/lib/prawn/security.rb +75 -70
- data/lib/prawn/soft_mask.rb +42 -30
- data/lib/prawn/stamp.rb +38 -42
- data/lib/prawn/text/box.rb +146 -96
- data/lib/prawn/text/formatted/arranger.rb +87 -26
- data/lib/prawn/text/formatted/box.rb +221 -150
- data/lib/prawn/text/formatted/fragment.rb +130 -14
- data/lib/prawn/text/formatted/line_wrap.rb +33 -24
- data/lib/prawn/text/formatted/parser.rb +112 -72
- data/lib/prawn/text/formatted/wrap.rb +12 -17
- data/lib/prawn/text/formatted.rb +75 -0
- data/lib/prawn/text.rb +441 -196
- data/lib/prawn/transformation_stack.rb +29 -10
- data/lib/prawn/utilities.rb +13 -13
- data/lib/prawn/version.rb +2 -1
- data/lib/prawn/view.rb +68 -53
- data/lib/prawn.rb +23 -18
- data.tar.gz.sig +0 -0
- metadata +54 -177
- metadata.gz.sig +0 -0
- data/.yardopts +0 -10
- data/Gemfile +0 -5
- data/Rakefile +0 -25
- data/manual/absolute_position.pdf +0 -0
- data/manual/basic_concepts/adding_pages.rb +0 -26
- data/manual/basic_concepts/basic_concepts.rb +0 -43
- data/manual/basic_concepts/creation.rb +0 -38
- data/manual/basic_concepts/cursor.rb +0 -32
- data/manual/basic_concepts/measurement.rb +0 -24
- data/manual/basic_concepts/origin.rb +0 -37
- data/manual/basic_concepts/other_cursor_helpers.rb +0 -39
- data/manual/basic_concepts/view.rb +0 -48
- data/manual/bounding_box/bounding_box.rb +0 -41
- data/manual/bounding_box/bounds.rb +0 -48
- data/manual/bounding_box/canvas.rb +0 -23
- data/manual/bounding_box/creation.rb +0 -22
- data/manual/bounding_box/indentation.rb +0 -45
- data/manual/bounding_box/nesting.rb +0 -52
- data/manual/bounding_box/russian_boxes.rb +0 -40
- data/manual/bounding_box/stretchy.rb +0 -29
- data/manual/contents.rb +0 -35
- data/manual/cover.rb +0 -43
- data/manual/document_and_page_options/background.rb +0 -29
- data/manual/document_and_page_options/document_and_page_options.rb +0 -34
- data/manual/document_and_page_options/metadata.rb +0 -25
- data/manual/document_and_page_options/page_margins.rb +0 -36
- data/manual/document_and_page_options/page_size.rb +0 -34
- data/manual/document_and_page_options/print_scaling.rb +0 -23
- data/manual/example_helper.rb +0 -8
- data/manual/graphics/blend_mode.rb +0 -52
- data/manual/graphics/circle_and_ellipse.rb +0 -21
- data/manual/graphics/color.rb +0 -22
- data/manual/graphics/common_lines.rb +0 -29
- data/manual/graphics/fill_and_stroke.rb +0 -41
- data/manual/graphics/fill_rules.rb +0 -38
- data/manual/graphics/gradients.rb +0 -43
- data/manual/graphics/graphics.rb +0 -64
- data/manual/graphics/helper.rb +0 -34
- data/manual/graphics/line_width.rb +0 -36
- data/manual/graphics/lines_and_curves.rb +0 -40
- data/manual/graphics/polygon.rb +0 -27
- data/manual/graphics/rectangle.rb +0 -20
- data/manual/graphics/rotate.rb +0 -25
- data/manual/graphics/scale.rb +0 -42
- data/manual/graphics/soft_masks.rb +0 -44
- data/manual/graphics/stroke_cap.rb +0 -30
- data/manual/graphics/stroke_dash.rb +0 -47
- data/manual/graphics/stroke_join.rb +0 -29
- data/manual/graphics/translate.rb +0 -29
- data/manual/graphics/transparency.rb +0 -33
- data/manual/how_to_read_this_manual.rb +0 -39
- data/manual/images/absolute_position.rb +0 -22
- data/manual/images/fit.rb +0 -20
- data/manual/images/horizontal.rb +0 -24
- data/manual/images/images.rb +0 -41
- data/manual/images/plain_image.rb +0 -17
- data/manual/images/scale.rb +0 -21
- data/manual/images/vertical.rb +0 -30
- data/manual/images/width_and_height.rb +0 -24
- data/manual/layout/boxes.rb +0 -26
- data/manual/layout/content.rb +0 -24
- data/manual/layout/layout.rb +0 -27
- data/manual/layout/simple_grid.rb +0 -22
- data/manual/outline/add_subsection_to.rb +0 -60
- data/manual/outline/insert_section_after.rb +0 -46
- data/manual/outline/outline.rb +0 -33
- data/manual/outline/sections_and_pages.rb +0 -66
- data/manual/repeatable_content/alternate_page_numbering.rb +0 -36
- data/manual/repeatable_content/page_numbering.rb +0 -55
- data/manual/repeatable_content/repeatable_content.rb +0 -35
- data/manual/repeatable_content/repeater.rb +0 -54
- data/manual/repeatable_content/stamp.rb +0 -40
- data/manual/security/encryption.rb +0 -28
- data/manual/security/permissions.rb +0 -43
- data/manual/security/security.rb +0 -28
- data/manual/table.rb +0 -16
- data/manual/text/alignment.rb +0 -43
- data/manual/text/color.rb +0 -24
- data/manual/text/column_box.rb +0 -30
- data/manual/text/fallback_fonts.rb +0 -41
- data/manual/text/font.rb +0 -40
- data/manual/text/font_size.rb +0 -44
- data/manual/text/font_style.rb +0 -25
- data/manual/text/formatted_callbacks.rb +0 -70
- data/manual/text/formatted_text.rb +0 -61
- data/manual/text/free_flowing_text.rb +0 -50
- data/manual/text/inline.rb +0 -40
- data/manual/text/kerning_and_character_spacing.rb +0 -38
- data/manual/text/leading.rb +0 -24
- data/manual/text/line_wrapping.rb +0 -60
- data/manual/text/paragraph_indentation.rb +0 -31
- data/manual/text/positioned_text.rb +0 -37
- data/manual/text/registering_families.rb +0 -51
- data/manual/text/rendering_and_color.rb +0 -36
- data/manual/text/right_to_left_text.rb +0 -54
- data/manual/text/rotation.rb +0 -52
- data/manual/text/single_usage.rb +0 -36
- data/manual/text/text.rb +0 -75
- data/manual/text/text_box_excess.rb +0 -35
- data/manual/text/text_box_extensions.rb +0 -48
- data/manual/text/text_box_overflow.rb +0 -51
- data/manual/text/utf8.rb +0 -27
- data/manual/text/win_ansi_charset.rb +0 -62
- data/prawn.gemspec +0 -51
- data/spec/data/curves.pdf +0 -66
- data/spec/extensions/encoding_helpers.rb +0 -11
- data/spec/prawn/document/bounding_box_spec.rb +0 -550
- data/spec/prawn/document/column_box_spec.rb +0 -75
- data/spec/prawn/document/security_spec.rb +0 -176
- data/spec/prawn/document_annotations_spec.rb +0 -76
- data/spec/prawn/document_destinations_spec.rb +0 -15
- data/spec/prawn/document_grid_spec.rb +0 -99
- data/spec/prawn/document_reference_spec.rb +0 -27
- data/spec/prawn/document_span_spec.rb +0 -44
- data/spec/prawn/document_spec.rb +0 -805
- data/spec/prawn/font_metric_cache_spec.rb +0 -54
- data/spec/prawn/font_spec.rb +0 -544
- data/spec/prawn/graphics/blend_mode_spec.rb +0 -63
- data/spec/prawn/graphics/transparency_spec.rb +0 -81
- data/spec/prawn/graphics_spec.rb +0 -872
- data/spec/prawn/graphics_stroke_styles_spec.rb +0 -229
- data/spec/prawn/image_handler_spec.rb +0 -53
- data/spec/prawn/images/jpg_spec.rb +0 -20
- data/spec/prawn/images/png_spec.rb +0 -283
- data/spec/prawn/images_spec.rb +0 -229
- data/spec/prawn/measurements_extensions_spec.rb +0 -24
- data/spec/prawn/outline_spec.rb +0 -512
- data/spec/prawn/repeater_spec.rb +0 -166
- data/spec/prawn/soft_mask_spec.rb +0 -74
- data/spec/prawn/stamp_spec.rb +0 -173
- data/spec/prawn/text/box_spec.rb +0 -1110
- data/spec/prawn/text/formatted/arranger_spec.rb +0 -466
- data/spec/prawn/text/formatted/box_spec.rb +0 -849
- data/spec/prawn/text/formatted/fragment_spec.rb +0 -343
- data/spec/prawn/text/formatted/line_wrap_spec.rb +0 -495
- data/spec/prawn/text/formatted/parser_spec.rb +0 -697
- data/spec/prawn/text_draw_text_spec.rb +0 -150
- data/spec/prawn/text_rendering_mode_spec.rb +0 -48
- data/spec/prawn/text_spacing_spec.rb +0 -95
- data/spec/prawn/text_spec.rb +0 -603
- data/spec/prawn/text_with_inline_formatting_spec.rb +0 -35
- data/spec/prawn/transformation_stack_spec.rb +0 -66
- data/spec/prawn/view_spec.rb +0 -63
- data/spec/prawn_manual_spec.rb +0 -35
- data/spec/spec_helper.rb +0 -48
data/lib/prawn/text.rb
CHANGED
@@ -1,154 +1,153 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# text.rb : Implements PDF text primitives
|
4
|
-
#
|
5
|
-
# Copyright May 2008, Gregory Brown. All Rights Reserved.
|
6
|
-
#
|
7
|
-
# This is free software. Please see the LICENSE and COPYING files for details.
|
8
|
-
|
9
3
|
require 'zlib'
|
10
4
|
|
11
5
|
require_relative 'text/formatted'
|
12
6
|
require_relative 'text/box'
|
13
7
|
|
14
8
|
module Prawn
|
9
|
+
# PDF text primitives.
|
15
10
|
module Text
|
16
11
|
include PDF::Core::Text
|
17
12
|
include Prawn::Text::Formatted
|
18
13
|
|
19
14
|
# No-Break Space
|
20
15
|
NBSP = "\u00A0"
|
16
|
+
|
21
17
|
# Zero Width Space (indicate word boundaries without a space)
|
22
18
|
ZWSP = "\u200B"
|
19
|
+
|
23
20
|
# Soft Hyphen (invisible, except when causing a line break)
|
24
21
|
SHY = "\u00AD"
|
25
22
|
|
26
23
|
# @group Stable API
|
27
24
|
|
25
|
+
# Draws text on the page.
|
26
|
+
#
|
28
27
|
# If you want text to flow onto a new page or between columns, this is the
|
29
|
-
# method to use. If, instead,
|
30
|
-
#
|
31
|
-
# or its convenience method text_box.
|
28
|
+
# method to use. If, instead, you want to place bounded text outside of the
|
29
|
+
# flow of a document (for captions, labels, charts, etc.), use {Text::Box}
|
30
|
+
# or its convenience method {text_box}.
|
32
31
|
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
32
|
+
# Prawn attempts to wrap the text to fit within your current bounding box
|
33
|
+
# (or `margin_box` if no bounding box is being used). Text will flow onto
|
34
|
+
# the next page when it reaches the bottom of the bounding box. Text wrap in
|
35
|
+
# Prawn does not re-flow line breaks, so if you want fully automated text
|
36
|
+
# wrapping, be sure to remove newlines before attempting to draw your
|
37
|
+
# string.
|
39
38
|
#
|
40
|
-
#
|
39
|
+
# #### Examples
|
41
40
|
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
41
|
+
# ```ruby
|
42
|
+
# pdf.text "Will be wrapped when it hits the edge of your bounding box"
|
43
|
+
# pdf.text "This will be centered", align: :center
|
44
|
+
# pdf.text "This will be right aligned", align: :right
|
45
|
+
# pdf.text "This <i>includes <b>inline</b></i> <font size='24'>formatting</font>", inline_format: true
|
46
|
+
# ```
|
47
47
|
#
|
48
|
-
# If your font contains kerning pair data that Prawn can parse, the
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
48
|
+
# If your font contains kerning pair data that Prawn can parse, the text
|
49
|
+
# will be kerned by default. You can disable kerning by including a `false`
|
50
|
+
# `:kerning` option. If you want to disable kerning on an entire document,
|
51
|
+
# set `default_kerning = false` for that document.
|
52
52
|
#
|
53
|
-
#
|
53
|
+
# #### Text Positioning Details
|
54
54
|
#
|
55
|
-
# The text is positioned at font.ascender below the baseline,
|
56
|
-
#
|
55
|
+
# The text is positioned at `font.ascender` below the baseline, making it
|
56
|
+
# easy to use this method within bounding boxes and spans.
|
57
57
|
#
|
58
|
-
#
|
58
|
+
# #### Encoding
|
59
59
|
#
|
60
|
-
# Note that strings passed to this function should be encoded as UTF-8.
|
61
|
-
#
|
62
|
-
#
|
60
|
+
# Note that strings passed to this function should be encoded as UTF-8. If
|
61
|
+
# you get unexpected characters appearing in your rendered document, check
|
62
|
+
# this.
|
63
63
|
#
|
64
|
-
# If the current font is a built-in one, although the string must be
|
65
|
-
#
|
66
|
-
# are allowed.
|
64
|
+
# If the current font is a built-in one, although the string must be encoded
|
65
|
+
# as UTF-8, only characters that are available in WinAnsi are allowed.
|
67
66
|
#
|
68
67
|
# If an empty box is rendered to your PDF instead of the character you
|
69
68
|
# wanted it usually means the current font doesn't include that character.
|
70
69
|
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
#
|
82
|
-
#
|
83
|
-
#
|
84
|
-
#
|
85
|
-
#
|
86
|
-
#
|
87
|
-
#
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
#
|
93
|
-
#
|
94
|
-
#
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
99
|
-
#
|
100
|
-
#
|
101
|
-
#
|
102
|
-
#
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
106
|
-
#
|
107
|
-
#
|
108
|
-
#
|
109
|
-
#
|
110
|
-
#
|
111
|
-
#
|
112
|
-
#
|
113
|
-
#
|
114
|
-
#
|
115
|
-
#
|
116
|
-
#
|
117
|
-
#
|
118
|
-
#
|
119
|
-
#
|
120
|
-
#
|
121
|
-
#
|
122
|
-
#
|
123
|
-
#
|
124
|
-
#
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
128
|
-
#
|
129
|
-
#
|
130
|
-
#
|
131
|
-
#
|
132
|
-
#
|
133
|
-
#
|
134
|
-
#
|
135
|
-
#
|
136
|
-
#
|
137
|
-
#
|
138
|
-
#
|
139
|
-
#
|
140
|
-
#
|
141
|
-
#
|
142
|
-
#
|
143
|
-
#
|
144
|
-
#
|
145
|
-
#
|
146
|
-
#
|
147
|
-
#
|
148
|
-
#
|
149
|
-
#
|
150
|
-
#
|
151
|
-
#
|
70
|
+
# @param string [String]
|
71
|
+
# @param options [Hash{Symbol => any}]
|
72
|
+
# @option options :inline_format [Boolean]
|
73
|
+
# If `true`, then the string parameter is interpreted as a HTML-esque
|
74
|
+
# string that recognizes the following tags (assuming the default text
|
75
|
+
# formatter is used):
|
76
|
+
# - `<b></b>`{:.language-html} --- bold style.
|
77
|
+
# - `<i></i>`{:.language-html} --- italic style.
|
78
|
+
# - `<u></u>`{:.language-html} --- underline.
|
79
|
+
# - `<strikethrough></strikethrough>`{:.language-html} --- strikethrough.
|
80
|
+
# - `<sub></sub>`{:.language-html} --- subscript.
|
81
|
+
# - `<sup></sup>`{:.language-html} --- superscript.
|
82
|
+
# - `<font></font>`{:.language-html} --- with the following attributes
|
83
|
+
# (using double or single quotes):
|
84
|
+
# - `name="Helvetica"`{:.language-html} --- the font. The font name must
|
85
|
+
# be an AFM font with the desired faces or must be a font that is
|
86
|
+
# already registered using {Prawn::Document#font_families}.
|
87
|
+
# - `size="24"`{:.language-html} --- attribute for setting size.
|
88
|
+
# - `character_spacing="2.5"`{:.language-html} --- character spacing.
|
89
|
+
# - `<color></color>`{:.language-html} --- text color
|
90
|
+
# - `rgb="ffffff"`{:.language-html} or `rgb="#ffffff"`{:.language-html}
|
91
|
+
# --- RGB color
|
92
|
+
# - `c="100" m="100" y="100" k="100"`{:.language-html} --- CMYK color
|
93
|
+
# - `<link></link>`{:.language-html} - link, with the following
|
94
|
+
# attributes:
|
95
|
+
# - `href="http://example.com"`{:.language-html} --- an external link.
|
96
|
+
# Note that you must explicitly underline and color using the
|
97
|
+
# appropriate tags if you which to draw attention to the link.
|
98
|
+
# @option options :kerning [Boolean] (value of document.default_kerning?)
|
99
|
+
# Whether or not to use kerning (if it is available with the current
|
100
|
+
# font).
|
101
|
+
# @option options :size [Number] (current ofnt size) The font size to use.
|
102
|
+
# @option options :color [Color]
|
103
|
+
# @option options :character_spacing [Number] (0)
|
104
|
+
# The amount of space to add to or remove from the default character
|
105
|
+
# spacing.
|
106
|
+
# @option options :style [Symbol] (current style)
|
107
|
+
# The style to use. The requested style must be part of the current font
|
108
|
+
# family.
|
109
|
+
# @option options :indent_paragraphs [Number]
|
110
|
+
# The amount to indent the first line of each paragraph. Omit this option
|
111
|
+
# if you do not want indenting.
|
112
|
+
# @option options :direction [:ltr, :rtl] (value of document.text_direction)
|
113
|
+
# Direction of the text.
|
114
|
+
# @option options :fallback_fonts [Array<String>]
|
115
|
+
# An array of font names. Each name must be the name of an AFM font or the
|
116
|
+
# name that was used to register a family of TTF fonts (see
|
117
|
+
# {Prawn::Document#font_families}). If present, then each glyph will be
|
118
|
+
# rendered using the first font that includes the glyph, starting with the
|
119
|
+
# current font and then moving through `:fallback_fonts`.
|
120
|
+
# @option option :align [:left, :center, :right, :justify]
|
121
|
+
# (:left if direction is :ltr, :right if direction is :rtl)
|
122
|
+
# Alignment within the bounding box.
|
123
|
+
# @option options :valign [:top, :center, :bottom] (:top)
|
124
|
+
# Vertical alignment within the bounding box.
|
125
|
+
# @option options :leading (Number) (value of document.default_leading)
|
126
|
+
# Additional space between lines.
|
127
|
+
# @option options :final_gap [Boolean] (true)
|
128
|
+
# If `true`, then the space between each line is included below the last
|
129
|
+
# line; otherwise, {Document.y} is placed just below the descender of the
|
130
|
+
# last line printed.
|
131
|
+
# @option options :mode [Symbol] (:fill)
|
132
|
+
# The text rendering mode to use. Use this to specify if the text should
|
133
|
+
# render with the fill color, stroke color or both.
|
134
|
+
# * `:fill` - fill text (default)
|
135
|
+
# * `:stroke` - stroke text
|
136
|
+
# * `:fill_stroke` - fill, then stroke text
|
137
|
+
# * `:invisible` - invisible text
|
138
|
+
# * `:fill_clip` - fill text then add to path for clipping
|
139
|
+
# * `:stroke_clip` - stroke text then add to path for clipping
|
140
|
+
# * `:fill_stroke_clip` - fill then stroke text, then add to path for
|
141
|
+
# clipping
|
142
|
+
# * `:clip` - add text to path for clipping
|
143
|
+
#
|
144
|
+
# @return [void]
|
145
|
+
#
|
146
|
+
# @raise [ArgumentError] if `:at` option included
|
147
|
+
# @raise [Prawn::Errrors::CannotFit] if not wide enough to print any text
|
148
|
+
#
|
149
|
+
# @see PDF::Core::Text#text_rendering_mode()
|
150
|
+
# for a list of valid text rendering modes.
|
152
151
|
def text(string, options = {})
|
153
152
|
return false if string.nil?
|
154
153
|
|
@@ -168,34 +167,108 @@ module Prawn
|
|
168
167
|
end
|
169
168
|
|
170
169
|
# Draws formatted text to the page.
|
171
|
-
# Formatted text is comprised of an array of hashes, where each hash defines
|
172
|
-
# text and format information. See Text::Formatted#formatted_text_box for
|
173
|
-
# more information on the structure of this array
|
174
170
|
#
|
175
|
-
#
|
171
|
+
# Formatted text is an array of hashes, where each hash defines text and
|
172
|
+
# format information.
|
176
173
|
#
|
174
|
+
# @example
|
177
175
|
# text([{ :text => "hello" },
|
178
176
|
# { :text => "world",
|
179
177
|
# :size => 24,
|
180
178
|
# :styles => [:bold, :italic] }])
|
181
179
|
#
|
182
|
-
#
|
183
|
-
#
|
184
|
-
#
|
185
|
-
#
|
186
|
-
#
|
187
|
-
#
|
188
|
-
#
|
189
|
-
#
|
180
|
+
# @param array [Array<Hash>] array of text fragments. See
|
181
|
+
# {Text::Formatted#formatted_text_box} for more information on the
|
182
|
+
# structure of this array.
|
183
|
+
# @param options [Hash{Symbol => any}]
|
184
|
+
# @option options :inline_format [Boolean]
|
185
|
+
# If `true`, then the string parameter is interpreted as a HTML-esque
|
186
|
+
# string that recognizes the following tags (assuming the default text
|
187
|
+
# formatter is used):
|
188
|
+
# - `<b></b>`{:.language-html} --- bold style.
|
189
|
+
# - `<i></i>`{:.language-html} --- italic style.
|
190
|
+
# - `<u></u>`{:.language-html} --- underline.
|
191
|
+
# - `<strikethrough></strikethrough>`{:.language-html} --- strikethrough.
|
192
|
+
# - `<sub></sub>`{:.language-html} --- subscript.
|
193
|
+
# - `<sup></sup>`{:.language-html} --- superscript.
|
194
|
+
# - `<font></font>`{:.language-html} --- with the following attributes
|
195
|
+
# (using double or single quotes):
|
196
|
+
# - `name="Helvetica"`{:.language-html} --- the font. The font name must
|
197
|
+
# be an AFM font with the desired faces or must be a font that is
|
198
|
+
# already registered using {Prawn::Document#font_families}.
|
199
|
+
# - `size="24"`{:.language-html} --- attribute for setting size.
|
200
|
+
# - `character_spacing="2.5"`{:.language-html} --- character spacing.
|
201
|
+
# - `<color></color>`{:.language-html} --- text color
|
202
|
+
# - `rgb="ffffff"`{:.language-html} or `rgb="#ffffff"`{:.language-html}
|
203
|
+
# --- RGB color
|
204
|
+
# - `c="100" m="100" y="100" k="100"`{:.language-html} --- CMYK color
|
205
|
+
# - `<link></link>`{:.language-html} - link, with the following
|
206
|
+
# attributes:
|
207
|
+
# - `href="http://example.com"`{:.language-html} --- an external link.
|
208
|
+
# Note that you must explicitly underline and color using the
|
209
|
+
# appropriate tags if you which to draw attention to the link.
|
210
|
+
# @option options :kerning [Boolean] (value of document.default_kerning?)
|
211
|
+
# Whether or not to use kerning (if it is available with the current
|
212
|
+
# font).
|
213
|
+
# @option options :size [Number] (current ofnt size) The font size to use.
|
214
|
+
# @option options :color [Color]
|
215
|
+
# @option options :character_spacing [Number] (0)
|
216
|
+
# The amount of space to add to or remove from the default character
|
217
|
+
# spacing.
|
218
|
+
# @option options :style [Symbol] (current style)
|
219
|
+
# The style to use. The requested style must be part of the current font
|
220
|
+
# family.
|
221
|
+
# @option options :indent_paragraphs [Number]
|
222
|
+
# The amount to indent the first line of each paragraph. Omit this option
|
223
|
+
# if you do not want indenting.
|
224
|
+
# @option options :direction [:ltr, :rtl] (value of document.text_direction)
|
225
|
+
# Direction of the text.
|
226
|
+
# @option options :fallback_fonts [Array<String>]
|
227
|
+
# An array of font names. Each name must be the name of an AFM font or the
|
228
|
+
# name that was used to register a family of TTF fonts (see
|
229
|
+
# {Prawn::Document#font_families}). If present, then each glyph will be
|
230
|
+
# rendered using the first font that includes the glyph, starting with the
|
231
|
+
# current font and then moving through `:fallback_fonts`.
|
232
|
+
# @option option :align [:left, :center, :right, :justify]
|
233
|
+
# (:left if direction is :ltr, :right if direction is :rtl)
|
234
|
+
# Alignment within the bounding box.
|
235
|
+
# @option options :valign [:top, :center, :bottom] (:top)
|
236
|
+
# Vertical alignment within the bounding box.
|
237
|
+
# @option options :leading (Number) (value of document.default_leading)
|
238
|
+
# Additional space between lines.
|
239
|
+
# @option options :final_gap [Boolean] (true)
|
240
|
+
# If `true`, then the space between each line is included below the last
|
241
|
+
# line; otherwise, {Document.y} is placed just below the descender of the
|
242
|
+
# last line printed.
|
243
|
+
# @option options :mode [Symbol] (:fill)
|
244
|
+
# The text rendering mode to use. Use this to specify if the text should
|
245
|
+
# render with the fill color, stroke color or both.
|
246
|
+
# * `:fill` - fill text (default)
|
247
|
+
# * `:stroke` - stroke text
|
248
|
+
# * `:fill_stroke` - fill, then stroke text
|
249
|
+
# * `:invisible` - invisible text
|
250
|
+
# * `:fill_clip` - fill text then add to path for clipping
|
251
|
+
# * `:stroke_clip` - stroke text then add to path for clipping
|
252
|
+
# * `:fill_stroke_clip` - fill then stroke text, then add to path for
|
253
|
+
# clipping
|
254
|
+
# * `:clip` - add text to path for clipping
|
255
|
+
#
|
256
|
+
# @return [void]
|
257
|
+
#
|
258
|
+
# @raise [ArgumentError] if `:at` option included
|
259
|
+
# @raise [Prawn::Errrors::CannotFit] if not wide enough to print any text
|
260
|
+
#
|
261
|
+
# @see PDF::Core::Text#text_rendering_mode()
|
262
|
+
# for a list of valid text rendering modes.
|
190
263
|
def formatted_text(array, options = {})
|
191
264
|
options = inspect_options_for_text(options.dup)
|
192
265
|
|
193
266
|
color = options.delete(:color)
|
194
267
|
if color
|
195
268
|
array =
|
196
|
-
array.map
|
269
|
+
array.map { |fragment|
|
197
270
|
fragment[:color] ? fragment : fragment.merge(color: color)
|
198
|
-
|
271
|
+
}
|
199
272
|
end
|
200
273
|
|
201
274
|
if @indent_paragraphs
|
@@ -218,61 +291,57 @@ module Prawn
|
|
218
291
|
end
|
219
292
|
end
|
220
293
|
|
221
|
-
# Draws text on the page, beginning at the point specified by the
|
222
|
-
# the string is assumed to be pre-formatted to properly fit the page.
|
294
|
+
# Draws text on the page, beginning at the point specified by the `:at`
|
295
|
+
# option the string is assumed to be pre-formatted to properly fit the page.
|
223
296
|
#
|
224
|
-
#
|
225
|
-
#
|
297
|
+
# ```ruby
|
298
|
+
# pdf.draw_text "Hello World", at: [100, 100]
|
299
|
+
# pdf.draw_text "Goodbye World", at: [50,50], size: 16
|
300
|
+
# ```
|
226
301
|
#
|
227
302
|
# If your font contains kerning pair data that Prawn can parse, the
|
228
303
|
# text will be kerned by default. You can disable kerning by including
|
229
|
-
# a false
|
230
|
-
# entire document, set default_kerning = false for that document
|
304
|
+
# a `false` `:kerning` option. If you want to disable kerning on an
|
305
|
+
# entire document, set `default_kerning = false` for that document
|
231
306
|
#
|
232
|
-
#
|
307
|
+
# #### Text Positioning Details
|
233
308
|
#
|
234
309
|
# Prawn will position your text by the left-most edge of its baseline, and
|
235
|
-
# flow along a single line.
|
310
|
+
# flow along a single line. (This means that `:align` will not work)
|
236
311
|
#
|
237
|
-
#
|
312
|
+
# #### Rotation
|
238
313
|
#
|
239
314
|
# Text can be rotated before it is placed on the canvas by specifying the
|
240
|
-
#
|
241
|
-
# counter-clockwise.
|
315
|
+
# `:rotate` option with a given angle. Rotation occurs counter-clockwise.
|
242
316
|
#
|
243
|
-
#
|
317
|
+
# #### Encoding
|
244
318
|
#
|
245
|
-
# Note that strings passed to this function should be encoded as UTF-8.
|
246
|
-
#
|
247
|
-
#
|
319
|
+
# Note that strings passed to this function should be encoded as UTF-8. If
|
320
|
+
# you get unexpected characters appearing in your rendered document, check
|
321
|
+
# this.
|
248
322
|
#
|
249
|
-
# If the current font is a built-in one, although the string must be
|
250
|
-
#
|
251
|
-
# are allowed.
|
323
|
+
# If the current font is a built-in one, although the string must be encoded
|
324
|
+
# as UTF-8, only characters that are available in WinAnsi are allowed.
|
252
325
|
#
|
253
326
|
# If an empty box is rendered to your PDF instead of the character you
|
254
327
|
# wanted it usually means the current font doesn't include that character.
|
255
328
|
#
|
256
|
-
#
|
257
|
-
#
|
258
|
-
#
|
259
|
-
#
|
260
|
-
#
|
261
|
-
#
|
262
|
-
#
|
263
|
-
#
|
264
|
-
#
|
265
|
-
#
|
266
|
-
#
|
267
|
-
#
|
268
|
-
#
|
269
|
-
#
|
270
|
-
#
|
271
|
-
#
|
272
|
-
# Raises <tt>ArgumentError</tt> if <tt>:at</tt> option omitted
|
273
|
-
#
|
274
|
-
# Raises <tt>ArgumentError</tt> if <tt>:align</tt> option included
|
275
|
-
#
|
329
|
+
# @param text [String]
|
330
|
+
# @param options [Hash{Symbol => any}]
|
331
|
+
# @option options :at [Array(Number, Number)] **Required**.
|
332
|
+
# The position at which to start the text.
|
333
|
+
# @option options :kerning [Boolean] (value of default_kerning?)
|
334
|
+
# Whether or not to use kerning (if it is available with the current
|
335
|
+
# font).
|
336
|
+
# @option options :size [Number] (current font size)
|
337
|
+
# The font size to use.
|
338
|
+
# @option options :style [Symbol] (current style)
|
339
|
+
# The style to use. The requested style must be part of the current font
|
340
|
+
# family.
|
341
|
+
# @option options :rotate [Number] The angle to which to rotate text.
|
342
|
+
# @return [void]
|
343
|
+
# @raise [ArgumentError]
|
344
|
+
# If `:at` option is omitted or `:align</tt> option is included.
|
276
345
|
def draw_text(text, options)
|
277
346
|
options = inspect_options_for_draw_text(options.dup)
|
278
347
|
|
@@ -285,16 +354,33 @@ module Prawn
|
|
285
354
|
end
|
286
355
|
end
|
287
356
|
|
288
|
-
# Low level text placement method.
|
289
|
-
#
|
290
|
-
#
|
357
|
+
# Low level text placement method.
|
358
|
+
#
|
359
|
+
# All font and size alterations should already be set.
|
360
|
+
#
|
361
|
+
# @param text [String]
|
362
|
+
# @param options [Hash{Symbol => any}]
|
363
|
+
# @option options :at [Array(Number, Number)]
|
364
|
+
# The position at which to start the text.
|
365
|
+
# @option options :kerning [Boolean]
|
366
|
+
# Whether or not to use kerning (if it is available with the current
|
367
|
+
# font).
|
368
|
+
# @option options :size [Number]
|
369
|
+
# The font size to use.
|
370
|
+
# @option options :style [Symbol]
|
371
|
+
# The style to use. The requested style must be part of the current font
|
372
|
+
# family.
|
373
|
+
# @option options :rotate [Number] The angle to which to rotate text.
|
374
|
+
# @return [void]
|
291
375
|
def draw_text!(text, options)
|
292
376
|
unless font.unicode? || font.class.hide_m17n_warning || text.ascii_only?
|
293
|
-
warn
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
377
|
+
warn(
|
378
|
+
"PDF's built-in fonts have very limited support for " \
|
379
|
+
"internationalized text.\nIf you need full UTF-8 support, " \
|
380
|
+
"consider using an external font instead.\n\nTo disable this " \
|
381
|
+
"warning, add the following line to your code:\n" \
|
382
|
+
"Prawn::Fonts::AFM.hide_m17n_warning = true\n",
|
383
|
+
)
|
298
384
|
|
299
385
|
font.class.hide_m17n_warning = true
|
300
386
|
end
|
@@ -304,35 +390,188 @@ module Prawn
|
|
304
390
|
end
|
305
391
|
|
306
392
|
# Gets height of text in PDF points.
|
307
|
-
# Same options as #text, except as noted.
|
308
|
-
# Not compatible with :indent_paragraphs option
|
309
|
-
#
|
310
|
-
# ==Example
|
311
|
-
#
|
312
|
-
# height_of("hello\nworld")
|
313
|
-
#
|
314
|
-
# == Exceptions
|
315
|
-
#
|
316
|
-
# Raises <tt>NotImplementedError</tt> if <tt>:indent_paragraphs</tt>
|
317
|
-
# option included
|
318
|
-
#
|
319
|
-
# Raises <tt>Prawn::Errrors::CannotFit</tt> if not wide enough to print
|
320
|
-
# any text
|
321
393
|
#
|
394
|
+
# @note This method takes the same options as {#text}, _except_
|
395
|
+
# `:indent_paragraphs`.
|
396
|
+
#
|
397
|
+
# @example
|
398
|
+
# text_height = height_of("hello\nworld")
|
399
|
+
#
|
400
|
+
# @param string [String]
|
401
|
+
# @param options [Hash{Symbol => any}]
|
402
|
+
# @option options :inline_format [Boolean]
|
403
|
+
# If `true`, then the string parameter is interpreted as a HTML-esque
|
404
|
+
# string that recognizes the following tags (assuming the default text
|
405
|
+
# formatter is used):
|
406
|
+
# - `<b></b>`{:.language-html} --- bold style.
|
407
|
+
# - `<i></i>`{:.language-html} --- italic style.
|
408
|
+
# - `<u></u>`{:.language-html} --- underline.
|
409
|
+
# - `<strikethrough></strikethrough>`{:.language-html} --- strikethrough.
|
410
|
+
# - `<sub></sub>`{:.language-html} --- subscript.
|
411
|
+
# - `<sup></sup>`{:.language-html} --- superscript.
|
412
|
+
# - `<font></font>`{:.language-html} --- with the following attributes
|
413
|
+
# (using double or single quotes):
|
414
|
+
# - `name="Helvetica"`{:.language-html} --- the font. The font name must
|
415
|
+
# be an AFM font with the desired faces or must be a font that is
|
416
|
+
# already registered using {Prawn::Document#font_families}.
|
417
|
+
# - `size="24"`{:.language-html} --- attribute for setting size.
|
418
|
+
# - `character_spacing="2.5"`{:.language-html} --- character spacing.
|
419
|
+
# - `<color></color>`{:.language-html} --- text color
|
420
|
+
# - `rgb="ffffff"`{:.language-html} or `rgb="#ffffff"`{:.language-html}
|
421
|
+
# --- RGB color
|
422
|
+
# - `c="100" m="100" y="100" k="100"`{:.language-html} --- CMYK color
|
423
|
+
# - `<link></link>`{:.language-html} - link, with the following
|
424
|
+
# attributes:
|
425
|
+
# - `href="http://example.com"`{:.language-html} --- an external link.
|
426
|
+
# Note that you must explicitly underline and color using the
|
427
|
+
# appropriate tags if you which to draw attention to the link.
|
428
|
+
# @option options :kerning [Boolean] (value of document.default_kerning?)
|
429
|
+
# Whether or not to use kerning (if it is available with the current
|
430
|
+
# font).
|
431
|
+
# @option options :size [Number] (current ofnt size) The font size to use.
|
432
|
+
# @option options :color [Color]
|
433
|
+
# @option options :character_spacing [Number] (0)
|
434
|
+
# The amount of space to add to or remove from the default character
|
435
|
+
# spacing.
|
436
|
+
# @option options :style [Symbol] (current style)
|
437
|
+
# The style to use. The requested style must be part of the current font
|
438
|
+
# family.
|
439
|
+
# @option options :direction [:ltr, :rtl] (value of document.text_direction)
|
440
|
+
# Direction of the text.
|
441
|
+
# @option options :fallback_fonts [Array<String>]
|
442
|
+
# An array of font names. Each name must be the name of an AFM font or the
|
443
|
+
# name that was used to register a family of TTF fonts (see
|
444
|
+
# {Prawn::Document#font_families}). If present, then each glyph will be
|
445
|
+
# rendered using the first font that includes the glyph, starting with the
|
446
|
+
# current font and then moving through `:fallback_fonts`.
|
447
|
+
# @option option :align [:left, :center, :right, :justify]
|
448
|
+
# (:left if direction is :ltr, :right if direction is :rtl)
|
449
|
+
# Alignment within the bounding box.
|
450
|
+
# @option options :valign [:top, :center, :bottom] (:top)
|
451
|
+
# Vertical alignment within the bounding box.
|
452
|
+
# @option options :leading (Number) (value of document.default_leading)
|
453
|
+
# Additional space between lines.
|
454
|
+
# @option options :final_gap [Boolean] (true)
|
455
|
+
# If `true`, then the space between each line is included below the last
|
456
|
+
# line; otherwise, {Document.y} is placed just below the descender of the
|
457
|
+
# last line printed.
|
458
|
+
# @option options :mode [Symbol] (:fill)
|
459
|
+
# The text rendering mode to use. Use this to specify if the text should
|
460
|
+
# render with the fill color, stroke color or both.
|
461
|
+
# * `:fill` - fill text (default)
|
462
|
+
# * `:stroke` - stroke text
|
463
|
+
# * `:fill_stroke` - fill, then stroke text
|
464
|
+
# * `:invisible` - invisible text
|
465
|
+
# * `:fill_clip` - fill text then add to path for clipping
|
466
|
+
# * `:stroke_clip` - stroke text then add to path for clipping
|
467
|
+
# * `:fill_stroke_clip` - fill then stroke text, then add to path for
|
468
|
+
# clipping
|
469
|
+
# * `:clip` - add text to path for clipping
|
470
|
+
#
|
471
|
+
# @return [void]
|
472
|
+
#
|
473
|
+
# @raise [ArgumentError] if `:at` option included
|
474
|
+
# @raise [Prawn::Errrors::CannotFit] if not wide enough to print any text
|
475
|
+
# @raise [NotImplementedError] if `:indent_paragraphs` option included.
|
476
|
+
#
|
477
|
+
# @see PDF::Core::Text#text_rendering_mode()
|
478
|
+
# for a list of valid text rendering modes.
|
479
|
+
# @see height_of_formatted
|
322
480
|
def height_of(string, options = {})
|
323
481
|
height_of_formatted([{ text: string }], options)
|
324
482
|
end
|
325
483
|
|
326
484
|
# Gets height of formatted text in PDF points.
|
327
|
-
# See documentation for #height_of.
|
328
485
|
#
|
329
|
-
#
|
486
|
+
# @note This method takes the same options as {#text}, _except_
|
487
|
+
# `:indent_paragraphs`.
|
330
488
|
#
|
489
|
+
# @example
|
331
490
|
# height_of_formatted([{ :text => "hello" },
|
332
491
|
# { :text => "world",
|
333
492
|
# :size => 24,
|
334
493
|
# :styles => [:bold, :italic] }])
|
335
494
|
#
|
495
|
+
# @param array [Array<Hash>] text fragments.
|
496
|
+
# @param options [Hash{Symbol => any}]
|
497
|
+
# @option options :inline_format [Boolean]
|
498
|
+
# If `true`, then the string parameter is interpreted as a HTML-esque
|
499
|
+
# string that recognizes the following tags (assuming the default text
|
500
|
+
# formatter is used):
|
501
|
+
# - `<b></b>`{:.language-html} --- bold style.
|
502
|
+
# - `<i></i>`{:.language-html} --- italic style.
|
503
|
+
# - `<u></u>`{:.language-html} --- underline.
|
504
|
+
# - `<strikethrough></strikethrough>`{:.language-html} --- strikethrough.
|
505
|
+
# - `<sub></sub>`{:.language-html} --- subscript.
|
506
|
+
# - `<sup></sup>`{:.language-html} --- superscript.
|
507
|
+
# - `<font></font>`{:.language-html} --- with the following attributes
|
508
|
+
# (using double or single quotes):
|
509
|
+
# - `name="Helvetica"`{:.language-html} --- the font. The font name must
|
510
|
+
# be an AFM font with the desired faces or must be a font that is
|
511
|
+
# already registered using {Prawn::Document#font_families}.
|
512
|
+
# - `size="24"`{:.language-html} --- attribute for setting size.
|
513
|
+
# - `character_spacing="2.5"`{:.language-html} --- character spacing.
|
514
|
+
# - `<color></color>`{:.language-html} --- text color
|
515
|
+
# - `rgb="ffffff"`{:.language-html} or `rgb="#ffffff"`{:.language-html}
|
516
|
+
# --- RGB color
|
517
|
+
# - `c="100" m="100" y="100" k="100"`{:.language-html} --- CMYK color
|
518
|
+
# - `<link></link>`{:.language-html} - link, with the following
|
519
|
+
# attributes:
|
520
|
+
# - `href="http://example.com"`{:.language-html} --- an external link.
|
521
|
+
# Note that you must explicitly underline and color using the
|
522
|
+
# appropriate tags if you which to draw attention to the link.
|
523
|
+
# @option options :kerning [Boolean] (value of document.default_kerning?)
|
524
|
+
# Whether or not to use kerning (if it is available with the current
|
525
|
+
# font).
|
526
|
+
# @option options :size [Number] (current ofnt size) The font size to use.
|
527
|
+
# @option options :color [Color]
|
528
|
+
# @option options :character_spacing [Number] (0)
|
529
|
+
# The amount of space to add to or remove from the default character
|
530
|
+
# spacing.
|
531
|
+
# @option options :style [Symbol] (current style)
|
532
|
+
# The style to use. The requested style must be part of the current font
|
533
|
+
# family.
|
534
|
+
# @option options :direction [:ltr, :rtl] (value of document.text_direction)
|
535
|
+
# Direction of the text.
|
536
|
+
# @option options :fallback_fonts [Array<String>]
|
537
|
+
# An array of font names. Each name must be the name of an AFM font or the
|
538
|
+
# name that was used to register a family of TTF fonts (see
|
539
|
+
# {Prawn::Document#font_families}). If present, then each glyph will be
|
540
|
+
# rendered using the first font that includes the glyph, starting with the
|
541
|
+
# current font and then moving through `:fallback_fonts`.
|
542
|
+
# @option option :align [:left, :center, :right, :justify]
|
543
|
+
# (:left if direction is :ltr, :right if direction is :rtl)
|
544
|
+
# Alignment within the bounding box.
|
545
|
+
# @option options :valign [:top, :center, :bottom] (:top)
|
546
|
+
# Vertical alignment within the bounding box.
|
547
|
+
# @option options :leading (Number) (value of document.default_leading)
|
548
|
+
# Additional space between lines.
|
549
|
+
# @option options :final_gap [Boolean] (true)
|
550
|
+
# If `true`, then the space between each line is included below the last
|
551
|
+
# line; otherwise, {Document.y} is placed just below the descender of the
|
552
|
+
# last line printed.
|
553
|
+
# @option options :mode [Symbol] (:fill)
|
554
|
+
# The text rendering mode to use. Use this to specify if the text should
|
555
|
+
# render with the fill color, stroke color or both.
|
556
|
+
# * `:fill` - fill text (default)
|
557
|
+
# * `:stroke` - stroke text
|
558
|
+
# * `:fill_stroke` - fill, then stroke text
|
559
|
+
# * `:invisible` - invisible text
|
560
|
+
# * `:fill_clip` - fill text then add to path for clipping
|
561
|
+
# * `:stroke_clip` - stroke text then add to path for clipping
|
562
|
+
# * `:fill_stroke_clip` - fill then stroke text, then add to path for
|
563
|
+
# clipping
|
564
|
+
# * `:clip` - add text to path for clipping
|
565
|
+
#
|
566
|
+
# @return [void]
|
567
|
+
#
|
568
|
+
# @raise [ArgumentError] if `:at` option included
|
569
|
+
# @raise [Prawn::Errrors::CannotFit] if not wide enough to print any text
|
570
|
+
# @raise [NotImplementedError] if `:indent_paragraphs` option included.
|
571
|
+
#
|
572
|
+
# @see PDF::Core::Text#text_rendering_mode()
|
573
|
+
# for a list of valid text rendering modes.
|
574
|
+
# @see height_of
|
336
575
|
def height_of_formatted(array, options = {})
|
337
576
|
if options[:indent_paragraphs]
|
338
577
|
raise NotImplementedError,
|
@@ -341,7 +580,7 @@ module Prawn
|
|
341
580
|
process_final_gap_option(options)
|
342
581
|
box = Text::Formatted::Box.new(
|
343
582
|
array,
|
344
|
-
options.merge(height: 100_000_000, document: self)
|
583
|
+
options.merge(height: 100_000_000, document: self),
|
345
584
|
)
|
346
585
|
box.render(dry_run: true)
|
347
586
|
|
@@ -382,7 +621,13 @@ module Prawn
|
|
382
621
|
@all_text_printed = box.everything_printed?
|
383
622
|
|
384
623
|
self.y -= box.height
|
385
|
-
|
624
|
+
|
625
|
+
# If there's no remaining_text we don't really want to treat this line
|
626
|
+
# in a special way, we printed everything we wanted so the special
|
627
|
+
# single_line logic should not be triggered here.
|
628
|
+
if @final_gap || (options[:single_line] && !@all_text_printed)
|
629
|
+
self.y -= box.line_gap + box.leading
|
630
|
+
end
|
386
631
|
|
387
632
|
remaining_text
|
388
633
|
end
|
@@ -399,7 +644,7 @@ module Prawn
|
|
399
644
|
options[:width] = bounds.width
|
400
645
|
options[:at] = [
|
401
646
|
@bounding_box.left_side - @bounding_box.absolute_left,
|
402
|
-
y - @bounding_box.absolute_bottom
|
647
|
+
y - @bounding_box.absolute_bottom,
|
403
648
|
]
|
404
649
|
end
|
405
650
|
|
@@ -422,7 +667,7 @@ module Prawn
|
|
422
667
|
if options[:at]
|
423
668
|
raise ArgumentError,
|
424
669
|
':at is no longer a valid option with text.' \
|
425
|
-
|
670
|
+
'use draw_text or text_box instead'
|
426
671
|
end
|
427
672
|
process_final_gap_option(options)
|
428
673
|
process_indent_paragraphs_option(options)
|