Question

I'm trying to generate a pdf with prawn with the "Arial" font. I'm doing all of this inside an inherited Prawn::Document class.

I've importet the arial font:

font_families.update("Arial" => {
    :normal => { :file => "#{Rails.root}/app/assets/fonts/Arial.ttf", :font => "Arial" },
    :bold => { :file => "#{Rails.root}/app/assets/fonts/Arial_Bold.ttf", :font => "Arial_Bold" }
    })

font "Arial", size: 11 # use this font and size from now on

This works fine but only outside of bounding_boxes. The text inside a bounding_box is untouched of the used font from the outside. When I try to define a font inside the box, I get this error:

 is not a known font.

Is a bounding_box capable of custom fonts at all? Thanks!

Was it helpful?

Solution

This should work:

font_families.update("Arial" => {
  :normal => "#{Rails.root}/app/assets/fonts/Arial.ttf",
  :bold => "#{Rails.root}/app/assets/fonts/Arial_Bold.ttf"
})

font "Arial", size: 11

Make sure to update the font families before starting a bounding box.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top