Last active
November 25, 2018 17:04
-
-
Save hidakatsuya/91c4da80c09c05757fb651c495a0fbc3 to your computer and use it in GitHub Desktop.
List line-height each font with prawn
This file contains hidden or 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' | |
| 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