Skip to content

Instantly share code, notes, and snippets.

@hidakatsuya
Last active November 25, 2018 17:04
Show Gist options
  • Save hidakatsuya/91c4da80c09c05757fb651c495a0fbc3 to your computer and use it in GitHub Desktop.
Save hidakatsuya/91c4da80c09c05757fb651c495a0fbc3 to your computer and use it in GitHub Desktop.
List line-height each font with prawn
require 'prawn'
fonts = [
['Helvetica', 'Agj'],
['Courier', 'Agj'],
['Times-Roman', 'Agj'],
['fonts/ipag.ttf', 'Agjぽ'],
['fonts/ipagp.ttf', 'Agjぽ']
]
font_sizes = [8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72]
results = []
pdf = Prawn::Document.new
fonts.each do |(family, string)|
font_sizes.each do |font_size|
pdf.font(family, size: font_size) do
result = [
family,
font_size,
pdf.width_of(string),
pdf.height_of(string)
]
puts result.join(',')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment