Sha256: 8e7da2c04c75d0263c41fdfde500ac920a7160e24db0c5527327c23d66ce93de

Contents?: true

Size: 950 Bytes

Versions: 5

Compression:

Stored size: 950 Bytes

Contents

require 'prawn/font/ttf'

module Prawn
  class Font
    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 |file|
          return file.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 |file|
          return file.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

5 entries across 5 versions & 3 rubygems

Version Path
kavu-prawn-core-0.4.100 lib/prawn/font/dfont.rb
kavu-prawn-core-0.4.99 lib/prawn/font/dfont.rb
prawn-core-0.5.0.1 lib/prawn/font/dfont.rb
prawn-0.4.0 lib/prawn/font/dfont.rb
prawn-0.4.1 lib/prawn/font/dfont.rb