Class: HexaPDF::Type::FontType1
- Inherits:
-
FontSimple
- Object
- Object
- Dictionary
- Font
- FontSimple
- HexaPDF::Type::FontType1
- 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
Instance Attribute Summary
Attributes inherited from Object
#data, #document, #must_be_indirect
Instance Method Summary collapse
-
#bounding_box ⇒ Object
Returns the bounding box of the font or
nil
if it is not found. -
#font_wrapper ⇒ Object
Overrides the default to provide a font wrapper in case none is set and the font is one of the standard fonts.
-
#symbolic? ⇒ Boolean
Returns
true
if the font is a symbolic font,false
if it is not, andnil
if it is not known. -
#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.
Methods inherited from FontSimple
#decode, #encoding, #font_descriptor, #to_utf8, #word_spacing_applicable?, #writing_mode
Methods inherited from Font
#embedded?, #font_file, #font_wrapper=, #glyph_scaling_factor, #must_be_indirect?, #to_utf8
Methods inherited from Dictionary
#[], #[]=, define_field, define_type, #delete, #each, each_field, #empty?, field, #key?, #to_hash, type, #type
Methods inherited from Object
#<=>, #==, #cache, #cached?, #clear_cache, deep_copy, #deep_copy, #document?, #eql?, field, #gen, #gen=, #hash, #indirect?, #initialize, #inspect, make_direct, #must_be_indirect?, #null?, #oid, #oid=, #type, #validate, #value, #value=
Constructor Details
This class inherits a constructor from HexaPDF::Object
Instance Method Details
#bounding_box ⇒ Object
Returns the bounding box of the font or nil
if it is not found.
134 135 136 137 138 139 140 141 142 143 |
# File 'lib/hexapdf/type/font_type1.rb', line 134 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 ⇒ Object
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
113 114 115 116 117 118 119 120 121 |
# File 'lib/hexapdf/type/font_type1.rb', line 113 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? ⇒ Boolean
Returns true
if the font is a symbolic font, false
if it is not, and nil
if it is not known.
147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/hexapdf/type/font_type1.rb', line 147 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.
125 126 127 128 129 130 131 |
# File 'lib/hexapdf/type/font_type1.rb', line 125 def width(code) if StandardFonts.standard_font?(self[:BaseFont]) StandardFonts.font(self[:BaseFont]).width(encoding.name(code)) || 0 else super end end |