Text size is now reduced before being truncated if min and max sizes are given in the config.

pull/6827/head
Richard 11 years ago
parent c6686168b3
commit 1a22dcdb35
  1. 27
      lib/open_project/pdf_export/export_card/column_element.rb

@ -25,7 +25,27 @@ module OpenProject::PdfExport::ExportCard
text = text + "#{@work_package.class.human_attribute_name(@property_name)}: " if has_label
text = text + value
font_size = Integer(@config['font_size']) # TODO: Not safe!
# Font size
if @config['font_size']
# Specific size given
overflow = :truncate
font_size = Integer(@config['font_size'])
elsif @config['min_font_size']
# Range given
overflow = :shrink_to_fit
min_font_size = Integer(@config['min_font_size'])
font_size = if @config['max_font_size']
Integer(@config['max_font_size'])
else
min_font_size
end
else
# Default
font_size = 12
overflow = :truncate
end
font_style = (@config['font_style'] or "normal").to_sym
text_align = (@config['text_align'] or "left").to_sym
@ -35,9 +55,10 @@ module OpenProject::PdfExport::ExportCard
{:height => @orientation[:height],
:width => @orientation[:width],
:at => offset,
:size => font_size,
:style => font_style,
:overflow => :truncate,
:overflow => overflow,
:size => font_size,
:min_font_size => min_font_size,
:align => text_align})
end

Loading…
Cancel
Save