module HexaPDF::FontLoader::Standard14
This module is used for providing the standard 14 PDF fonts.
Constants
- MAPPING
Mapping of font family name and variant to font name.
Public Class Methods
available_fonts(_document)
click to toggle source
Returns a hash of the form 'font_name => [variants, …]' of the standard 14 PDF fonts.
# File lib/hexapdf/font_loader/standard14.rb, line 98 def self.available_fonts(_document) MAPPING.transform_values(&:keys) end
call(document, name, variant: :none, custom_encoding: false, **)
click to toggle source
Creates a new font object backed by the AFM font metrics read from the file or IO stream.
document
-
The PDF document to associate the font object with.
name
-
The name of the built-in font. One of Times, Helvetica, Courier, Symbol or ZapfDingbats.
variant
-
The font variant. Can be :none, :bold, :italic, :bold_italic for Times, Helvetica and Courier; and must be :none for Symbol and ZapfDingbats.
custom_encoding
-
For Times, Helvetica and Courier the standard encoding WinAnsiEncoding is used. If this option is not wanted because access to other glyphs is needed, set this to
true
# File lib/hexapdf/font_loader/standard14.rb, line 88 def self.call(document, name, variant: :none, custom_encoding: false, **) name = MAPPING[name] && MAPPING[name][variant] return nil if name.nil? file = File.join(HexaPDF.data_dir, 'afm', "#{name}.afm") font = (@afm_font_cache ||= {})[file] ||= HexaPDF::Font::Type1::Font.from_afm(file) HexaPDF::Font::Type1Wrapper.new(document, font, custom_encoding: custom_encoding) end