Class: Fontist::Import::GoogleFontsImporter
- Inherits:
-
Object
- Object
- Fontist::Import::GoogleFontsImporter
- Defined in:
- lib/fontist/import/google_fonts_importer.rb
Overview
Google Fonts importer using unified FontDatabase architecture
Generates v4 formulas from Google Fonts API (TTF only) with OFL.txt from GitHub. Downloads and parses fonts with Fontisan to extract accurate metadata.
Instance Method Summary collapse
- #import ⇒ Object
-
#initialize(options = {}) ⇒ GoogleFontsImporter
constructor
A new instance of GoogleFontsImporter.
Constructor Details
#initialize(options = {}) ⇒ GoogleFontsImporter
Returns a new instance of GoogleFontsImporter.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fontist/import/google_fonts_importer.rb', line 12 def initialize( = {}) @api_key = [:api_key] || ENV.fetch("GOOGLE_FONTS_API_KEY") do raise "GOOGLE_FONTS_API_KEY environment variable not set" end @source_path = [:source_path] || raise("source_path required for v4/v5 formula generation") @output_path = [:output_path] || "./Formulas/google" @font_family = [:font_family] @verbose = [:verbose] @import_cache = [:import_cache] @force = [:force] @schema_version = [:schema_version] || 4 @success_count = 0 @failure_count = 0 @skipped_count = 0 @overwritten_count = 0 @failures = [] # Track {name, reason} for each failure end |
Instance Method Details
#import ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fontist/import/google_fonts_importer.rb', line 30 def import start_time = Time.now # Display header with import cache display_header # Build database database = build_database # Get font list font_families = @font_family ? [@font_family] : database.all_fonts.map(&:family) if @verbose Fontist.ui.say("📦 Found #{Paint[font_families.size, :yellow, :bright]} font families to import") Fontist.ui.say("📁 Saving formulas to: #{Paint[@output_path, :cyan]}") Fontist.ui.say("") end # Process fonts process_fonts(database, font_families) # Display summary display_summary(font_families.size, Time.now - start_time) # Display failures after summary display_failures build_results(Time.now - start_time) end |