Class: HexaPDF::Type::FontType1

Inherits:
FontSimple show all
Defined in:
lib/hexapdf/type/font_type1.rb

Overview

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.

Defined Under Namespace

Modules: StandardFonts

Constant Summary

Constants included from DictionaryFields

DictionaryFields::Boolean, DictionaryFields::PDFByteString, DictionaryFields::PDFDate

Constants inherited from Object

Object::NOT_DUPLICATABLE_CLASSES

Instance Attribute Summary

Attributes inherited from Object

#data, #document, #must_be_indirect

Instance Method Summary collapse

Methods inherited from FontSimple

#decode, #encoding, #to_utf8, #word_spacing_applicable?, #writing_mode

Methods inherited from Font

#embedded?, #font_file, #must_be_indirect?, #to_utf8

Methods inherited from Dictionary

#[], #[]=, define_field, #delete, #each, each_field, #empty?, field, #key?, #to_hash, #type

Methods inherited from Object

#<=>, #==, deep_copy, #deep_copy, #document?, #eql?, #gen, #gen=, #hash, #indirect?, #initialize, #inspect, #must_be_indirect?, #null?, #oid, #oid=, #type, #validate, #value, #value=

Constructor Details

This class inherits a constructor from HexaPDF::Object

Instance Method Details

#bounding_boxObject

Returns the bounding box of the font or nil if it is not found.



115
116
117
118
119
120
121
122
123
124
# File 'lib/hexapdf/type/font_type1.rb', line 115

def bounding_box
  bbox = super
  if bbox
    bbox
  elsif StandardFonts.standard_font?(self[:BaseFont])
    StandardFonts.font(self[:BaseFont]).bounding_box
  else
    nil
  end
end

#symbolic?Boolean

Returns true if the font is a symbolic font, false if it is not, and nil if it is not known.

Returns:



128
129
130
131
132
133
134
135
136
137
138
# File 'lib/hexapdf/type/font_type1.rb', line 128

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) ⇒ Object

Returns the unscaled width of the given code point in glyph units, or 0 if the width for the code point is missing.



106
107
108
109
110
111
112
# File 'lib/hexapdf/type/font_type1.rb', line 106

def width(code)
  if StandardFonts.standard_font?(self[:BaseFont])
    StandardFonts.font(self[:BaseFont]).width(encoding.name(code)) || 0
  else
    super
  end
end