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



120
121
122
123
# File 'lib/metanorma/util/fontist_helper.rb', line 120

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)


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

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



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

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)


125
126
127
# File 'lib/metanorma/util/fontist_helper.rb', line 125

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

.location_manifest(processor, source_attributes) ⇒ Object



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

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