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/import/windows.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/windows_fod_metadata.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/windows_import_source.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/resources/windows_fod_resource.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, WindowsFodMetadata, WindowsImportSource

Constant Summary collapse

VERSION =
"3.0.2".freeze

Class Method Summary collapse

Class Method Details

.auto_overwriteObject



259
260
261
262
263
# File 'lib/fontist.rb', line 259

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

  nil
end

.auto_overwrite=(value) ⇒ Object



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

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

.configObject



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

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

.config_pathObject



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

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

.default_fontist_pathObject



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

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

.downloads_pathObject



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

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

.excluded_fonts_pathObject



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

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

.fontist_index_pathObject



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

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

.fontist_pathObject



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

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

.fontist_preferred_family_index_pathObject



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

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

.fontist_version_pathObject



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

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

.fonts_pathObject



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

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

.formula_filename_index_pathObject



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

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

.formula_index_dirObject



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

def self.formula_index_dir
  Fontist.fontist_version_path
end

.formula_index_pathObject



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

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

.formula_preferred_family_index_pathObject



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

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

.formula_size_limit_in_megabytesObject



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

def self.formula_size_limit_in_megabytes
  300
end

.formulas_pathObject



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

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

.formulas_path=(path) ⇒ Object



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

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

.formulas_repo_pathObject



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

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

.formulas_repo_path_exists!Object



273
274
275
276
277
278
279
280
281
282
# File 'lib/fontist.rb', line 273

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



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

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

.formulas_versionObject



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

def self.formulas_version
  "v5"
end

.google_fonts_keyObject



269
270
271
# File 'lib/fontist.rb', line 269

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

.import_cache_pathObject



157
158
159
160
161
# File 'lib/fontist.rb', line 157

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



153
154
155
# File 'lib/fontist.rb', line 153

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

.interactive=(bool) ⇒ Object



255
256
257
# File 'lib/fontist.rb', line 255

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

.interactive?Boolean

Returns:

  • (Boolean)


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

def self.interactive?
  @interactive || false
end

.lib_pathObject



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

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

.log_level=(level) ⇒ Object



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

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

.open_timeoutObject



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

def self.open_timeout
  config[:open_timeout]
end

.preferred_family=(bool) ⇒ Object



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

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

.preferred_family?Boolean

Returns:

  • (Boolean)


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

def self.preferred_family?
  !!@preferred_family
end

.private_formulas_pathObject



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

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

.read_timeoutObject



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

def self.read_timeout
  config[:read_timeout]
end

.root_pathObject



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

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

.system_file_pathObject



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

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

.system_index_pathObject



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

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

.system_preferred_family_index_pathObject



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

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

.uiObject



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

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

.use_cache=(bool) ⇒ Object



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

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

.use_cache?Boolean

Returns:

  • (Boolean)


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

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

.user_index_pathObject



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

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

.user_preferred_family_index_pathObject



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

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