diff --git a/lib/prawn/document.rb b/lib/prawn/document.rb
index a51f87483..30a4a9755 100644
--- a/lib/prawn/document.rb
+++ b/lib/prawn/document.rb
@@ -23,18 +23,18 @@ class Document
# The explicit receiver argument is necessary only when you need to make
# use of a closure.
#
- # # Using implicit block form and rendering to a file
- # Prawn::Document.generate "foo.pdf" do
- # font "Times-Roman"
- # text "Hello World", :at => [200,720], :size => 32
- # end
- #
- # # Using explicit block form and rendering to a file
- # content = "Hello World"
- # Prawn::Document.generate "foo.pdf" do |pdf|
- # pdf.font "Times-Roman"
- # pdf.text content, :at => [200,720], :size => 32
- # end
+ # # Using implicit block form and rendering to a file
+ # Prawn::Document.generate "foo.pdf" do
+ # font "Times-Roman"
+ # text "Hello World", :at => [200,720], :size => 32
+ # end
+ #
+ # # Using explicit block form and rendering to a file
+ # content = "Hello World"
+ # Prawn::Document.generate "foo.pdf" do |pdf|
+ # pdf.font "Times-Roman"
+ # pdf.text content, :at => [200,720], :size => 32
+ # end
#
def self.generate(filename,options={},&block)
pdf = Prawn::Document.new(options)
@@ -44,25 +44,25 @@ def self.generate(filename,options={},&block)
# Creates a new PDF Document. The following options are available:
#
- # :page_size:: One of the Document::PageGeometry::SIZES (default: LETTER)
+ # :page_size:: One of the Document::PageGeometry::SIZES [LETTER]
# :page_layout:: Either :portrait or :landscape
# :on_page_start:: Optional proc run at each page start
# :on_page_stop:: Optional proc run at each page stop
- # :left_margin:: Sets the left margin in points [default: 0.5 inch]
- # :right_margin:: Sets the right margin in points [default: 0.5 inch]
- # :top_margin:: Sets the top margin in points [default: 0.5 inch]
- # :bottom_margin:: Sets the bottom margin in points [default: 0.5 inch]
+ # :left_margin:: Sets the left margin in points [ 0.5 inch]
+ # :right_margin:: Sets the right margin in points [ 0.5 inch]
+ # :top_margin:: Sets the top margin in points [ 0.5 inch]
+ # :bottom_margin:: Sets the bottom margin in points [0.5 inch]
#
#
- # # New document, US Letter paper, portrait orientation
- # pdf = Prawn::Document.new
+ # # New document, US Letter paper, portrait orientation
+ # pdf = Prawn::Document.new
#
- # # New document, A4 paper, landscaped
- # pdf = Prawn::Document.new(:page_size => "A4", :page_layout => :landscape)
+ # # New document, A4 paper, landscaped
+ # pdf = Prawn::Document.new(:page_size => "A4", :page_layout => :landscape)
#
- # # New document, draws a line at the start of each new page
- # pdf = Prawn::Document.new(:on_page_start =>
- # lambda { |doc| doc.line [0,100], [300,100] } )
+ # # New document, draws a line at the start of each new page
+ # pdf = Prawn::Document.new(:on_page_start =>
+ # lambda { |doc| doc.line [0,100], [300,100] } )
#
def initialize(options={})
@objects = []
@@ -118,10 +118,10 @@ def start_new_page
# Returns the number of pages in the document
#
- # pdf = Prawn::Document.new
- # pdf.page_count #=> 1
- # 3.times { pdf.start_new_page }
- # pdf.page_count #=> 4
+ # pdf = Prawn::Document.new
+ # pdf.page_count #=> 1
+ # 3.times { pdf.start_new_page }
+ # pdf.page_count #=> 4
def page_count
@pages.data[:Count]
end
@@ -141,7 +141,7 @@ def render
# Renders the PDF document to file.
#
- # pdf.render_file "foo.pdf"
+ # pdf.render_file "foo.pdf"
#
def render_file(filename)
File.open(filename,"wb") { |f| f << render }
diff --git a/lib/prawn/document/bounding_box.rb b/lib/prawn/document/bounding_box.rb
index 307ba5f05..f4be38051 100644
--- a/lib/prawn/document/bounding_box.rb
+++ b/lib/prawn/document/bounding_box.rb
@@ -28,14 +28,14 @@ class Document
# Take for example two triangles which share one point, drawn from the
# origin:
#
- # pdf.polygon [0,250], [0,0], [150,100]
- # pdf.polygon [100,0], [150,100], [200,0]
+ # pdf.polygon [0,250], [0,0], [150,100]
+ # pdf.polygon [100,0], [150,100], [200,0]
#
# It would be easy enough to translate these triangles to another point,
# e.g [200,200]
#
- # pdf.polygon [200,450], [200,200], [350,300]
- # pdf.polygon [300,200], [350,300], [400,200]
+ # pdf.polygon [200,450], [200,200], [350,300]
+ # pdf.polygon [300,200], [350,300], [400,200]
#
# However, each time you want to move the drawing, you'd need to alter
# every point in the drawing calls, which as you might imagine, can become
@@ -48,10 +48,10 @@ class Document
#
# Using the [200,200] example:
#
- # pdf.bounding_box([200,450], :width => 200, :height => 250) do
- # pdf.polygon [0,250], [0,0], [150,100]
- # pdf.polygon [100,0], [150,100], [200,0]
- # end
+ # pdf.bounding_box([200,450], :width => 200, :height => 250) do
+ # pdf.polygon [0,250], [0,0], [150,100]
+ # pdf.polygon [100,0], [150,100], [200,0]
+ # end
#
# Notice that the drawing is still relative to the origin. If we want to
# move this drawing around the document, we simply need to recalculate the
@@ -135,4 +135,4 @@ def height
end
end
end
-end
\ No newline at end of file
+end
diff --git a/lib/prawn/document/text.rb b/lib/prawn/document/text.rb
index ce1ddc739..84c21d6ad 100644
--- a/lib/prawn/document/text.rb
+++ b/lib/prawn/document/text.rb
@@ -27,9 +27,9 @@ module Text
# linebreaks, so if you want fully automated text wrapping, be sure to
# remove newlines before attempting to draw your string.
#
- # pdf.text "Hello World", :at => [100,100]
- # pdf.text "Goodbye World", :at => [50,50], :size => 16
- # pdf.text "Will be wrapped when it hits the edge of your bounding box"
+ # pdf.text "Hello World", :at => [100,100]
+ # pdf.text "Goodbye World", :at => [50,50], :size => 16
+ # pdf.text "Will be wrapped when it hits the edge of your bounding box"
#
# Under Ruby 1.8 compatible implementations, all strings passed to this
# function should be encoded as UTF-8. If you gets unexpected characters
@@ -89,8 +89,8 @@ def text(text,options={})
# fonts supported by PDF, or the location of a TTF file. The BUILT_INS
# array specifies the valid built in font values.
#
- # pdf.font "Times-Roman"
- # pdf.font "Chalkboard.ttf"
+ # pdf.font "Times-Roman"
+ # pdf.font "Chalkboard.ttf"
#
# If a ttf font is specified, the full file will be embedded in the
# rendered PDF. This should be your preferred option in most cases.
@@ -108,7 +108,23 @@ def font(name)
set_current_font
end
- # Sets the font size for all text nodes inside the block
+ # Sets the default font size for use within a block. Individual overrides
+ # can be used as desired. The previous font size will be stored after the
+ # block.
+ #
+ # Prawn::Document.generate("font_size.pdf") do
+ # font_size!(16)
+ # text "At size 16"
+ #
+ # font_size(10) do
+ # text "At size 10"
+ # text "At size 6", :size => 6
+ # text "At size 10"
+ # end
+ #
+ # text "At size 16"
+ # end
+ #
def font_size(size)
font_size_before_block = @font_size || DEFAULT_FONT_SIZE
font_size!(size)
@@ -116,7 +132,8 @@ def font_size(size)
font_size!(font_size_before_block)
end
- # Sets the default font size for the document
+ # Sets the default font size. See example in font_size
+ #
def font_size!(size)
@font_size = size unless size == nil
end
diff --git a/lib/prawn/font/cmap.rb b/lib/prawn/font/cmap.rb
index ebb21202f..3303393ce 100644
--- a/lib/prawn/font/cmap.rb
+++ b/lib/prawn/font/cmap.rb
@@ -6,7 +6,7 @@
module Prawn
module Font #:nodoc:
- class CMap
+ class CMap #:nodoc:
def initialize
@codes = {}
diff --git a/lib/prawn/font/metrics.rb b/lib/prawn/font/metrics.rb
index 942a4fe8d..0465ba861 100644
--- a/lib/prawn/font/metrics.rb
+++ b/lib/prawn/font/metrics.rb
@@ -9,7 +9,7 @@
module Prawn
module Font #:nodoc:
- class Metrics
+ class Metrics #:nodoc:
include Prawn::Font::Wrapping
diff --git a/lib/prawn/font/wrapping.rb b/lib/prawn/font/wrapping.rb
index f155b12cf..71fc6f185 100644
--- a/lib/prawn/font/wrapping.rb
+++ b/lib/prawn/font/wrapping.rb
@@ -4,8 +4,8 @@
#
# This is free software. Please see the LICENSE and COPYING files for details.
module Prawn
- module Font
- module Wrapping
+ module Font #:nodoc:
+ module Wrapping #:nodoc:
# TODO: Replace with TeX optimal algorithm
def naive_wrap(string, line_width, font_size)