Skip to content

Commit

Permalink
Permit setting the font everywhere
Browse files Browse the repository at this point in the history
-> Verify the fonts that are necessary for the report
  • Loading branch information
jungrafael committed Oct 7, 2015
1 parent 7a213fc commit f914b83
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test
2.times {r.line_break}
r.add_image do |i|
i.set_path 'data/example.svg'
i.size x: 10, y: 10
i.size x: 70, y: 10
end
r.line_break
r.add_paragraph do |p|
Expand Down
17 changes: 13 additions & 4 deletions lib/report/rtf_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def generate_report
p.line_break
else
character_style = RTF::CharacterStyle.new
character_style.font = RTF::Font.new(RTF::Font::MODERN, 'Courier')
character_style.font = font(report_element.font)
character_style.font_size = report_element.font_size*2 #Probably bug in the library
character_style.bold = report_text.font_style == :bold ? true : false

Expand All @@ -48,9 +48,7 @@ def generate_report
end
when 'Report::Table'
style = RTF::CharacterStyle.new
style.bold = true
style.underline = true

style.font = font(report_element.font)
report_element.set_table_dimensions

dim = report_element.table_dimensions
Expand Down Expand Up @@ -91,4 +89,15 @@ def justification position
RTF::ParagraphStyle::FULL_JUSTIFY
end
end

def font font_style
case font_style
when :courier
RTF::Font.new(RTF::Font::MODERN, 'Courier')
when :times_new_roman
RTF::Font.new(RTF::Font::ROMAN, 'Times New Roman')
when :arial
RTF::Font.new(RTF::Font::ROMAN, 'Arial')
end
end
end
2 changes: 1 addition & 1 deletion lib/report/table.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Report::Table
attr_accessor :table_data, :table_size, :table_dimensions
attr_accessor :table_data, :table_size, :table_dimensions, :font

def initialize(dimension_x, dimension_y)
@table_size = {x: dimension_x, y: dimension_y}
Expand Down

0 comments on commit f914b83

Please sign in to comment.