lib/frameit/editor.rb in frameit-2.7.0 vs lib/frameit/editor.rb in frameit-2.8.0
- old
+ new
@@ -229,11 +229,11 @@
def build_title_images(max_width, max_height)
words = [:keyword, :title].keep_if { |a| fetch_text(a) } # optional keyword/title
results = {}
words.each do |key|
# Create empty background
- empty_path = File.join(Helper.gem_path('frameit'), "lib/assets/empty.png")
+ empty_path = File.join(Frameit::ROOT, "lib/assets/empty.png")
title_image = MiniMagick::Image.open(empty_path)
image_height = max_height # gets trimmed afterwards anyway, and on the iPad the `y` would get cut
title_image.combine_options do |i|
# Oversize as the text might be larger than the actual image. We're trimming afterwards anyway
i.resize "#{max_width * 5.0}x#{image_height}!" # `!` says it should ignore the ratio
@@ -243,16 +243,20 @@
text = fetch_text(key)
UI.verbose("Using #{current_font} as font the #{key} of #{screenshot.path}") if current_font
UI.verbose("Adding text '#{text}'")
text.gsub! '\n', "\n"
+ text.gsub!(/(?<!\\)(')/) { |s| "\\#{s}" } # escape unescaped apostrophes with a backslash
+ interline_spacing = fetch_config['interline_spacing']
+
# Add the actual title
title_image.combine_options do |i|
i.font current_font if current_font
i.gravity "Center"
i.pointsize actual_font_size
i.draw "text 0,0 '#{text}'"
+ i.interline_spacing interline_spacing if interline_spacing
i.fill fetch_config[key.to_s]['color']
end
title_image.trim # remove white space
results[key] = title_image