Module: Fontist

Defined in:
lib/fontist/import/google_import.rb,
lib/fontist.rb,
lib/fontist/cli.rb,
lib/fontist/font.rb,
lib/fontist/repo.rb,
lib/fontist/cache.rb,
lib/fontist/index.rb,
lib/fontist/macos.rb,
lib/fontist/utils.rb,
lib/fontist/config.rb,
lib/fontist/errors.rb,
lib/fontist/import.rb,
lib/fontist/update.rb,
lib/fontist/extract.rb,
lib/fontist/formula.rb,
lib/fontist/helpers.rb,
lib/fontist/indexes.rb,
lib/fontist/version.rb,
lib/fontist/manifest.rb,
lib/fontist/repo_cli.rb,
lib/fontist/resource.rb,
lib/fontist/utils/ui.rb,
lib/fontist/cache_cli.rb,
lib/fontist/font_file.rb,
lib/fontist/font_path.rb,
lib/fontist/index_cli.rb,
lib/fontist/resources.rb,
lib/fontist/validator.rb,
lib/fontist/config_cli.rb,
lib/fontist/font_model.rb,
lib/fontist/font_style.rb,
lib/fontist/fontconfig.rb,
lib/fontist/import/otf.rb,
lib/fontist/import_cli.rb,
lib/fontist/memoizable.rb,
lib/fontist/validation.rb,
lib/fontist/cache/store.rb,
lib/fontist/font_finder.rb,
lib/fontist/format_spec.rb,
lib/fontist/system_font.rb,
lib/fontist/utils/cache.rb,
lib/fontist/cli/thor_ext.rb,
lib/fontist/import/files.rb,
lib/fontist/manifest_cli.rb,
lib/fontist/system_index.rb,
lib/fontist/utils/system.rb,
lib/fontist/validate_cli.rb,
lib/fontist/cache/manager.rb,
lib/fontist/import/google.rb,
lib/fontist/import/models.rb,
lib/fontist/import_source.rb,
lib/fontist/macos/catalog.rb,
lib/fontist/path_scanning.rb,
lib/fontist/style_version.rb,
lib/fontist/utils/locking.rb,
lib/fontist/font_installer.rb,
lib/fontist/fontconfig_cli.rb,
lib/fontist/format_matcher.rb,
lib/fontist/formula_picker.rb,
lib/fontist/import/helpers.rb,
lib/fontist/utils/file_ops.rb,
lib/fontist/collection_file.rb,
lib/fontist/font_collection.rb,
lib/fontist/install_location.rb,
lib/fontist/manifest_request.rb,
lib/fontist/utils/downloader.rb,
lib/fontist/utils/file_magic.rb,
lib/fontist/utils/github_url.rb,
lib/fontist/cli/class_options.rb,
lib/fontist/import/font_style.rb,
lib/fontist/import/google/api.rb,
lib/fontist/install_locations.rb,
lib/fontist/manifest_response.rb,
lib/fontist/sil_import_source.rb,
lib/fontist/formula_suggestion.rb,
lib/fontist/import/text_helper.rb,
lib/fontist/indexes/font_index.rb,
lib/fontist/indexes/user_index.rb,
lib/fontist/import/sil_importer.rb,
lib/fontist/indexes/index_mixin.rb,
lib/fontist/macos/catalog/asset.rb,
lib/fontist/macos_import_source.rb,
lib/fontist/resource_collection.rb,
lib/fontist/utils/github_client.rb,
lib/fontist/google_import_source.rb,
lib/fontist/import/google/models.rb,
lib/fontist/import/otf/font_file.rb,
lib/fontist/indexes/system_index.rb,
lib/fontist/import/create_formula.rb,
lib/fontist/import/import_display.rb,
lib/fontist/import/macos_importer.rb,
lib/fontist/indexes/fontist_index.rb,
lib/fontist/import/formula_builder.rb,
lib/fontist/import/template_helper.rb,
lib/fontist/indexes/filename_index.rb,
lib/fontist/import/convert_formulas.rb,
lib/fontist/import/upgrade_formulas.rb,
lib/fontist/import/v4_to_v5_migrator.rb,
lib/fontist/indexes/directory_change.rb,
lib/fontist/macos_framework_metadata.rb,
lib/fontist/import/formula_serializer.rb,
lib/fontist/import/google/models/axis.rb,
lib/fontist/macos/catalog/base_parser.rb,
lib/fontist/resources/google_resource.rb,
lib/fontist/import/files/font_detector.rb,
lib/fontist/import/google/data_sources.rb,
lib/fontist/import/helpers/hash_helper.rb,
lib/fontist/indexes/directory_snapshot.rb,
lib/fontist/macos/catalog/font3_parser.rb,
lib/fontist/macos/catalog/font4_parser.rb,
lib/fontist/macos/catalog/font5_parser.rb,
lib/fontist/macos/catalog/font6_parser.rb,
lib/fontist/macos/catalog/font7_parser.rb,
lib/fontist/macos/catalog/font8_parser.rb,
lib/fontist/resources/archive_resource.rb,
lib/fontist/import/google/font_database.rb,
lib/fontist/import/models/font_metadata.rb,
lib/fontist/import/recursive_extraction.rb,
lib/fontist/indexes/formula_key_to_path.rb,
lib/fontist/indexes/incremental_scanner.rb,
lib/fontist/import/files/collection_file.rb,
lib/fontist/import/google_fonts_importer.rb,
lib/fontist/import/helpers/system_helper.rb,
lib/fontist/resources/apple_cdn_resource.rb,
lib/fontist/import/google/data_sources/vf.rb,
lib/fontist/import/google/formula_builder.rb,
lib/fontist/import/google/metadata_parser.rb,
lib/fontist/import/google/models/metadata.rb,
lib/fontist/import/manual_formula_builder.rb,
lib/fontist/macos/catalog/catalog_manager.rb,
lib/fontist/import/font_metadata_extractor.rb,
lib/fontist/import/google/data_sources/ttf.rb,
lib/fontist/import/google/metadata_adapter.rb,
lib/fontist/import/google/data_sources/base.rb,
lib/fontist/install_locations/base_location.rb,
lib/fontist/install_locations/user_location.rb,
lib/fontist/import/google/data_sources/woff2.rb,
lib/fontist/import/google/models/font_family.rb,
lib/fontist/import/google/data_sources/github.rb,
lib/fontist/import/google/models/font_variant.rb,
lib/fontist/indexes/default_family_font_index.rb,
lib/fontist/indexes/incremental_index_updater.rb,
lib/fontist/install_locations/system_location.rb,
lib/fontist/import/google/models/axis_metadata.rb,
lib/fontist/import/google/models/file_metadata.rb,
lib/fontist/indexes/base_font_collection_index.rb,
lib/fontist/install_locations/fontist_location.rb,
lib/fontist/import/font_parsing_error_collector.rb,
lib/fontist/indexes/preferred_family_font_index.rb,
lib/fontist/import/google/models/source_metadata.rb,
lib/fontist/import/google/models/font_file_metadata.rb,
lib/fontist/import/google/formula_builders/formula_builder_v4.rb,
lib/fontist/import/google/formula_builders/formula_builder_v5.rb,
lib/fontist/import/google/formula_builders/base_formula_builder.rb

Overview

TODO: We should properly parse Protobuf files (METADATA.pb) instead of using ad-hoc parsers. However, there is no current Ruby Protobuf library that supports parsing Protobuf text format files. ruby-protobuf only supports binary format, and google-protobuf gem requires compiled extensions.

Defined Under Namespace

Modules: Cache, Errors, Helpers, Import, Indexes, InstallLocations, Macos, Memoizable, PathScanning, Resources, ThorExt, Utils Classes: CLI, CacheCLI, CollectionFile, Config, ConfigCLI, Extract, ExtractOptions, Font, FontCollection, FontFile, FontFinder, FontInstaller, FontMatch, FontModel, FontPath, FontStyle, FontValidationResult, Fontconfig, FontconfigCLI, FormatMatcher, FormatSpec, Formula, FormulaCollection, FormulaPicker, FormulaSuggestion, GoogleImportSource, ImportCLI, ImportSource, Index, IndexCLI, IndexEntry, IndexStats, Info, InstallLocation, MacosFrameworkMetadata, MacosImportSource, Manifest, ManifestCLI, ManifestFont, ManifestRequest, ManifestRequestFont, ManifestResponse, ManifestResponseFont, ManifestResponseFontStyle, Repo, RepoCLI, Resource, ResourceCollection, SilImportSource, StyleVersion, SystemFont, SystemIndex, SystemIndexFont, SystemIndexFontCollection, Update, ValidateCLI, ValidationCache, ValidationReport, Validator

Constant Summary collapse

VERSION =
"3.0.0".freeze

Class Method Summary collapse

Class Method Details

.auto_overwriteObject



256
257
258
259
260
# File 'lib/fontist.rb', line 256

def self.auto_overwrite
  return @auto_overwrite if defined?(@auto_overwrite)

  nil
end

.auto_overwrite=(value) ⇒ Object



262
263
264
# File 'lib/fontist.rb', line 262

def self.auto_overwrite=(value)
  @auto_overwrite = value
end

.configObject



228
229
230
# File 'lib/fontist.rb', line 228

def self.config
  Fontist::Config.instance.values
end

.config_pathObject



232
233
234
# File 'lib/fontist.rb', line 232

def self.config_path
  Fontist.fontist_path.join("config.yml")
end

.default_fontist_pathObject



110
111
112
# File 'lib/fontist.rb', line 110

def self.default_fontist_path
  Pathname.new(File.join(Dir.home, ".fontist"))
end

.downloads_pathObject



146
147
148
# File 'lib/fontist.rb', line 146

def self.downloads_path
  Fontist.fontist_path.join("downloads")
end

.excluded_fonts_pathObject



164
165
166
# File 'lib/fontist.rb', line 164

def self.excluded_fonts_path
  Fontist.lib_path.join("fontist", "exclude.yml")
end

.fontist_index_pathObject



176
177
178
# File 'lib/fontist.rb', line 176

def self.fontist_index_path
  Fontist.fontist_path.join("fontist_index.default_family.yml")
end

.fontist_pathObject



106
107
108
# File 'lib/fontist.rb', line 106

def self.fontist_path
  Pathname.new(ENV["FONTIST_PATH"] || default_fontist_path)
end

.fontist_preferred_family_index_pathObject



180
181
182
# File 'lib/fontist.rb', line 180

def self.fontist_preferred_family_index_path
  Fontist.fontist_path.join("fontist_index.preferred_family.yml")
end

.fontist_version_pathObject



122
123
124
# File 'lib/fontist.rb', line 122

def self.fontist_version_path
  Fontist.fontist_path.join("versions", formulas_version)
end

.fonts_pathObject



114
115
116
# File 'lib/fontist.rb', line 114

def self.fonts_path
  Pathname.new(config[:fonts_path])
end

.formula_filename_index_pathObject



200
201
202
# File 'lib/fontist.rb', line 200

def self.formula_filename_index_path
  formula_index_dir.join("filename_index.yml")
end

.formula_index_dirObject



204
205
206
# File 'lib/fontist.rb', line 204

def self.formula_index_dir
  Fontist.fontist_version_path
end

.formula_index_pathObject



192
193
194
# File 'lib/fontist.rb', line 192

def self.formula_index_path
  formula_index_dir.join("formula_index.default_family.yml")
end

.formula_preferred_family_index_pathObject



196
197
198
# File 'lib/fontist.rb', line 196

def self.formula_preferred_family_index_path
  formula_index_dir.join("formula_index.preferred_family.yml")
end

.formula_size_limit_in_megabytesObject



208
209
210
# File 'lib/fontist.rb', line 208

def self.formula_size_limit_in_megabytes
  300
end

.formulas_pathObject



134
135
136
# File 'lib/fontist.rb', line 134

def self.formulas_path
  @formulas_path || Fontist.formulas_repo_path.join("Formulas")
end

.formulas_path=(path) ⇒ Object



138
139
140
# File 'lib/fontist.rb', line 138

def self.formulas_path=(path)
  @formulas_path = path
end

.formulas_repo_pathObject



118
119
120
# File 'lib/fontist.rb', line 118

def self.formulas_repo_path
  Fontist.fontist_version_path.join("formulas")
end

.formulas_repo_path_exists!Object



270
271
272
273
274
275
276
277
278
279
# File 'lib/fontist.rb', line 270

def self.formulas_repo_path_exists!
  return true if Dir.exist?(Fontist.formulas_repo_path.join("Formulas"))

  # Auto-update formulas repo if it doesn't exist (lazy initialization).
  # This ensures formulas are always discoverable without requiring
  # explicit `fontist update`.
  Formula.update_formulas_repo

  true
end

.formulas_repo_urlObject



130
131
132
# File 'lib/fontist.rb', line 130

def self.formulas_repo_url
  "https://github.com/fontist/formulas.git"
end

.formulas_versionObject



126
127
128
# File 'lib/fontist.rb', line 126

def self.formulas_version
  "v5"
end

.google_fonts_keyObject



266
267
268
# File 'lib/fontist.rb', line 266

def self.google_fonts_key
  ENV["GOOGLE_FONTS_API_KEY"] || config[:google_fonts_key]
end

.import_cache_pathObject



154
155
156
157
158
# File 'lib/fontist.rb', line 154

def self.import_cache_path
  @import_cache_path ||
    (ENV["FONTIST_IMPORT_CACHE"] ? Pathname.new(ENV["FONTIST_IMPORT_CACHE"]) : nil) ||
    Fontist.fontist_path.join("import_cache")
end

.import_cache_path=(path) ⇒ Object



150
151
152
# File 'lib/fontist.rb', line 150

def self.import_cache_path=(path)
  @import_cache_path = Pathname.new(path) if path
end

.interactive=(bool) ⇒ Object



252
253
254
# File 'lib/fontist.rb', line 252

def self.interactive=(bool)
  @interactive = bool
end

.interactive?Boolean

Returns:

  • (Boolean)


248
249
250
# File 'lib/fontist.rb', line 248

def self.interactive?
  @interactive || false
end

.lib_pathObject



98
99
100
# File 'lib/fontist.rb', line 98

def self.lib_path
  Fontist.root_path.join("lib")
end

.log_level=(level) ⇒ Object



244
245
246
# File 'lib/fontist.rb', line 244

def self.log_level=(level)
  Fontist.ui.level = level
end

.open_timeoutObject



220
221
222
# File 'lib/fontist.rb', line 220

def self.open_timeout
  config[:open_timeout]
end

.preferred_family=(bool) ⇒ Object



216
217
218
# File 'lib/fontist.rb', line 216

def self.preferred_family=(bool)
  @preferred_family = bool
end

.preferred_family?Boolean

Returns:

  • (Boolean)


212
213
214
# File 'lib/fontist.rb', line 212

def self.preferred_family?
  !!@preferred_family
end

.private_formulas_pathObject



142
143
144
# File 'lib/fontist.rb', line 142

def self.private_formulas_path
  Fontist.formulas_path.join("private")
end

.read_timeoutObject



224
225
226
# File 'lib/fontist.rb', line 224

def self.read_timeout
  config[:read_timeout]
end

.root_pathObject



102
103
104
# File 'lib/fontist.rb', line 102

def self.root_path
  Pathname.new(File.dirname(__dir__))
end

.system_file_pathObject



160
161
162
# File 'lib/fontist.rb', line 160

def self.system_file_path
  Fontist.lib_path.join("fontist", "system.yml")
end

.system_index_pathObject



168
169
170
# File 'lib/fontist.rb', line 168

def self.system_index_path
  Fontist.fontist_path.join("system_index.default_family.yml")
end

.system_preferred_family_index_pathObject



172
173
174
# File 'lib/fontist.rb', line 172

def self.system_preferred_family_index_path
  Fontist.fontist_path.join("system_index.preferred_family.yml")
end

.uiObject



94
95
96
# File 'lib/fontist.rb', line 94

def self.ui
  Fontist::Utils::UI
end

.use_cache=(bool) ⇒ Object



240
241
242
# File 'lib/fontist.rb', line 240

def self.use_cache=(bool)
  @use_cache = bool
end

.use_cache?Boolean

Returns:

  • (Boolean)


236
237
238
# File 'lib/fontist.rb', line 236

def self.use_cache?
  instance_variable_defined?(:@use_cache) ? @use_cache : true
end

.user_index_pathObject



184
185
186
# File 'lib/fontist.rb', line 184

def self.user_index_path
  Fontist.fontist_path.join("user_index.default_family.yml")
end

.user_preferred_family_index_pathObject



188
189
190
# File 'lib/fontist.rb', line 188

def self.user_preferred_family_index_path
  Fontist.fontist_path.join("user_index.preferred_family.yml")
end