class HexaPDF::Type::FontType1
Represents a Type1 font.
PDF provides 14 built-in fonts that all PDF readers must understand. These 14 fonts are known as the “Standard 14 Fonts” and are all Type1 fonts. HexaPDF
supports these fonts.
Public Instance Methods
bounding_box()
click to toggle source
Returns the bounding box of the font or nil
if it is not found.
Calls superclass method
HexaPDF::Type::Font#bounding_box
# File lib/hexapdf/type/font_type1.rb, line 133 def bounding_box bbox = super if bbox bbox elsif StandardFonts.standard_font?(self[:BaseFont]) StandardFonts.font(self[:BaseFont]).bounding_box else nil end end
font_wrapper()
click to toggle source
Overrides the default to provide a font wrapper in case none is set and the font is one of the standard fonts.
See: Font#font_wrapper
Calls superclass method
HexaPDF::Type::Font#font_wrapper
# File lib/hexapdf/type/font_type1.rb, line 112 def font_wrapper if (tmp = super) tmp elsif StandardFonts.standard_font?(self[:BaseFont]) self.font_wrapper = HexaPDF::Font::Type1Wrapper.new(document, StandardFonts.font(self[:BaseFont]), pdf_object: self) end end
symbolic?()
click to toggle source
Returns true
if the font is a symbolic font, false
if it is not, and nil
if it is not known.
Calls superclass method
HexaPDF::Type::FontSimple#symbolic?
# File lib/hexapdf/type/font_type1.rb, line 146 def symbolic? symbolic = super if !symbolic.nil? symbolic elsif StandardFonts.standard_font?(self[:BaseFont]) name = StandardFonts.standard_name(self[:BaseFont]) name == :ZapfDingbats || name == :Symbol else nil end end
width(code)
click to toggle source
Returns the unscaled width of the given code point in glyph units, or 0 if the width for the code point is missing.
Calls superclass method
HexaPDF::Type::FontSimple#width
# File lib/hexapdf/type/font_type1.rb, line 124 def width(code) if StandardFonts.standard_font?(self[:BaseFont]) StandardFonts.font(self[:BaseFont]).width(encoding.name(code)) || 0 else super end end
Private Instance Methods
encoding_from_font()
click to toggle source
Reads the encoding from an embedded font file and handles the special case of the Standard 14 fonts.
# File lib/hexapdf/type/font_type1.rb, line 162 def encoding_from_font if StandardFonts.standard_font?(self[:BaseFont]) StandardFonts.font(self[:BaseFont]).encoding elsif (obj = self[:FontDescriptor][:FontFile]) HexaPDF::Font::Type1::PFBParser.encoding(obj.stream) else raise HexaPDF::Error, "Can't read encoding because Type1 font is not embedded" end end
perform_validation() { |"Required field FontDescriptor is not set", false| ... }
click to toggle source
Validates the Type1 font dictionary.
Calls superclass method
HexaPDF::Type::FontSimple#perform_validation
# File lib/hexapdf/type/font_type1.rb, line 173 def perform_validation std_font = StandardFonts.standard_font?(self[:BaseFont]) super(ignore_missing_font_fields: std_font) if !std_font && self[:FontDescriptor].nil? yield("Required field FontDescriptor is not set", false) end end