Sha256: 934cc071c75779369ba133c2d53195ff1c0eef9cd75ee84355daebe9b58e0c95

Contents?: true

Size: 999 Bytes

Versions: 2

Compression:

Stored size: 999 Bytes

Contents

# frozen_string_literal: true

require_relative 'ttf'

module Prawn
  module Fonts
    # @private
    class DFont < TTF
      # Returns a list of the names of all named fonts in the given dfont file.
      # Note that fonts are not required to be named in a dfont file, so the
      # list may be empty even if the file does contain fonts. Also, note that
      # the list is returned in no particular order, so the first font in the
      # list is not necessarily the font at index 0 in the file.
      #
      def self.named_fonts(file)
        TTFunk::ResourceFile.open(file) do |f|
          return f.resources_for('sfnt')
        end
      end

      # Returns the number of fonts contained in the dfont file.
      #
      def self.font_count(file)
        TTFunk::ResourceFile.open(file) do |f|
          return f.map['sfnt'][:list].length
        end
      end

      private

      def read_ttf_file
        TTFunk::File.from_dfont(@name, @options[:font] || 0)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
prawn-2.4.0 lib/prawn/fonts/dfont.rb
prawn-2.3.0 lib/prawn/fonts/dfont.rb