Skip to content

Commit

Permalink
Merge branch 'master' of github.com:prawnpdf/prawn
Browse files Browse the repository at this point in the history
  • Loading branch information
practicingruby committed Oct 30, 2014
2 parents faa0963 + 4ac30fb commit ddc5884
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 33 deletions.
30 changes: 0 additions & 30 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,3 @@ to file a ticket or file one on your behalf.
3. Pull requests for bug fixes or enhancements are welcome. Feel free to open
them in the early stages of your work so that we can give feedback
and discuss ideas together.

Please note that Prawn has had a rough couple of years, and so our forward
progress has slowed down quite a bit. To make it to a 1.0 release, we need
to work on just the most essential things, but our long-term goal is to
make this project as friendly to contributors as possible.

Here are some notes on our issue tracker process:

* We will close pull requests that need revisions, after tagging them
with a "needs-revision" tag. Once the revisions are made, you can
comment on the pull request and we'll review it again.

* We may close any issue after 30 days of inactivity, labeling it
with a 'stale' tag. To re-open it, simply leave a comment on
the issue. If there is a proper example in place and the
issue still is relevant, we will open it back up.

* We will close all incoming issues related to the currently
unmaintained templates feature, marking them with a 'templates'
tag. These will remained archived in our tracker until
someone else starts maintaining prawn-templates, but we
cannot provide any help for this unsupported feature at
this point in time.

These are all temporary measures, and will be revised once we
hit 1.0. The underlying goal is to keep the issue tracker full
of actionable issues that we can respond to in a timely fashion,
not to sweep unresolved issues under the rug!

Thanks for your patience, and happy Prawning.
7 changes: 5 additions & 2 deletions lib/prawn/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ module Text
# the current font familly. [current style]
# <tt>:indent_paragraphs</tt>:: <tt>number</tt>. The amount to indent the
# first line of each paragraph. Omit this
# option if you do not want indenting
# option if you do not want indenting.
# <tt>:direction</tt>::
# <tt>:ltr</tt>, <tt>:rtl</tt>, Direction of the text (left-to-right
# or right-to-left) [value of document.text_direction]
Expand Down Expand Up @@ -359,7 +359,10 @@ def draw_remaining_formatted_text_on_new_pages(remaining_text, options)
end

def draw_indented_formatted_line(string, options)
indent(@indent_paragraphs) do
gap = options.fetch(:direction, :ltr) == :ltr ?
[@indent_paragraphs, 0] : [0, @indent_paragraphs]

indent(*gap) do
fill_formatted_text_box(string, options.dup.merge(:single_line => true))
end
end
Expand Down
8 changes: 8 additions & 0 deletions manual/text/paragraph_indentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,12 @@
text "This paragraph will be indented. " * 10 +
"\n" + "This one will too. " * 10,
:indent_paragraphs => 60

move_down 20

text "FROM RIGHT TO LEFT:"
text "This paragraph will be indented. " * 10 +
"\n" + "This one will too. " * 10,
:indent_paragraphs => 60, :direction => :rtl

end
2 changes: 1 addition & 1 deletion prawn.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
spec.add_dependency('ttfunk', '~> 1.4.0')
spec.add_dependency('pdf-core', "~> 0.5.0")

spec.add_development_dependency('pdf-inspector', '~> 1.1.0')
spec.add_development_dependency('pdf-inspector', '~> 1.2.0')
spec.add_development_dependency('yard')
spec.add_development_dependency('rspec', '2.14.1')
spec.add_development_dependency('mocha')
Expand Down
51 changes: 51 additions & 0 deletions spec/text_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,57 @@
text.strings[3].should == ("hello " * 19).strip
text.strings[4].should == ("hello " * 21).strip
end


it "should indent from right side when using :rtl direction" do
para1 = "The rain in spain falls mainly on the plains " * 3
para2 = "The rain in spain falls mainly on the plains " * 3

@pdf.text(para1 + "\n" + para2, :indent_paragraphs => 60, :direction => :rtl)

text = PDF::Inspector::Text.analyze(@pdf.render)

lines = text.strings
x_positions = text.positions.map { |e| e[0] }

# NOTE: The code below reflects Prawn's current kerning behavior for RTL
# text, which isn't necessarily correct. If we change that behavior,
# this test will need to be updated.

x_positions[0].should(
be_within(0.001).of(@pdf.bounds.absolute_right - 60 -
@pdf.width_of(lines[0].reverse, :kerning => true)))

x_positions[1].should(
be_within(0.001).of(@pdf.bounds.absolute_right -
@pdf.width_of(lines[1].reverse, :kerning => true)))

x_positions[2].should(
be_within(0.001).of(@pdf.bounds.absolute_right - 60 -
@pdf.width_of(lines[2].reverse, :kerning => true)))

x_positions[3].should(
be_within(0.001).of(@pdf.bounds.absolute_right -
@pdf.width_of(lines[3].reverse, :kerning => true)))
end

it "should indent from right side when using :ltr direction" do
para1 = "The rain in spain falls mainly on the plains " * 3
para2 = "The rain in spain falls mainly on the plains " * 3

@pdf.text(para1 + "\n" + para2, :indent_paragraphs => 60, :direction => :ltr)

text = PDF::Inspector::Text.analyze(@pdf.render)

x_positions = text.positions.map { |e| e[0] }

x_positions[0].should == 60
x_positions[1].should == 0

x_positions[2].should == 60
x_positions[3].should == 0
end

describe "when wrap to new page, and first line of new page" +
" is not the start of a new paragraph, that line should" +
" not be indented" do
Expand Down

0 comments on commit ddc5884

Please sign in to comment.