Sha256: 84be47cc917bfac4b5cbcf093c33b0a9f1dbbe9d0c8f38f6f0cbe4ab32b49962

Contents?: true

Size: 973 Bytes

Versions: 8

Compression:

Stored size: 973 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

8 entries across 8 versions & 2 rubygems

Version Path
prawn-core-0.7.2 lib/prawn/font/dfont.rb
prawn-core-0.7.1 lib/prawn/font/dfont.rb
prawn-layout-0.3.2 vendor/prawn-core/lib/prawn/font/dfont.rb
prawn-core-0.6.3 lib/prawn/font/dfont.rb
prawn-core-0.6.2 lib/prawn/font/dfont.rb
prawn-layout-0.3.1 vendor/prawn-core/lib/prawn/font/dfont.rb
prawn-core-0.6.1 lib/prawn/font/dfont.rb
prawn-core-0.5.1 lib/prawn/font/dfont.rb