14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/pdfrb/font_loader/variant_from_name.rb', line 14
def call(document, name, **_opts)
return nil unless name.is_a?(String)
base = name.sub(/[- ](Bold|Italic|Oblique|BoldItalic|BoldOblique).*/i, "")
return nil unless BASE_MAP.key?(base)
idx = case name
when /bold.*italic|italic.*bold/i
3
when /bold/i
1
else
/oblique|italic/i.match?(name) ? 2 : 0
end
full_name = BASE_MAP[base][idx]
return nil unless full_name
document.add({ Type: :Font, Subtype: :Type1, BaseFont: full_name.to_sym },
type: Pdfrb::Model::Type::FontType1)
end
|