Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8438187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:38:26+00:00 2026-06-10T07:38:26+00:00

I’m trying to use ruby to generate a PDF using Prawn on OS X.

  • 0

I’m trying to use ruby to generate a PDF using Prawn on OS X. I have the following:

font 'Arial'

Arial is installed on my Mac. But when I try to generate the PDF, I get the following error:

Prawn::Errors::UnknownFont in ProjectsController#show
Arial is not a known font.

How can I get this common font to work in Prawn? In fact, almost anything other than Helvetica or Times New Roman throws this same error. This is part of a Rails 3.2 app.

If I try to load the font ttf file directly, per Ashish’s suggestion below, I get a Bad font family message:

RuntimeError (Bad font family):
  app/pdfs/quote_sheet_pdf.rb:29:in `page_top'
  app/pdfs/quote_sheet_pdf.rb:12:in `initialize'
  app/controllers/projects_controller.rb:9:in `new'
  app/controllers/projects_controller.rb:9:in `block (2 levels) in show'
  app/controllers/projects_controller.rb:7:in `show'
  config/initializers/quiet_assets.rb:7:in `call_with_quiet_assets'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:38:27+00:00Added an answer on June 10, 2026 at 7:38 am

    If you’re using the :style option to calls to text, e.g.

    text "Hello World", :style => :italic
    

    Then the font you’re using at the time needs to have an associated font family, otherwise you’ll get the “Bad font family” error you’re seeing, e.g. this:

    Prawn::Document.generate("output.pdf") do
      font "/Library/Fonts/Arial.ttf"
      text "Hello World", :style => :italic
    end
    

    produces: Bad font family (RuntimeError).

    One way round this would be to always specify the exact font file you want every time you want to change style, e.g.

    font "/Library/Fonts/Arial Italic.ttf"
    text "Hello World"
    

    A better option would be to create a font family with the styles you want:

    Prawn::Document.generate("output.pdf") do
    
      font_families.update("Arial" => {
        :normal => "/Library/Fonts/Arial.ttf",
        :italic => "/Library/Fonts/Arial Italic.ttf",
        :bold => "/Library/Fonts/Arial Bold.ttf",
        :bold_italic => "/Library/Fonts/Arial Bold Italic.ttf"
      })
    
      font "Arial"
      text "Hello World"
      text "Hello World", :style => :italic
      text "Hello World", :style => :bold
      text "Hello World", :style => :bold_italic
    end
    

    After you’ve set up the font family you can just use Arial as the font name, and you can use the different styles easily.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.