mirror of
https://github.com/docusealco/docuseal.git
synced 2026-08-07 07:14:43 +00:00
match generated font frontend
This commit is contained in:
@@ -4,14 +4,15 @@ module Submitters
|
||||
module GenerateFontImage
|
||||
WIDTH = 3000
|
||||
HEIGHT = 160
|
||||
SHEAR = 0.25
|
||||
|
||||
FONTS = {
|
||||
'Dancing Script Regular' => '/fonts/DancingScript-Regular.otf',
|
||||
'Go Noto Kurrent-Bold Bold' => '/fonts/GoNotoKurrent-Bold.ttf'
|
||||
'Go Noto Kurrent-Regular Regular' => '/fonts/GoNotoKurrent-Regular.ttf'
|
||||
}.freeze
|
||||
|
||||
FONT_ALIASES = {
|
||||
'initials' => 'Go Noto Kurrent-Bold Bold',
|
||||
'initials' => 'Go Noto Kurrent-Regular Regular',
|
||||
'signature' => 'Dancing Script Regular'
|
||||
}.freeze
|
||||
|
||||
@@ -25,6 +26,10 @@ module Submitters
|
||||
text_image = Vips::Image.text(text, font:, fontfile: FONTS[font],
|
||||
width: WIDTH, height: HEIGHT, wrap: :none)
|
||||
|
||||
text_image = text_image.affine([1, -SHEAR, 0, 1], background: [0])
|
||||
|
||||
text_image = text_image.crop(*text_image.find_trim(background: [0], threshold: 0))
|
||||
|
||||
text_mask = Vips::Image.black(text_image.width, text_image.height)
|
||||
|
||||
image = text_mask.bandjoin(text_image).copy(interpretation: :b_w)
|
||||
|
||||
Reference in New Issue
Block a user