Class: Pdfrb::Model::Type::CIDFont
- Inherits:
-
Font
show all
- Defined in:
- lib/pdfrb/model/type/cid_font.rb
Overview
CID-keyed font (s9.7.3). Inner font of a /Type0 composite.
/Subtype /CIDFontType0 or /CIDFontType2.
Instance Attribute Summary
Attributes inherited from Object
#document, #gen, #oid, #value
Instance Method Summary
collapse
Methods inherited from Font
#cid?, #descendant_font, #embedded?, #encoding, #first_char, #font_file, #glyph_width, #last_char, #simple?, #subtype, #to_unicode, #type3?, #widths
#[], #[]=, arlington_available?, arlington_default, arlington_key_to_symbol, arlington_loaded_for?, arlington_mark_loaded, arlington_object, arlington_one_type_to_ruby, arlington_required?, arlington_types_to_ruby, arlington_version, define_field, define_field_from_arlington, #delete, #each, each_field, #each_raw, #empty?, field, #initialize, #key?, #keys, lookup_type, own_fields, #pdf_type, register_type, type_map, #validate
Methods inherited from Object
#==, define_type, #deref, #indirect?, #initialize, #must_be_indirect?, #pdf_type, pdf_type
Instance Method Details
#base_font ⇒ Object
12
|
# File 'lib/pdfrb/model/type/cid_font.rb', line 12
def base_font; self[:BaseFont]; end
|
#cid_subtype ⇒ Object
11
|
# File 'lib/pdfrb/model/type/cid_font.rb', line 11
def cid_subtype; self[:Subtype]; end
|
#cid_system_info ⇒ Object
13
|
# File 'lib/pdfrb/model/type/cid_font.rb', line 13
def cid_system_info; self[:CIDSystemInfo]; end
|
#cid_to_gid_map ⇒ Object
19
|
# File 'lib/pdfrb/model/type/cid_font.rb', line 19
def cid_to_gid_map; self[:CIDToGIDMap]; end
|
#default_width ⇒ Object
29
30
31
|
# File 'lib/pdfrb/model/type/cid_font.rb', line 29
def default_width
dw || 1000
end
|
15
|
# File 'lib/pdfrb/model/type/cid_font.rb', line 15
def dw; self[:DW]; end
|
17
|
# File 'lib/pdfrb/model/type/cid_font.rb', line 17
def dw2; self[:DW2]; end
|
#font_descriptor ⇒ Object
14
|
# File 'lib/pdfrb/model/type/cid_font.rb', line 14
def font_descriptor; self[:FontDescriptor]; end
|
#type0? ⇒ Boolean
21
22
23
|
# File 'lib/pdfrb/model/type/cid_font.rb', line 21
def type0?
cid_subtype&.to_sym == :CIDFontType0
end
|
#type2? ⇒ Boolean
25
26
27
|
# File 'lib/pdfrb/model/type/cid_font.rb', line 25
def type2?
cid_subtype&.to_sym == :CIDFontType2
end
|
16
|
# File 'lib/pdfrb/model/type/cid_font.rb', line 16
def w; self[:W]; end
|
18
|
# File 'lib/pdfrb/model/type/cid_font.rb', line 18
def w2; self[:W2]; end
|
#width_for_cid(cid) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/pdfrb/model/type/cid_font.rb', line 33
def width_for_cid(cid)
return default_width unless w
entries = w.is_a?(Pdfrb::Model::PdfArray) ? w.to_a : w
i = 0
while i < entries.size
first = entries[i]
second = entries[i + 1]
return nil unless first && second
case second.to_s
when /\A[\[\]]\z/
array = entries[i + 2]
return nil unless first.is_a?(Integer) && array.is_a?(Array)
offset = cid - first
return array[offset] if offset >= 0 && offset < array.size
else
value = entries[i + 2]
return value if cid.between?(first, second)
end
i += 3
end
default_width
end
|