Class: Metanorma::Util::FontistHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/metanorma/util/fontist_helper.rb

Class Method Summary collapse

Class Method Details

.append_source_fonts(manifest, source_attributes) ⇒ Object



122
123
124
125
# File 'lib/metanorma/util/fontist_helper.rb', line 122

def self.append_source_fonts(manifest, source_attributes)
  source_attributes[:fonts]&.split(";")&.each { |f| manifest[f] = nil }
  manifest
end

.has_custom_fonts?(processor, options, source_attributes) ⇒ Boolean

Returns:

  • (Boolean)


106
107
108
109
110
111
# File 'lib/metanorma/util/fontist_helper.rb', line 106

def self.has_custom_fonts?(processor, options, source_attributes)
  install_fonts?(options) \
    && processor.respond_to?(:fonts_manifest) \
    && !processor.fonts_manifest.nil? \
    || source_attributes[:fonts]
end

.install_fonts(processor, options) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/metanorma/util/fontist_helper.rb', line 90

def self.install_fonts(processor, options)
  return unless validate_install_fonts(processor, options)

  @@updated_formulas_repo = false
  manifest = processor.fonts_manifest.dup
  append_source_fonts(manifest, options)
  agree_to_terms, can_without_fonts, no_progress = validate_options(options)

  install_fonts_safe(
    manifest,
    agree_to_terms,
    can_without_fonts,
    no_progress,
  )
end

.install_fonts?(options) ⇒ Boolean

Returns:

  • (Boolean)


127
128
129
# File 'lib/metanorma/util/fontist_helper.rb', line 127

def self.install_fonts?(options)
  options[:install_fonts].nil? || options[:install_fonts]
end

.location_manifest(processor, source_attributes) ⇒ Object



113
114
115
116
117
118
119
120
# File 'lib/metanorma/util/fontist_helper.rb', line 113

def self.location_manifest(processor, source_attributes)
  instance = Fontist::Manifest.from_hash(
    append_source_fonts(processor.fonts_manifest.dup, source_attributes),
    locations: true
  )

  instance.to_hash unless instance.nil?
end