Class: Prawn::Fonts::DFont

Inherits:
TTF show all
Defined in:
lib/prawn/fonts/dfont.rb

Overview

Note:

You shouldn’t use this class directly.

DFONT font. DFONT is a bunch of TrueType fonts in a single file.

Class Method Summary collapse

Constructor Details

This class inherits a constructor from Prawn::Fonts::TTF

Class Method Details

.font_count(file) ⇒ Integer

Returns the number of fonts contained in the dfont file.

Parameters:

  • file (String)

Returns:

  • (Integer)
Source Code
lib/prawn/fonts/dfont.rb, line 29
29
def self.font_count(file)
30
  TTFunk::ResourceFile.open(file) do |f|
31
    return f.map['sfnt'][:list].length
32
  end
33
end

.named_fonts(file) ⇒ Array<String>

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.

Parameters:

  • file (String)

Returns:

  • (Array<String>)
Source Code
lib/prawn/fonts/dfont.rb, line 19
19
def self.named_fonts(file)
20
  TTFunk::ResourceFile.open(file) do |f|
21
    return f.resources_for('sfnt')
22
  end
23
end