Sha256: f5b324214a0e2439eb39730c27b88469a823072d8822e18df49fad256b243013
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true require_relative 'ttf' module Prawn module Fonts # TrueType Collection font. It's an SFNT-based format that contains a bunch # of TrueType fonts in a single file. # # @note You shouldn't use this class directly. 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. # # @param file [String] # @return [Array<String>] 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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
prawn-2.5.0 | lib/prawn/fonts/ttc.rb |