问题描述
我在Ruby on Rails上有一个文凭生成器,可以在图像模板上绘制一些文本变量,现在我需要在一个语句中突出显示某些单词
例如(注意专业知识时要加粗):
已达到认证要求 并在群组名称中被确认为专业 完成小时的课程和 online_hours 的学习时间
我知道Imagemagick允许使用某些字体绘制文本,但是我看起来很相似,但只能应用于某些单词。
我的模板文字:
证明书合格证 是comcom:expertise zh:cohort_name cumpliendo:小时小时数y:online_hours时间空档
我的代码:
def formatted_text(text)
formatted_text = text
formatted_text = formatted_text.gsub(/:cohort_name/,cohort_name.to_s)
formatted_text = formatted_text.gsub(/:hours/,hours.to_s)
formatted_text = formatted_text.gsub(/:online_hours/,online_hours.to_s)
formatted_text = formatted_text.gsub(/:expertise/,expertise.to_s)
formatted_text
end
image_cert = MiniMagick::Image.open(cert.url)
image_cert.combine_options do |c|
if certification_type.footer_text
c.gravity "West"
c.draw "text 120,80 '#{formatted_footer}'"
end
end
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)