Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add font_size Feature to PrawnTable's Text Cell #157

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/prawn/table/cell/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ def font_style=(style)
@text_options[:style] = style
end

# Set the font size
def font_size=(size)
@text_options[:size] = size
end

# Returns the width of this text with no wrapping. This will be far off
# from the final width if the text is long.
#
Expand Down
19 changes: 19 additions & 0 deletions spec/table/cell/text_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# encoding: utf-8

require File.join(File.expand_path(File.dirname(__FILE__)), "..", "..", "spec_helper")
require 'set'

describe Prawn::Table::Cell::Text do
let(:pdf) { Prawn::Document.new }
let(:data) { "Text data" }
let(:options) { { :font_size => 12 } }
let(:cell) { Prawn::Table::Cell::Text.new(pdf, [0, 0], :content => data, :text_options => options) }

describe "#font_size=" do
it "sets the font size in the text options" do
new_font_size = 10
cell.font_size = new_font_size
expect(cell.instance_variable_get("@text_options")[:size]).to eq(new_font_size)
end
end
end