Class: HexaPDF::Type::CIDFont
- Inherits:
-
Font
- Object
- Object
- Dictionary
- Font
- HexaPDF::Type::CIDFont
- Defined in:
- lib/hexapdf/type/cid_font.rb
Overview
Represents a generic CIDFont which can only be used as a descendant font of a composite PDF font.
See: PDF2.0 s9.7.4
Defined Under Namespace
Classes: CIDSystemInfo
Constant Summary collapse
- DEFAULT_WIDTH =
:nodoc:
1000
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
-
#set_widths(widths, default_width: DEFAULT_WIDTH) ⇒ Object
Sets the /W and /DW keys using the given array of [CID, width] pairs and an optional default width.
-
#width(cid) ⇒ Object
Returns the unscaled width of the given CID in glyph units, or 0 if the width for the CID is missing.
Methods inherited from Font
#bounding_box, #embedded?, #font_file, #font_wrapper, #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
#set_widths(widths, default_width: DEFAULT_WIDTH) ⇒ Object
Sets the /W and /DW keys using the given array of [CID, width] pairs and an optional default width.
See: PDF2.0 s9.7.4.3
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/hexapdf/type/cid_font.rb', line 87 def set_widths(widths, default_width: DEFAULT_WIDTH) if widths.empty? (default_width == DEFAULT_WIDTH ? delete(:DW) : self[:DW] = default_width) delete(:W) else self[:DW] = default_width.to_i unless default_width == DEFAULT_WIDTH self[:W] = w = [] last_cid = -10 cur_widths = nil widths.each do |cid, width| if last_cid + 1 != cid cur_widths = [] w << cid << cur_widths end cur_widths << width.to_i last_cid = cid end end end |
#width(cid) ⇒ Object
Returns the unscaled width of the given CID in glyph units, or 0 if the width for the CID is missing.
Note that in contrast to other fonts, the argument must not be a code point but a CID!
79 80 81 |
# File 'lib/hexapdf/type/cid_font.rb', line 79 def width(cid) widths[cid] || value[:DW] || DEFAULT_WIDTH end |