adapting font size to fit previous size with LiberationSerif

This commit is contained in:
Judith 2020-06-24 10:43:12 +02:00 committed by jpoulvel (Rebase PR Action)
parent c3a6f671c8
commit b7fe9418fd
3 changed files with 20 additions and 20 deletions

View file

@ -47,13 +47,13 @@ prawn_document(margin: [top_margin, right_margin, bottom_margin, left_margin], p
end end
pdf.fill_color grey pdf.fill_color grey
pdf.pad_top(40) { pdf.text "le #{l(created_at, format: '%e %B %Y')}", size: 10, align: :right, character_spacing: -0.5 } pdf.pad_top(40) { pdf.text "le #{l(created_at, format: '%e %B %Y')}", size: 9, align: :right, character_spacing: -0.5 }
pdf.fill_color black pdf.fill_color black
pdf.pad_top(40) { pdf.text title, size: 18, character_spacing: -0.2 } pdf.pad_top(40) { pdf.text title, size: 14, character_spacing: -0.2 }
pdf.fill_color grey pdf.fill_color grey
pdf.pad_top(30) { pdf.text body, size: 10, character_spacing: -0.2, align: :justify } pdf.pad_top(30) { pdf.text body, size: 9, character_spacing: -0.2, align: :justify }
if signature.present? if signature.present?
pdf.pad_top(40) do pdf.pad_top(40) do

View file

@ -8,7 +8,7 @@ def render_in_2_columns(pdf, label, text)
end end
def format_in_2_lines(pdf, champ, nb_lines = 1) def format_in_2_lines(pdf, champ, nb_lines = 1)
add_single_line(pdf, champ.libelle, 12, :bold) add_single_line(pdf, champ.libelle, 9, :bold)
add_optionnal_description(pdf, champ) add_optionnal_description(pdf, champ)
height = 10 * (nb_lines+1) height = 10 * (nb_lines+1)
pdf.bounding_box([0, pdf.cursor],:width => 460,:height => height) do pdf.bounding_box([0, pdf.cursor],:width => 460,:height => height) do
@ -27,7 +27,7 @@ def format_in_2_columns(pdf, label)
end end
def format_with_checkbox(pdf, label, offset = 0) def format_with_checkbox(pdf, label, offset = 0)
pdf.font 'marianne', size: 12 do pdf.font 'marianne', size: 9 do
pdf.stroke_rectangle [0 + offset, pdf.cursor], 10, 10 pdf.stroke_rectangle [0 + offset, pdf.cursor], 10, 10
pdf.text_box label, at: [15 + offset, pdf.cursor] pdf.text_box label, at: [15 + offset, pdf.cursor]
end end
@ -63,7 +63,7 @@ def add_identite_individual(pdf, dossier)
end end
def add_identite_etablissement(pdf, libelle) def add_identite_etablissement(pdf, libelle)
add_single_line(pdf, libelle, 12, :bold) add_single_line(pdf, libelle, 9, :bold)
format_in_2_columns(pdf, "SIRET") format_in_2_columns(pdf, "SIRET")
format_in_2_columns(pdf, "Dénomination") format_in_2_columns(pdf, "Dénomination")
@ -77,12 +77,12 @@ def add_single_line(pdf, libelle, size, style)
end end
def add_title(pdf, title) def add_title(pdf, title)
add_single_line(pdf, title, 24, :bold) add_single_line(pdf, title, 20, :bold)
pdf.text "\n" pdf.text "\n"
end end
def add_libelle(pdf, champ) def add_libelle(pdf, champ)
add_single_line(pdf, champ.libelle, 12, :bold) add_single_line(pdf, champ.libelle, 9, :bold)
end end
def add_explanation(pdf, explanation) def add_explanation(pdf, explanation)
@ -98,7 +98,7 @@ def render_single_champ(pdf, champ)
when 'Champs::RepetitionChamp' when 'Champs::RepetitionChamp'
raise 'There should not be a RepetitionChamp here !' raise 'There should not be a RepetitionChamp here !'
when 'Champs::PieceJustificativeChamp' when 'Champs::PieceJustificativeChamp'
add_single_line(pdf, 'Pièce justificative à joindre en complément du dossier', 12, :bold) add_single_line(pdf, 'Pièce justificative à joindre en complément du dossier', 9, :bold)
format_with_checkbox(pdf, champ.libelle) format_with_checkbox(pdf, champ.libelle)
add_optionnal_description(pdf, champ) add_optionnal_description(pdf, champ)
pdf.text "\n" pdf.text "\n"
@ -116,7 +116,7 @@ def render_single_champ(pdf, champ)
format_with_checkbox(pdf, Individual::GENDER_MALE) format_with_checkbox(pdf, Individual::GENDER_MALE)
pdf.text "\n" pdf.text "\n"
when 'Champs::HeaderSectionChamp' when 'Champs::HeaderSectionChamp'
add_single_line(pdf, champ.libelle, 18, :bold) add_single_line(pdf, champ.libelle, 14, :bold)
add_optionnal_description(pdf, champ) add_optionnal_description(pdf, champ)
pdf.text "\n" pdf.text "\n"
when 'Champs::ExplicationChamp' when 'Champs::ExplicationChamp'
@ -178,7 +178,7 @@ prawn_document(page_size: "A4") do |pdf|
pdf.font_families.update( 'marianne' => { pdf.font_families.update( 'marianne' => {
normal: Rails.root.join('lib/prawn/fonts/marianne/marianne-regular.ttf' ), normal: Rails.root.join('lib/prawn/fonts/marianne/marianne-regular.ttf' ),
bold: Rails.root.join('lib/prawn/fonts/marianne/marianne-bold.ttf' ), bold: Rails.root.join('lib/prawn/fonts/marianne/marianne-bold.ttf' ),
italic: Rails.root.join('lib/prawn/fonts/spectral/Spectral-Italic.ttf' ), italic: Rails.root.join('lib/prawn/fonts/spectral/Spectral-SemiBoldItalic.ttf' ),
}) })
pdf.font 'marianne' pdf.font 'marianne'
pdf.svg IO.read("app/assets/images/header/logo-ds-wide.svg"), width: 300, position: :center pdf.svg IO.read("app/assets/images/header/logo-ds-wide.svg"), width: 300, position: :center
@ -199,7 +199,7 @@ prawn_document(page_size: "A4") do |pdf|
pdf.text "\n" pdf.text "\n"
add_title(pdf, 'Formulaire') add_title(pdf, 'Formulaire')
add_single_line(pdf, @procedure.description + "\n", 12, :italic) if @procedure.description.present? add_single_line(pdf, @procedure.description + "\n", 9, :italic) if @procedure.description.present?
add_champs(pdf, @dossier.champs) add_champs(pdf, @dossier.champs)
add_page_numbering(pdf) add_page_numbering(pdf)
add_procedure(pdf, @dossier) add_procedure(pdf, @dossier)

View file

@ -1,11 +1,11 @@
require 'prawn/measurement_extensions' require 'prawn/measurement_extensions'
def format_in_2_lines(pdf, label, text) def format_in_2_lines(pdf, label, text)
pdf.font 'marianne', style: :bold, size: 12 do pdf.font 'marianne', style: :bold, size: 10 do
pdf.text label pdf.text label
end end
pdf.text text pdf.text text, size: 9
pdf.text "\n" pdf.text "\n", size: 9
end end
def format_in_2_columns(pdf, label, text) def format_in_2_columns(pdf, label, text)
@ -16,7 +16,7 @@ def format_in_2_columns(pdf, label, text)
end end
def add_title(pdf, title) def add_title(pdf, title)
title_style = {style: :bold, size: 24} title_style = {style: :bold, size: 20}
pdf.font 'marianne', title_style do pdf.font 'marianne', title_style do
pdf.text title pdf.text title
end end
@ -83,7 +83,7 @@ def render_single_champ(pdf, champ)
when 'Champs::PieceJustificativeChamp' when 'Champs::PieceJustificativeChamp'
return return
when 'Champs::HeaderSectionChamp' when 'Champs::HeaderSectionChamp'
pdf.font 'marianne', style: :bold, size: 18 do pdf.font 'marianne', style: :bold, size: 14 do
pdf.text champ.libelle pdf.text champ.libelle
end end
pdf.text "\n" pdf.text "\n"
@ -92,7 +92,7 @@ def render_single_champ(pdf, champ)
when 'Champs::CarteChamp' when 'Champs::CarteChamp'
format_in_2_lines(pdf, champ.libelle, champ.to_feature_collection.to_json) format_in_2_lines(pdf, champ.libelle, champ.to_feature_collection.to_json)
when 'Champs::SiretChamp' when 'Champs::SiretChamp'
pdf.font 'marianne', style: :bold, size: 12 do pdf.font 'marianne', style: :bold, size: 9 do
pdf.text champ.libelle pdf.text champ.libelle
end end
pdf.text " - SIRET: #{champ.to_s}" pdf.text " - SIRET: #{champ.to_s}"
@ -130,8 +130,8 @@ def add_message(pdf, message)
end end
pdf.text "#{sender}, #{format_date(message.created_at)}", style: :bold pdf.text "#{sender}, #{format_date(message.created_at)}", style: :bold
pdf.text ActionView::Base.full_sanitizer.sanitize(message.body) pdf.text ActionView::Base.full_sanitizer.sanitize(message.body), size: 9
pdf.text "\n" pdf.text "\n", size: 9
end end
def add_avis(pdf, avis) def add_avis(pdf, avis)