1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
require_relative 'ttf'
module Prawn
class Font
# @private
class TTC < TTF
# Returns a list of the names of all named fonts in the given ttc file.
# They are returned in order of their appearance in the file.
#
def self.font_names(file)
TTFunk::Collection.open(file) do |ttc|
ttc.map { |font| font.name.font_name.first }
end
end
private
def read_ttf_file
TTFunk::File.from_ttc(
@name,
font_option_to_index(@name, @options[:font])
)
end
def font_option_to_index(file, option)
if option.is_a?(Numeric)
option
else
self.class.font_names(file).index { |n| n == option } || 0
end
end
end
end
end
|