formatted_text() is generate "Prawn::Errors::UnknownFont"

30 views
Skip to first unread message

Mr. Alone

unread,
Apr 10, 2020, 3:42:34 AM4/10/20
to Prawn
Hi All.
I'm need help.

I get an error when I call the function 
formatted_text(
[
{ text: 'text1', font: 'TiemposHeadline', size: 10, styles: [:medium] },
{ text: 'text2', font: 'TiemposText', size: 10, styles: [:regular] }
]
)

Prawn::Errors::UnknownFont in TestController#show

is not a known font.




class MyPdf < Prawn::Document

def initialize()
super(page_size: 'A4',
page_layout: :portrait,
margin: 20
)

font_path = "#{Rails.root}/app/assets/fonts"
font_families.update(
"TiemposText" => {
:regular => { :file => "#{font_path}/Tiempos/TiemposText-Regular.ttf" },
:italic => { :file => "#{font_path}/Tiempos/TiemposText-Italic.ttf" },
:bold => { :file => "#{font_path}/Tiempos/TiemposText-Bold.ttf" },
:bold_italic => { :file => "#{font_path}/Tiempos/TiemposText-BoldItalic.ttf" }
},
"TiemposHeadline" => {
:medium => { :file => "#{font_path}/Tiempos/TiemposHeadline-Medium.ttf" },
:light => { :file => "#{font_path}/Tiempos/TiemposHeadline-Light.ttf" },
:italic => { :file => "#{font_path}/Tiempos/TiemposHeadline-Italic.ttf" },
:bold => { :file => "#{font_path}/Tiempos/TiemposText-Black.ttf" }
},
"Poppins" => {
:regular => { :file => "#{font_path}/Poppins/Poppins-Regular.ttf" },
:medium => { :file => "#{font_path}/Poppins/Poppins-Medium.ttf" },
:medium_italic => { :file => "#{font_path}/Poppins/Poppins-MediumItalic.ttf" },
:light => { :file => "#{font_path}/Poppins/Poppins-Light.ttf" },
:italic => { :file => "#{font_path}/Poppins/Poppins-Italic.ttf" },
:bold => { :file => "#{font_path}/Poppins/Poppins-Bold.ttf" },
:semi_bold => { :file => "#{font_path}/Poppins/Poppins-SemiBold.ttf" },
:semi_bold_italic => { :file => "#{font_path}/Poppins/Poppins-SemiBoldItalic.ttf" }
}
)

end

def to_pdf
content

render
end

  def content
    formatted_text(
       [
         { text: 'text1', font: 'TiemposHeadline', size: 10, styles: [:medium] },
         { text: 'text2', font: 'TiemposText', size: 10, styles: [:regular] }
      ]
    )
  end

end
Reply all
Reply to author
Forward
0 new messages