Created
August 31, 2013 18:59
-
-
Save tombruijn/6399975 to your computer and use it in GitHub Desktop.
Quick prawn setup file for font testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "prawn" | |
pdf = Prawn::Document.new do |prawn| | |
prawn.font_families.update("OpenSans" => { | |
normal: "book/assets/fonts/OpenSans-Regular.ttf", | |
italic: "book/assets/fonts/OpenSans-Italic.ttf", | |
bold: "book/assets/fonts/OpenSans-Bold.ttf", | |
bold_italic: "book/assets/fonts/OpenSans-BoldItalic.ttf" | |
}) | |
["Helvetica", "Courier", "OpenSans"].each do |f| | |
prawn.text "Block #{f}" | |
prawn.font f do | |
prawn.text "block: #{prawn.font.inspect}" | |
end | |
prawn.move_down 10 | |
prawn.text "Fallback: #{f}" | |
prawn.text "fallback: #{prawn.font.inspect}", fallback_fonts: [f], font: f | |
prawn.move_down 50 | |
end | |
end | |
pdf.render_file("bla.pdf") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment