Class: Metanorma::FontistUtils

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

Class Method Summary collapse

Class Method Details

.append_source_fonts(manifest, source_attributes) ⇒ Object



117
118
119
120
# File 'lib/metanorma/fontist_utils.rb', line 117

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)


104
105
106
107
108
109
# File 'lib/metanorma/fontist_utils.rb', line 104

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

.install_fonts(processor, options) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/metanorma/fontist_utils.rb', line 88

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

.location_manifest(processor, source_attributes) ⇒ Object



111
112
113
114
115
# File 'lib/metanorma/fontist_utils.rb', line 111

def self.location_manifest(processor, source_attributes)
  Fontist::Manifest::Locations.from_hash(
    append_source_fonts(processor.fonts_manifest.dup, source_attributes),
  )
end