use universal font

pull/217/head
Pete Matsyburka 2 years ago
parent e07d402782
commit 7361a00d42

@ -2,9 +2,7 @@ FROM ruby:3.2.2-alpine3.18 as fonts
WORKDIR /fonts WORKDIR /fonts
RUN apk --no-cache add fontforge wget ttf-liberation && cp /usr/share/fonts/liberation/LiberationSans-Regular.ttf /usr/share/fonts/liberation/LiberationSans-Bold.ttf . && wget https://cdn.jsdelivr.net/gh/notofonts/notofonts.github.io/fonts/NotoSansArabic/hinted/ttf/NotoSansArabic-Regular.ttf && wget https://github.com/impallari/DancingScript/raw/master/fonts/DancingScript-Regular.otf && wget https://github.com/impallari/DancingScript/raw/master/OFL.txt RUN apk --no-cache add wget && wget https://github.com/satbyy/go-noto-universal/releases/download/v7.0/GoNotoCurrent-Regular.ttf && wget https://github.com/satbyy/go-noto-universal/releases/download/v7.0/GoNotoCurrent-Bold.ttf && wget https://github.com/impallari/DancingScript/raw/master/fonts/DancingScript-Regular.otf && wget https://github.com/impallari/DancingScript/raw/master/OFL.txt
RUN fontforge -lang=py -c 'font1 = fontforge.open("LiberationSans-Regular.ttf"); font2 = fontforge.open("NotoSansArabic-Regular.ttf"); font1.mergeFonts(font2); font1.generate("LiberationSans-Regular.ttf")'
FROM ruby:3.2.2-alpine3.18 as webpack FROM ruby:3.2.2-alpine3.18 as webpack
@ -55,7 +53,7 @@ COPY ./public ./public
COPY ./tmp ./tmp COPY ./tmp ./tmp
COPY LICENSE README.md Rakefile config.ru .version ./ COPY LICENSE README.md Rakefile config.ru .version ./
COPY --from=fonts /fonts/LiberationSans-Regular.ttf /fonts/LiberationSans-Bold.ttf /fonts/DancingScript-Regular.otf /fonts/OFL.txt /fonts COPY --from=fonts /fonts/GoNotoCurrent-Regular.ttf /fonts/GoNotoCurrent-Bold.ttf /fonts/DancingScript-Regular.otf /fonts/OFL.txt /fonts
COPY --from=webpack /app/public/packs ./public/packs COPY --from=webpack /app/public/packs ./public/packs
RUN ln -s /fonts /app/public/fonts RUN ln -s /fonts /app/public/fonts

@ -4,8 +4,8 @@ module Submissions
module GenerateAuditTrail module GenerateAuditTrail
FONT_SIZE = 9 FONT_SIZE = 9
TEXT_COLOR = '525252' TEXT_COLOR = '525252'
FONT_PATH = '/fonts/LiberationSans-Regular.ttf' FONT_PATH = '/fonts/GoNotoCurrent-Regular.ttf'
FONT_BOLD_PATH = '/fonts/LiberationSans-Bold.ttf' FONT_BOLD_PATH = '/fonts/GoNotoCurrent-Bold.ttf'
FONT_NAME = if File.exist?(FONT_PATH) FONT_NAME = if File.exist?(FONT_PATH)
FONT_PATH FONT_PATH
else else
@ -61,7 +61,7 @@ module Submissions
style.frame = style.create_frame(canvas.context, 50) style.frame = style.create_frame(canvas.context, 50)
end end
composer.style(:base, font: FONT_NAME, font_size: FONT_SIZE, fill_color: TEXT_COLOR, line_spacing: 1.2) composer.style(:base, font: FONT_NAME, font_size: FONT_SIZE, fill_color: TEXT_COLOR, line_spacing: 1)
composer.style(:link, fill_color: 'hp-blue-light', underline: true) composer.style(:link, fill_color: 'hp-blue-light', underline: true)
composer.new_page composer.new_page
@ -71,16 +71,16 @@ module Submissions
column.text(account.linked_account_account&.testing? ? 'Testing Log - Not for Production Use' : 'Audit Log', column.text(account.linked_account_account&.testing? ? 'Testing Log - Not for Production Use' : 'Audit Log',
font_size: 16, font_size: 16,
padding: [15, 0, 0, 0], padding: [10, 0, 0, 0],
position: :float, position_hint: :right) position: :float, position_hint: :right)
end end
composer.column(columns: 1) do |column| composer.column(columns: 1) do |column|
column.text("Envelope ID: #{submission.id}", font_size: 12, padding: [20, 0, 10, 0], position: :float) column.text("Envelope ID: #{submission.id}", font_size: 12, padding: [15, 0, 8, 0], position: :float)
unless submission.source.in?(%w[embed api]) unless submission.source.in?(%w[embed api])
column.formatted_text([{ link: verify_url, text: 'Verify', style: :link }], column.formatted_text([{ link: verify_url, text: 'Verify', style: :link }],
font_size: 9, padding: [22, 0, 10, 0], position: :float, align: :right) font_size: 9, padding: [15, 0, 10, 0], position: :float, align: :right)
end end
end end
@ -114,13 +114,13 @@ module Submissions
{ text: 'Generated at: ', font: [FONT_BOLD_NAME, { variant: :bold }] }, { text: 'Generated at: ', font: [FONT_BOLD_NAME, { variant: :bold }] },
"#{I18n.l(document.created_at.in_time_zone(account.timezone), format: :long, locale: account.locale)} " \ "#{I18n.l(document.created_at.in_time_zone(account.timezone), format: :long, locale: account.locale)} " \
"#{TimeUtils.timezone_abbr(account.timezone, document.created_at)}" "#{TimeUtils.timezone_abbr(account.timezone, document.created_at)}"
], line_spacing: 1.8 ], line_spacing: 1.3
) )
] ]
end end
if documents_data.present? if documents_data.present?
composer.table(documents_data, cell_style: { padding: [0, 0, 25, 0], border: { width: 0 } }) composer.table(documents_data, cell_style: { padding: [0, 0, 20, 0], border: { width: 0 } })
composer.draw_box(divider) composer.draw_box(divider)
end end
@ -151,7 +151,7 @@ module Submissions
submitter.email && { text: "#{submitter.email}\n", font: [FONT_BOLD_NAME, { variant: :bold }] }, submitter.email && { text: "#{submitter.email}\n", font: [FONT_BOLD_NAME, { variant: :bold }] },
submitter.name && { text: "#{TextUtils.maybe_rtl_reverse(submitter.name)}\n" }, submitter.name && { text: "#{TextUtils.maybe_rtl_reverse(submitter.name)}\n" },
submitter.phone && { text: "#{submitter.phone}\n" } submitter.phone && { text: "#{submitter.phone}\n" }
].compact_blank, line_spacing: 1.8, padding: [0, 20, 0, 0] ].compact_blank, line_spacing: 1.3, padding: [0, 20, 0, 0]
) )
], ],
[ [
@ -167,7 +167,7 @@ module Submissions
completed_event.data['sid'] && { text: "Session ID: #{completed_event.data['sid']}\n" }, completed_event.data['sid'] && { text: "Session ID: #{completed_event.data['sid']}\n" },
completed_event.data['ua'] && { text: "User agent: #{completed_event.data['ua']}\n" }, completed_event.data['ua'] && { text: "User agent: #{completed_event.data['ua']}\n" },
"\n" "\n"
].compact_blank, line_spacing: 1.8, padding: [10, 20, 20, 0] ].compact_blank, line_spacing: 1.3, padding: [10, 20, 20, 0]
) )
] ]
] ]
@ -193,7 +193,7 @@ module Submissions
} }
].compact_blank, ].compact_blank,
align: field['name'].to_s.match?(RTL_REGEXP) ? :right : :left, align: field['name'].to_s.match?(RTL_REGEXP) ? :right : :left,
line_spacing: 1.8, padding: [0, 0, 5, 0] line_spacing: 1.3, padding: [0, 0, 2, 0]
), ),
if field['type'].in?(%w[image signature initials stamp]) if field['type'].in?(%w[image signature initials stamp])
attachment = submitter.attachments.find { |a| a.uuid == value } attachment = submitter.attachments.find { |a| a.uuid == value }
@ -207,7 +207,7 @@ module Submissions
width = field['type'] == 'initials' ? 100 : 200 width = field['type'] == 'initials' ? 100 : 200
height = resized_image.height * (width.to_f / resized_image.width) height = resized_image.height * (width.to_f / resized_image.width)
composer.image(io, width:, height:, margin: [0, 0, 10, 0]) composer.image(io, width:, height:, margin: [5, 0, 10, 0])
composer.formatted_text_box([{ text: '' }]) composer.formatted_text_box([{ text: '' }])
elsif field['type'].in?(%w[file payment]) elsif field['type'].in?(%w[file payment])
if field['type'] == 'payment' if field['type'] == 'payment'
@ -270,7 +270,7 @@ module Submissions
] ]
end end
composer.table(events_data, cell_style: { padding: [0, 0, 20, 0], border: { width: 0 } }) if events_data.present? composer.table(events_data, cell_style: { padding: [0, 0, 12, 0], border: { width: 0 } }) if events_data.present?
io = StringIO.new io = StringIO.new
@ -308,7 +308,7 @@ module Submissions
font_size: 20, font_size: 20,
font: [FONT_BOLD_NAME, { variant: :bold }], font: [FONT_BOLD_NAME, { variant: :bold }],
width: 100, width: 100,
padding: [12, 0, 0, 8], padding: [5, 0, 0, 8],
position: :float, position_hint: :left) position: :float, position_hint: :left)
end end
# rubocop:enable Metrics # rubocop:enable Metrics

@ -3,7 +3,7 @@
module Submissions module Submissions
module GenerateResultAttachments module GenerateResultAttachments
FONT_SIZE = 11 FONT_SIZE = 11
FONT_PATH = '/fonts/LiberationSans-Regular.ttf' FONT_PATH = '/fonts/GoNotoCurrent-Regular.ttf'
FONT_NAME = if File.exist?(FONT_PATH) FONT_NAME = if File.exist?(FONT_PATH)
FONT_PATH FONT_PATH
else else

Loading…
Cancel
Save