diff --git a/lib/submitters/generate_font_image.rb b/lib/submitters/generate_font_image.rb index 0413355f..05e7e454 100644 --- a/lib/submitters/generate_font_image.rb +++ b/lib/submitters/generate_font_image.rb @@ -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)