Module: HexaPDF::Type::FontType1::StandardFonts

Defined in:
lib/hexapdf/type/font_type1.rb

Overview

Provides the names and additional mappings of the Standard 14 Fonts.

Class Method Summary collapse

Class Method Details

.font(name) ⇒ Object

Returns the Type1 font object for the given standard font name, or nil if the given name doesn’t belong to a standard font.



92
93
94
95
96
97
98
99
100
101
102
# File 'lib/hexapdf/type/font_type1.rb', line 92

def self.font(name)
  name = @mapping[name]
  if !standard_font?(name)
    nil
  elsif @cache.key?(name)
    @cache[name]
  else
    file = File.join(HexaPDF.data_dir, 'afm', "#{name}.afm")
    @cache[name] = HexaPDF::Font::Type1::Font.from_afm(file)
  end
end

.standard_font?(name) ⇒ Boolean

Returns true if the given name is the name of a standard font.

Returns:



78
79
80
# File 'lib/hexapdf/type/font_type1.rb', line 78

def self.standard_font?(name)
  @mapping.include?(name)
end

.standard_name(name) ⇒ Object

Returns the standard name of the font in case an additional name is used, or nil if the given name doesn’t belong to a standard font.



84
85
86
# File 'lib/hexapdf/type/font_type1.rb', line 84

def self.standard_name(name)
  @mapping[name]
end