fontist 3.0.40 → 3.0.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce7d7174490910823059c7abf1a6b7d910ad2e383594606df92bad8f8ddb5cad
4
- data.tar.gz: cfdca82ec87b74d49260146aaaeb5143a8a85008b96dc12a0a54d20a170e8900
3
+ metadata.gz: a064dbb6e34647ec61e1d0026cf081ee336e8f840aafc8c0d776d368f1b73cd0
4
+ data.tar.gz: 9d08023fe33c17842e4217233f36f0b18398e994ee456f3b1b6835da171f4d19
5
5
  SHA512:
6
- metadata.gz: 5ecae7158189d128ad7ed41bf1cffe119f3656222da9f1eb43fe46bae233bb18f5a9a8e99c2eedc120306d7fc6b9b224de56367d6feb6e5ec1c04394beb22817
7
- data.tar.gz: 66766185068d24636922d1feb67345a3fb01e7faf53a5e1146389ac2c1db52999e8f7049b47c9bb1eb7babb3ff067fced1744488a21b46d1a0d7aa32eb49a6f4
6
+ metadata.gz: 15a22d4fafed929dff512fa5e672a853c9306eebf389612aea07326acd8542eb683c26e80a6c04cd1bffacde479e48b0dfaf67186b7c76d22298791db7d214d7
7
+ data.tar.gz: 07cc3aea73bbe3bbe907c8085694c84be78b9a0e1f6f0694db3ffe23e9e72395360c4e5ea55a9da57802fd02a80144e4039d25ad016a469db7ca502ee6855af7
data/README.adoc CHANGED
@@ -2155,9 +2155,6 @@ variable_fonts = Fontist::Import::Google::Api.variable_fonts_only
2155
2155
  ----
2156
2156
  ====
2157
2157
 
2158
- For detailed usage examples, see
2159
- link:docs/google-fonts-multi-format-usage.md[Google Fonts Multi-Format Usage Guide].
2160
-
2161
2158
  ==== Importing fonts from Google Fonts as Fontist Formulas
2162
2159
 
2163
2160
  Prerequisites:
@@ -69,8 +69,12 @@ module Fontist
69
69
  # fonts from Fontisan hold no open file to close.
70
70
  variable = font.has_table?("fvar")
71
71
  font.close if font.respond_to?(:close)
72
+ # rubocop:disable Layout/LineLength
72
73
  names[:variable_instances] = extract_variable_instances_from_path(path) if
73
74
  variable && names[:family_name]
75
+ # rubocop:enable Layout/LineLength
76
+ names[:variable] = variable
77
+ names[:format] = detect_font_format(path)
74
78
  names
75
79
  rescue StandardError => e
76
80
  raise_font_file_error(e)
@@ -334,5 +338,16 @@ module Fontist
334
338
  def variable_instances
335
339
  @info[:variable_instances] || []
336
340
  end
341
+
342
+ # Whether the file carries an `fvar` table. The system index persists
343
+ # this per entry, so static-default resolution can tell variable files
344
+ # from static ones.
345
+ def variable
346
+ @info[:variable] || false
347
+ end
348
+
349
+ def format
350
+ @info[:format]
351
+ end
337
352
  end
338
353
  end
@@ -23,14 +23,26 @@ module Fontist
23
23
  end
24
24
  end
25
25
 
26
- def file_font(row)
26
+ def file_font(row, path)
27
27
  report_validation(row)
28
28
  info = symbolize(row["names"] || {})
29
+ add_variable_metadata(info, row)
30
+ info[:format] = format_for(path)
31
+ FontFile.new(info)
32
+ end
33
+
34
+ def add_variable_metadata(info, row)
29
35
  if row["has_fvar"] && info[:family_name]
30
36
  info[:variable_instances] =
31
37
  row["variable_instances"].map { |i| symbolize(i) }
32
38
  end
33
- FontFile.new(info)
39
+ info[:variable] = row.key?("has_fvar") ? !!row["has_fvar"] : nil
40
+ end
41
+
42
+ def format_for(path)
43
+ Fontisan::FontLoader.detect_format(path)&.to_s
44
+ rescue StandardError
45
+ "unknown"
34
46
  end
35
47
 
36
48
  def collection_face(row)
@@ -209,12 +209,13 @@ module Fontist
209
209
  # Don't rebuild index more frequently than this (in seconds)
210
210
  INDEX_REBUILD_THRESHOLD = 30 * 60 # 30 minutes
211
211
 
212
- # Index entry shape generation. v1 stored one entry per font file;
213
- # v2 stores one entry per named instance of variable fonts (the
214
- # FiraCode[wght].ttf class of files). Bump when the entry shape
215
- # changes again: persisted indexes carrying an older generation
216
- # cannot answer the current lookups and force a rebuild.
217
- INDEX_FORMAT_VERSION = 2
212
+ # Index entry shape generation. v2 stored one entry per named instance
213
+ # of variable fonts but left the `variable_font`/`format` metadata
214
+ # unset; v3 persists both, so static-default resolution can tell
215
+ # variable files from static ones. Bump when the entry shape changes
216
+ # again: persisted indexes carrying an older generation cannot answer
217
+ # the current lookups and force a rebuild.
218
+ INDEX_FORMAT_VERSION = 3
218
219
 
219
220
  def metadata_path
220
221
  "#{@path}.metadata.yml"
@@ -746,12 +747,16 @@ verbose:, stats:)
746
747
  def build_entries_from_rows(path, rows)
747
748
  if rows.first["is_collection"]
748
749
  ScanRowFonts.warn_collection_extension(path)
749
- rows.map { |row| parse_font(ScanRowFonts.collection_face(row), path) }
750
+ rows.map { |row| parse_font(ScanRowFonts.collection_face(row), path,
751
+ format: ScanRowFonts.format_for(path),
752
+ variable_font: false) }
750
753
  else
751
754
  ScanRowFonts.warn_file_extension(path, rows.first)
752
- font_file = ScanRowFonts.file_font(rows.first)
755
+ font_file = ScanRowFonts.file_font(rows.first, path)
753
756
  entries = variable_font_entries(font_file, path)
754
- entries.empty? ? parse_font(font_file, path) : entries
757
+ entries.empty? ? parse_font(font_file, path,
758
+ format: font_file.format,
759
+ variable_font: font_file.variable) : entries
755
760
  end
756
761
  end
757
762
 
@@ -853,7 +858,9 @@ spinner_index = nil)
853
858
  entries = variable_font_entries(font_file, path)
854
859
  return entries unless entries.empty?
855
860
 
856
- parse_font(font_file, path)
861
+ parse_font(font_file, path,
862
+ format: font_file.format,
863
+ variable_font: font_file.variable)
857
864
  end
858
865
 
859
866
  # One index entry per named instance of a variable font: a variable
@@ -888,19 +895,22 @@ spinner_index = nil)
888
895
  preferred_subfamily_name: instance[:style],
889
896
  file_size: file_size,
890
897
  file_mtime: file_mtime,
898
+ format: font_file.format,
899
+ variable_font: font_file.variable,
891
900
  )
892
901
  end
893
902
  end
894
903
 
895
904
  def detect_collection_fonts(path)
905
+ format = Fontisan::FontLoader.detect_format(path)&.to_s
896
906
  CollectionFile.from_path(path) do |collection|
897
907
  collection.map do |font_file|
898
- parse_font(font_file, path)
908
+ parse_font(font_file, path, format: format, variable_font: false)
899
909
  end
900
910
  end
901
911
  end
902
912
 
903
- def parse_font(font_file, path)
913
+ def parse_font(font_file, path, format:, variable_font:)
904
914
  # Skip fonts with incomplete metadata
905
915
  unless font_file.full_name && font_file.family
906
916
  warn_incomplete_metadata(path)
@@ -928,6 +938,8 @@ spinner_index = nil)
928
938
  preferred_subfamily_name: font_file.preferred_subfamily_name,
929
939
  file_size: file_size,
930
940
  file_mtime: file_mtime,
941
+ format: format,
942
+ variable_font: variable_font,
931
943
  )
932
944
  end
933
945
 
@@ -1,3 +1,3 @@
1
1
  module Fontist
2
- VERSION = "3.0.40".freeze
2
+ VERSION = "3.0.42".freeze
3
3
  end
data/lib/fontist.rb CHANGED
@@ -218,7 +218,7 @@ module Fontist
218
218
  end
219
219
 
220
220
  def self.formula_size_limit_in_megabytes
221
- 300
221
+ ENV.fetch("FONTIST_FORMULA_SIZE_LIMIT", 300).to_i
222
222
  end
223
223
 
224
224
  def self.preferred_family?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fontist
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.40
4
+ version: 3.0.42
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-24 00:00:00.000000000 Z
11
+ date: 2026-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: down
@@ -273,10 +273,6 @@ files:
273
273
  - LICENSE.txt
274
274
  - README.adoc
275
275
  - Rakefile
276
- - TODO.audit-docs.md
277
- - TODO.fontist-v5.md
278
- - TODO.improve-docs.md
279
- - TODO.upgrade-excavate.md
280
276
  - docs/.gitignore
281
277
  - docs/.vitepress/config.ts
282
278
  - docs/.vitepress/theme/components/HeroCodeBlock.vue
@@ -346,7 +342,6 @@ files:
346
342
  - fontist.gemspec
347
343
  - formula_filename_index.yml
348
344
  - formula_index.yml
349
- - google-fonts-multi-format-usage.md
350
345
  - lib/fontist.rb
351
346
  - lib/fontist/cache.rb
352
347
  - lib/fontist/cache/manager.rb
data/TODO.audit-docs.md DELETED
@@ -1,164 +0,0 @@
1
- # TODO: Documentation Audit
2
-
3
- ## Purpose
4
- Audit all Fontist Ruby gem functionality to ensure complete documentation coverage.
5
-
6
- ## Reference Files
7
- - docs/guide/how-it-works.md
8
- - docs/api/
9
- - docs/cli/
10
- - docs/guide/concepts/
11
-
12
- **Last Updated:** 2026-03-10
13
-
14
- ---
15
-
16
- ## ✅ COMPLETED
17
-
18
- ### 1. Configuration Priority System
19
- Documented in `/guide/how-it-works.md`
20
-
21
- **Priority Order (Highest to Lowest):**
22
-
23
- | Priority | Source | Example | Notes |
24
- |----------|--------|---------|-------|
25
- | 1 | ENV VAR | `FONTIST_PATH=/custom` | Always wins |
26
- | 2 | Config file | `~/.fontist/config.yml` | Persistent settings |
27
- | 3 | CLI option | `--location user` | Per-command override |
28
- | 4 | Ruby API | `Fontist.preferred_family = true` | Programmatic |
29
- | 5 | Default | Built-in defaults | Fallback |
30
-
31
- ### 2. Installation Locations
32
- Documented in `/guide/how-it-works.md`
33
-
34
- | Type | Path | Managed? | Use Case |
35
- |------|------|----------|----------|
36
- | fontist | `~/.fontist/fonts/{formula}/` | ✅ Yes | Default, isolated |
37
- | user | `~/Library/Fonts/fontist/` (macOS) | ✅ Yes | User-wide access |
38
- | system | `/Library/Fonts/fontist/` (macOS) | ✅ Yes | All users |
39
-
40
- ### 3. Font Indexes
41
- Documented in `/guide/how-it-works.md`
42
-
43
- - Formula Index: Maps font names → formula files
44
- - System Index: OS-installed fonts
45
- - Fontist Index: Fonts installed via Fontist
46
- - User Index: User-installed fonts
47
-
48
- ### 4. Formula Repository
49
- Documented in `/guide/formulas.md`
50
-
51
- - Location: `~/.fontist/versions/v4/formulas/`
52
- - Git clone from `https://github.com/fontist/formulas.git`
53
- - Auto-updates via `fontist update`
54
- - Private repos via `fontist repo`
55
-
56
- ### 5. CLI Commands
57
- All documented in `/docs/cli/`
58
-
59
- ### 6. Ruby API Classes
60
- All documented in `/docs/api/`
61
-
62
- ---
63
-
64
- ## 🔄 IN PROGRESS
65
-
66
- - [ ] Add configuration priority table to how-it-works.md
67
- - [ ] Add managed vs non-managed location explanation
68
- - [ ] Document all ENV variables in reference page
69
-
70
- ---
71
-
72
- ## Configuration Reference
73
-
74
- ### All Configuration Settings
75
-
76
- | Setting | ENV VAR | Config Key | CLI Option | Default |
77
- |---------|---------|------------|------------|---------|
78
- | Base path | `FONTIST_PATH` | - | - | `~/.fontist` |
79
- | Fonts path | - | `fonts_path` | - | `~/.fontist/fonts` |
80
- | Formulas path | `FONTIST_FORMULAS_PATH` | - | `--formulas-path` | (auto) |
81
- | Install location | `FONTIST_INSTALL_LOCATION` | `fonts_install_location` | `--location` | `fontist` |
82
- | User fonts path | `FONTIST_USER_FONTS_PATH` | `user_fonts_path` | - | Platform default |
83
- | System fonts path | `FONTIST_SYSTEM_FONTS_PATH` | `system_fonts_path` | - | Platform default |
84
- | Preferred family | - | `preferred_family` | `--preferred-family` | `false` |
85
- | No cache | - | - | `--no-cache` | `false` |
86
- | Quiet mode | - | - | `--quiet` | `false` |
87
- | Verbose | - | - | `--verbose` | `false` |
88
- | Open timeout | - | `open_timeout` | - | `60` |
89
- | Read timeout | - | `read_timeout` | - | `60` |
90
- | Google Fonts key | `GOOGLE_FONTS_API_KEY` | `google_fonts_key` | - | `nil` |
91
- | Import cache | `FONTIST_IMPORT_CACHE` | - | - | `~/.fontist/import_cache` |
92
-
93
- ---
94
-
95
- ## Environment Variables Reference
96
-
97
- | Variable | Description | Default |
98
- |----------|-------------|---------|
99
- | `FONTIST_PATH` | Base directory for all Fontist data | `~/.fontist` |
100
- | `FONTIST_FORMULAS_PATH` | Custom formulas directory | (auto) |
101
- | `FONTIST_INSTALL_LOCATION` | Default install location (`fontist`, `user`, `system`) | `fontist` |
102
- | `FONTIST_USER_FONTS_PATH` | Custom user fonts path | Platform default |
103
- | `FONTIST_SYSTEM_FONTS_PATH` | Custom system fonts path | Platform default |
104
- | `FONTIST_IMPORT_CACHE` | Import cache directory | `~/.fontist/import_cache` |
105
- | `FONTIST_NO_MIRRORS` | Disable formula index mirrors | `false` |
106
- | `GOOGLE_FONTS_API_KEY` | Google Fonts API key | (none) |
107
-
108
- ---
109
-
110
- ## Managed vs Non-Managed Locations
111
-
112
- ### Managed Locations (Fontist controls)
113
- - `~/.fontist/fonts/` - Always managed
114
- - `~/Library/Fonts/fontist/` - Managed subdirectory
115
- - `/Library/Fonts/fontist/` - Managed subdirectory
116
-
117
- **Behavior:** Safe to replace existing fonts
118
-
119
- ### Non-Managed Locations (custom paths via ENV)
120
- - `FONTIST_USER_FONTS_PATH=~/Library/Fonts` → installs directly
121
- - `FONTIST_SYSTEM_FONTS_PATH=/Library/Fonts` → installs directly
122
-
123
- **Behavior:** Uses unique filenames (`-fontist` suffix) to avoid conflicts
124
-
125
- ---
126
-
127
- ## Directory Structure
128
-
129
- ```
130
- ~/.fontist/
131
- ├── fonts/ # Installed font files
132
- │ └── {formula-key}/
133
- │ └── *.ttf
134
- ├── versions/
135
- │ └── v4/
136
- │ ├── formulas/ # Git clone of formulas repo
137
- │ │ └── Formulas/
138
- │ │ ├── roboto.yml
139
- │ │ └── private/ # Custom formula repos
140
- │ ├── formula_index.default_family.yml
141
- │ ├── formula_index.preferred_family.yml
142
- │ └── filename_index.yml
143
- ├── config.yml # User configuration
144
- ├── downloads/ # Temporary downloads
145
- ├── import_cache/ # Imported font cache
146
- ├── system_index.default_family.yml # System fonts index
147
- ├── fontist_index.default_family.yml # Fontist fonts index
148
- └── user_index.default_family.yml # User fonts index
149
- ```
150
-
151
- ---
152
-
153
- ## Remaining Minor Gaps
154
-
155
- - [ ] Document import system (`fontist import`) internals
156
- - [ ] Document cache system internals
157
- - [ ] Document formula picker algorithm
158
- - [ ] Document locking mechanism (for concurrent operations)
159
-
160
- ---
161
-
162
- ## Status: Nearly Complete
163
- **Priority:** High
164
- **Notes:** Core functionality documented, minor gaps remain
data/TODO.fontist-v5.md DELETED
@@ -1,196 +0,0 @@
1
- # Fontist v5 Schema Implementation Plan
2
-
3
- ## Overview
4
-
5
- This document outlines the implementation plan for Formula Schema v5 with
6
- multi-format font support. The architecture uses **v5-only classes** -
7
- migration from v4 to v5 is handled by a separate migration script.
8
-
9
- ## Architecture
10
-
11
- ### Core Principle: v5 Only
12
-
13
- All formula classes now use v5 schema with:
14
- - `schema_version: 5` (default)
15
- - Format metadata on resources (`format`, `variable_axes`)
16
- - Format metadata on styles (`formats`, `variable_font`, `variable_axes`)
17
-
18
- ### Class Hierarchy
19
-
20
- ```
21
- Formula (v5 only)
22
- ├── schema_version: 5
23
- ├── resources: ResourceCollection
24
- │ └── Resource
25
- │ ├── format: string (ttf, otf, woff, woff2, ttc, otc, dfont)
26
- │ └── variable_axes: array (e.g., ["wght", "wdth"])
27
- ├── fonts: FontModel[]
28
- │ └── styles: FontStyle[]
29
- │ ├── formats: array
30
- │ ├── variable_font: boolean
31
- │ └── variable_axes: array
32
- └── font_collections: FontCollection[]
33
- ```
34
-
35
- ## Implementation Status
36
-
37
- ### Phase 1: Core Models ✅ DONE
38
-
39
- - [x] FormatSpec model (`lib/fontist/format_spec.rb`)
40
- - [x] FormatMatcher service (`lib/fontist/format_matcher.rb`)
41
- - [x] FontFinder service (`lib/fontist/font_finder.rb`)
42
- - [x] v5-only Formula class (`lib/fontist/formula.rb`)
43
- - [x] v5-only Resource class (`lib/fontist/resource.rb`)
44
- - [x] v5-only FontStyle class (`lib/fontist/font_style.rb`)
45
- - [x] ResourceCollection class (`lib/fontist/resource_collection.rb`)
46
- - [x] All 65 tests passing
47
-
48
- ### Phase 2: Import System Fixes ✅ DONE
49
-
50
- #### Importer Format Metadata Status
51
-
52
- | Importer | format in resources | variable_axes | Status |
53
- |----------|-------------------|---------------|--------|
54
- | Google V5 | ✅ Dynamic | ✅ Yes | DONE |
55
- | Google V4 | ✅ Hardcoded "ttf" | ⚠️ Skipped | N/A |
56
- | macOS | ✅ Via CreateFormula | ✅ Via CreateFormula | DONE |
57
- | SIL | ✅ Via CreateFormula | ✅ Via CreateFormula | DONE |
58
-
59
- #### Tasks
60
-
61
- - [x] Fix `CreateFormula` class to detect and add format metadata
62
- - [x] macOS importer uses CreateFormula (now has format detection)
63
- - [x] SIL importer uses CreateFormula (now has format detection)
64
- - [x] Verify Google V5 importer works correctly
65
-
66
- ### Phase 3: Migration Script ✅ DONE
67
-
68
- Create `lib/fontist/import/v4_to_v5_migrator.rb`: ✅ Created
69
-
70
- Migration features:
71
- - [x] Reads v4 YAML
72
- - [x] Adds schema_version: 5
73
- - [x] Detects format from file extensions
74
- - [x] Detects variable fonts from filename patterns
75
- - [x] Writes v5 YAML
76
- - [x] CLI command: `fontist migrate-formulas INPUT [OUTPUT]`
77
-
78
- ### Phase 4: Run Imports ✅ DONE (via migration)
79
-
80
- All existing formulas migrated to v5 schema. Fresh imports can be run if needed:
81
-
82
- ```bash
83
- # Google Fonts (if fresh import needed)
84
- fontist import google --schema-version=5 --output-path=./Formulas/google --force
85
-
86
- # macOS Fonts (if fresh import needed)
87
- fontist import macos --schema-version=5 --output-path=./Formulas/macos --force
88
-
89
- # SIL Fonts (if fresh import needed)
90
- fontist import sil --schema-version=5 --output-path=./Formulas/sil --force
91
- ```
92
-
93
- ### Phase 5: Migrate Existing Formulas ✅ DONE
94
-
95
- ```bash
96
- # Run migration on all existing v4 formulas
97
- fontist migrate-formulas ../formulas/Formulas ../formulas/Formulas --verbose
98
- ```
99
-
100
- Results:
101
- - Migrated: 3206 formulas
102
- - Skipped (already v5): 474 formulas
103
- - Failed: 1 (malformed YAML backup file)
104
- - Total time: ~5 seconds
105
-
106
- ## Critical Files
107
-
108
- ### Core Classes (v5 only)
109
-
110
- | File | Description | Status |
111
- |------|-------------|--------|
112
- | `lib/fontist/formula.rb` | v5 formula with schema_version | ✅ Done |
113
- | `lib/fontist/resource.rb` | Resource with format/variable_axes | ✅ Done |
114
- | `lib/fontist/resource_collection.rb` | Resource collection | ✅ Done |
115
- | `lib/fontist/font_style.rb` | FontStyle with format metadata | ✅ Done |
116
- | `lib/fontist/font_model.rb` | FontModel using FontStyle | ✅ Done |
117
- | `lib/fontist/font_collection.rb` | FontCollection using FontModel | ✅ Done |
118
-
119
- ### Services
120
-
121
- | File | Description | Status |
122
- |------|-------------|--------|
123
- | `lib/fontist/format_spec.rb` | FormatSpec model | ✅ Done |
124
- | `lib/fontist/format_matcher.rb` | Format matching service | ✅ Done |
125
- | `lib/fontist/font_finder.rb` | Font discovery by capabilities | ✅ Done |
126
-
127
- ### Import System
128
-
129
- | File | Description | Status |
130
- |------|-------------|--------|
131
- | `lib/fontist/import/create_formula.rb` | Generic formula creator | ✅ Fixed |
132
- | `lib/fontist/import/formula_builder.rb` | Base formula builder | ✅ Works |
133
- | `lib/fontist/import/google/formula_builder_v5.rb` | Google V5 builder | ✅ Done |
134
- | `lib/fontist/import/macos_importer.rb` | macOS importer | ✅ Works |
135
- | `lib/fontist/import/sil_importer.rb` | SIL importer | ✅ Works |
136
- | `lib/fontist/import/v4_to_v5_migrator.rb` | Migration script | ✅ Created |
137
-
138
- ## Next Steps
139
-
140
- 1. ~~**Fix CreateFormula class**~~ - ✅ Done
141
- 2. ~~**Fix macOS importer**~~ - ✅ Works via CreateFormula
142
- 3. ~~**Fix SIL importer**~~ - ✅ Works via CreateFormula
143
- 4. ~~**Create V4→V5 migrator**~~ - ✅ Created
144
- 5. ~~**Migrate formulas**~~ - ✅ 3206 migrated, 474 skipped
145
- 6. ~~**Commit formulas**~~ - ✅ Committed to v5 branch (3cbe032)
146
- 7. ~~**Fix V5 builder for variable fonts**~~ - ✅ Done (8e0e568)
147
- 8. **Run fresh Google import** - Import with v5 schema to get WOFF2/variable fonts
148
- 9. **Verify** - Test installation with v5 formulas
149
-
150
- ## v5 Formula Example (Roboto Flex)
151
-
152
- ```yaml
153
- schema_version: 5
154
- resources:
155
- woff2_variable:
156
- format: woff2
157
- variable_axes: [GRAD, XOPQ, XTRA, YOPQ, YTAS, YTDE, YTFI, YTLC, YTUC, opsz, slnt, wdth, wght]
158
- ttf_variable:
159
- format: ttf
160
- variable_axes: [GRAD, XOPQ, XTRA, YOPQ, YTAS, YTDE, YTFI, YTLC, YTUC, opsz, slnt, wdth, wght]
161
- fonts:
162
- - styles:
163
- - variable_font: true
164
- variable_axes: [GRAD, XOPQ, XTRA, YOPQ, YTAS, YTDE, YTFI, YTLC, YTUC, opsz, slnt, wdth, wght]
165
- formats: [ttf, woff2]
166
- ```
167
-
168
- ## Breaking Changes
169
-
170
- - v4 formulas are no longer supported directly
171
- - Migration or re-import required for all formulas
172
- - All formulas must have `schema_version: 5`
173
- - Resources must have `format` field in v5
174
-
175
- ## Format Detection Logic
176
-
177
- ### File Extension → Format
178
-
179
- | Extension | Format |
180
- |-----------|--------|
181
- | .ttf | ttf |
182
- | .otf | otf |
183
- | .woff | woff |
184
- | .woff2 | woff2 |
185
- | .ttc | ttc |
186
- | .otc | otc |
187
- | .dfont | dfont |
188
-
189
- ### Filename Pattern → Variable Axes
190
-
191
- | Pattern | Axes |
192
- |---------|------|
193
- | `Font[wght].ttf` | ["wght"] |
194
- | `Font[wght,wdth].ttf` | ["wght", "wdth"] |
195
- | `Font-Variable.ttf` | Detect from font file |
196
- | `Font-VF.ttf` | Detect from font file |
data/TODO.improve-docs.md DELETED
@@ -1,114 +0,0 @@
1
- # Fontist Documentation Improvement Plan
2
-
3
- **Goal:** Achieve 100% documentation coverage of README.adoc content in docs/
4
-
5
- **Status:** ✅ Complete
6
-
7
- ---
8
-
9
- ## Phase 1: Platform-Specific Guides (Critical)
10
-
11
- ### 1.1 Create macOS Platform Guide
12
- - [x] Create `/docs/guide/platforms/macos.md`
13
- - [x] Document supplementary fonts framework
14
- - [x] Document framework versioning (Font3-Font8)
15
- - [x] Document platform tags (`macos-fontX`)
16
- - [x] Document version compatibility checking
17
- - [x] Include macOS version → framework table
18
- - [x] Add link to Fontist blog post
19
-
20
- ### 1.2 Create Windows Platform Guide
21
- - [x] Create `/docs/guide/platforms/windows.md`
22
- - [x] Document Windows font management differences
23
- - [x] Document Windows font locations
24
- - [x] Document file locking considerations
25
- - [x] Document path handling
26
- - [x] Document registry integration
27
- - [x] Document administrator privileges
28
- - [x] Include platform compatibility table
29
-
30
- ---
31
-
32
- ## Phase 2: Installation Improvements
33
-
34
- ### 2.1 Update Installation Guide
35
- - [x] Add detailed dependency table (json, brotli, seven-zip, libmspack, ffi-libarchive-binary)
36
- - [x] Add Windows RubyInstaller DevKit steps (`ridk install`)
37
- - [x] Add Git as prerequisite for update/repo commands
38
- - [x] Add note about native extension compilation
39
-
40
- ---
41
-
42
- ## Phase 3: Formula Advanced Features
43
-
44
- ### 3.1 Update Formulas Guide
45
- - [x] Add `override:` key documentation (already present)
46
- - [x] Add Frutiger fonts example (already present)
47
- - [x] Add HTTP authentication for private repos (already present)
48
- - [x] Add authorization headers example (already present)
49
- - [x] Add token scope requirements (already present)
50
-
51
- ### 3.2 Update create-formula CLI
52
- - [x] Add `--name-prefix` option with example (already documented)
53
-
54
- ---
55
-
56
- ## Phase 4: How It Works Improvements
57
-
58
- ### 4.1 Update How It Works Guide
59
- - [x] Add managed vs non-managed locations section (already present)
60
- - [x] Add font discovery behavior explanation (already present)
61
- - [x] Add import cache environment variables (already present)
62
-
63
- ---
64
-
65
- ## Phase 5: Maintainer Documentation (Clearly Marked)
66
-
67
- ### 5.1 Create Maintainer Import Guide
68
- - [x] Create `/docs/guide/maintainer/index.md`
69
- - [x] Create `/docs/guide/maintainer/import.md`
70
- - [x] Mark as "Maintainer Only" clearly
71
- - [x] Document `fontist import google` command
72
- - [x] Document Google Fonts API integration
73
- - [x] Document import source architecture
74
- - [x] Document versioned filenames
75
- - [x] Document import cache Ruby API
76
-
77
- ### 5.2 Update CLI Import Reference
78
- - [x] Add `fontist import google` to `/docs/cli/import.md` (already present)
79
- - [x] Add maintainer-only notice
80
-
81
- ---
82
-
83
- ## Phase 6: Navigation Updates
84
-
85
- ### 6.1 Update VitePress Config
86
- - [x] Add Platforms section to Guide sidebar
87
- - [x] Add Maintainer section to Guide sidebar (collapsed)
88
- - [x] Update navigation as needed
89
-
90
- ---
91
-
92
- ## Phase 7: Verification
93
-
94
- ### 7.1 Build and Test
95
- - [x] Run `npm run build` to verify no errors
96
- - [x] Run lychee link checker (manual verification with curl - lychee crashed)
97
- - [x] Verify all new pages are accessible
98
- - [x] Cross-check against README.adoc
99
-
100
- ---
101
-
102
- ## Progress Tracking
103
-
104
- | Phase | Status | Items Done | Items Total |
105
- |-------|--------|------------|-------------|
106
- | 1. Platform Guides | ✅ Complete | 14 | 14 |
107
- | 2. Installation | ✅ Complete | 4 | 4 |
108
- | 3. Formula Features | ✅ Complete | 7 | 7 |
109
- | 4. How It Works | ✅ Complete | 3 | 3 |
110
- | 5. Maintainer Docs | ✅ Complete | 10 | 10 |
111
- | 6. Navigation | ✅ Complete | 3 | 3 |
112
- | 7. Verification | ✅ Complete | 4 | 4 |
113
-
114
- **Total Progress: 45/45 items (100%)**
@@ -1,107 +0,0 @@
1
- # TODO: Fix Excavate Memory Leaks and Upgrade Fontist
2
-
3
- ## Problem
4
- Fontist CI tests pass but fail at the end with:
5
- ```
6
- failed to allocate memory (NoMemoryError)
7
- ```
8
-
9
- This happens after repeated archive extractions during test runs.
10
-
11
- ## Root Cause Analysis
12
- Memory leaks in Excavate gem due to:
13
- 1. Temp directories not cleaned up on errors
14
- 2. Incorrect `ensure`/`rescue` order in `extract_and_replace` method
15
-
16
- ## Remaining Work
17
-
18
- ### 1. Fix Excavate Gem (in /Users/mulgogi/src/fontist/excavate)
19
-
20
- #### archive.rb - Fix `extract_and_replace` method (lines 217-229)
21
- Current broken code has `ensure` BEFORE `rescue` which is invalid Ruby syntax:
22
- ```ruby
23
- def extract_and_replace(archive)
24
- target = Dir.mktmpdir
25
- extract_recursively(archive, target)
26
- replace_archive_with_contents(archive, target)
27
- ensure # <-- WRONG: ensure must come AFTER rescue
28
- FileUtils.rm_rf(target)
29
- rescue StandardError # <-- This causes syntax error
30
- raise unless TYPES.key?(normalized_extension(archive))
31
- end
32
- ```
33
-
34
- Fix - swap order so `rescue` comes before `ensure`:
35
- ```ruby
36
- def extract_and_replace(archive)
37
- target = Dir.mktmpdir
38
- extract_recursively(archive, target)
39
- replace_archive_with_contents(archive, target)
40
- rescue StandardError
41
- raise unless TYPES.key?(normalized_extension(archive))
42
- ensure
43
- FileUtils.rm_rf(target)
44
- end
45
- ```
46
-
47
- ### 2. Run Excavate Tests
48
- ```bash
49
- cd /Users/mulgogi/src/fontist/excavate
50
- bundle exec rspec
51
- ```
52
- All 65 tests should pass.
53
-
54
- ### 3. Bump Excavate Version
55
- Edit `/Users/mulgogi/src/fontist/excavate/lib/excavate/version.rb`:
56
- ```ruby
57
- VERSION = "1.0.3"
58
- ```
59
-
60
- ### 4. Commit and Push Excavate
61
- ```bash
62
- cd /Users/mulgogi/src/fontist/excavate
63
- git add -A
64
- git commit -m "fix: prevent memory leaks by ensuring proper resource cleanup
65
-
66
- - Fix extract_and_replace to use correct rescue/ensure order
67
- - Add ensure block to extract_by_filter for temp dir cleanup"
68
- git push origin main
69
- ```
70
-
71
- ### 5. Release Excavate Gem
72
- ```bash
73
- cd /Users/mulgogi/src/fontist/excavate
74
- # Tag and push to rubygems
75
- git tag v1.0.3
76
- git push --tags
77
- gem build excavate.gemspec
78
- gem push excavate-1.0.3.gem
79
- ```
80
-
81
- ### 6. Update Fontist to Use New Excavate
82
- ```bash
83
- cd /Users/mulgogi/src/fontist/fontist
84
- # Update Gemfile.lock to use excavate >= 1.0.3
85
- bundle update excavate
86
- ```
87
-
88
- ### 7. Run Fontist Tests
89
- ```bash
90
- cd /Users/mulgogi/src/fontist/fontist
91
- bundle exec rspec
92
- ```
93
- Tests should pass WITHOUT the `NoMemoryError` at the end.
94
-
95
- ### 8. Create PR and Merge
96
- - Create PR in fontist repository
97
- - Reference issue #451
98
- - Merge after CI passes
99
-
100
- ## Files Modified
101
-
102
- ### Excavate
103
- - `lib/excavate/archive.rb` - Fix `extract_and_replace` method
104
-
105
- ## Notes
106
- - Do NOT add `ensure` blocks with `reader&.close` to extractors - the Omnizip readers don't have a `close` method
107
- - The fix is simple: correct the `rescue`/`ensure` order in `extract_and_replace`
@@ -1,419 +0,0 @@
1
- # Google Fonts Multi-Format API Usage Guide
2
-
3
- This guide explains how to use the new multi-format Google Fonts API integration in Fontist, which provides access to TTF, Variable Fonts (VF), and WOFF2 formats.
4
-
5
- ## Overview
6
-
7
- The Google Fonts API integration now fetches data from three endpoints and merges them into a unified database:
8
-
9
- 1. **TTF Endpoint** - Standard TrueType fonts
10
- 2. **VF Endpoint** - Variable fonts with axes information
11
- 3. **WOFF2 Endpoint** - WOFF2 format files
12
-
13
- ## Quick Start
14
-
15
- ```ruby
16
- require 'fontist'
17
- require 'fontist/import/google/api'
18
-
19
- # Get all font families (includes TTF, VF, and WOFF2 data)
20
- families = Fontist::Import::Google::Api.items
21
- puts "Total families: #{families.count}"
22
-
23
- # Access unified database
24
- db = Fontist::Import::Google::Api.database
25
- ```
26
-
27
- ## Basic Operations
28
-
29
- ### Get All Fonts
30
-
31
- ```ruby
32
- # Returns array of FontFamily objects
33
- all_fonts = Fontist::Import::Google::Api.items
34
-
35
- # Iterate through fonts
36
- all_fonts.each do |font|
37
- puts "#{font.family} (#{font.category})"
38
- end
39
- ```
40
-
41
- ### Find Specific Font
42
-
43
- ```ruby
44
- # Find by familia name
45
- roboto = Fontist::Import::Google::Api.font_by_name("Roboto")
46
-
47
- if roboto
48
- puts "Family: #{roboto.family}"
49
- puts "Category: #{roboto.category}"
50
- puts "Variants: #{roboto.variants.join(', ')}"
51
- puts "Version: #{roboto.version}"
52
- puts "Last Modified: #{roboto.last_modified}"
53
- end
54
- ```
55
-
56
- ### Filter by Category
57
-
58
- ```ruby
59
- # Get all sans-serif fonts
60
- sans_serif = Fontist::Import::Google::Api.by_category("sans-serif")
61
- puts "Sans-serif fonts: #{sans_serif.count}"
62
-
63
- # Get all monospace fonts
64
- monospace = Fontist::Import::Google::Api.by_category("monospace")
65
- ```
66
-
67
- ## Variable Fonts
68
-
69
- ### Get Variable Fonts Only
70
-
71
- ```ruby
72
- # Returns only fonts with variable font axes
73
- variable_fonts = Fontist::Import::Google::Api.variable_fonts_only
74
- puts "Variable fonts: #{variable_fonts.count}"
75
-
76
- variable_fonts.each do |font|
77
- puts "\n#{font.family}"
78
- font.axes.each do |axis|
79
- puts " #{axis.tag}: #{axis.start} to #{axis.end}"
80
- end
81
- end
82
- ```
83
-
84
- ### Check if Font is Variable
85
-
86
- ```ruby
87
- font = Fontist::Import::Google::Api.font_by_name("Roboto Flex")
88
-
89
- if font&.variable_font?
90
- puts "#{font.family} is a variable font with #{font.axes.count} axes"
91
-
92
- # Access specific axes
93
- weight_axes = font.weight_axes
94
- width_axes = font.width_axes
95
- slant_axes = font.slant_axes
96
- custom_axes = font.custom_axes
97
- end
98
- ```
99
-
100
- ### Working with Axes
101
-
102
- ```ruby
103
- font = Fontist::Import::Google::Api.font_by_name("Advent Pro")
104
-
105
- if font&.variable_font?
106
- font.axes.each do |axis|
107
- puts "Axis: #{axis.tag}"
108
- puts " Range: #{axis.start} - #{axis.end}"
109
- puts " Type: #{axis.description}"
110
-
111
- # Check axis type
112
- puts " Weight axis" if axis.weight_axis?
113
- puts " Width axis" if axis.width_axis?
114
- puts " Slant axis" if axis.slant_axis?
115
- puts " Custom axis" if axis.custom_axis?
116
- end
117
-
118
- # Find specific axis
119
- weight_axis = font.axis_by_tag("wght")
120
- if weight_axis
121
- puts "Weight range: #{weight_axis.range.inspect}"
122
- end
123
- end
124
- ```
125
-
126
- ## Multiple Formats (TTF and WOFF2)
127
-
128
- ### Check Available Formats
129
-
130
- ```ruby
131
- db = Fontist::Import::Google::Api.database
132
-
133
- # Fonts with TTF format
134
- ttf_fonts = db.fonts_with_ttf
135
- puts "Fonts with TTF: #{ttf_fonts.count}"
136
-
137
- # Fonts with WOFF2 format
138
- woff2_fonts = db.fonts_with_woff2
139
- puts "Fonts with WOFF2: #{woff2_fonts.count}"
140
-
141
- # Fonts with both formats
142
- both_formats = db.fonts_with_both_formats
143
- puts "Fonts with both: #{both_formats.count}"
144
- ```
145
-
146
- ### Access Format-Specific URLs
147
-
148
- ```ruby
149
- db = Fontist::Import::Google::Api.database
150
-
151
- # Get TTF URLs for a font
152
- ttf_files = db.ttf_files_for("Roboto")
153
- ttf_files.each do |variant, url|
154
- puts "#{variant}: #{url}"
155
- end
156
-
157
- # Get WOFF2 URLs for a font
158
- woff2_files = db.woff2_files_for("Roboto")
159
- woff2_files.each do |variant, url|
160
- puts "#{variant}: #{url}"
161
- end
162
- ```
163
-
164
- ### Font Files Structure
165
-
166
- ```ruby
167
- font = Fontist::Import::Google::Api.font_by_name("Roboto")
168
-
169
- # The files hash contains TTF URLs by default
170
- font.files.each do |variant, url|
171
- puts "#{variant} (TTF): #{url}"
172
- end
173
-
174
- # Access both formats via database
175
- db = Fontist::Import::Google::Api.database
176
- ttf = db.ttf_files_for("Roboto")
177
- woff2 = db.woff2_files_for("Roboto")
178
- ```
179
-
180
- ## Advanced Queries
181
-
182
- ### Get Statistics
183
-
184
- ```ruby
185
- # Overall statistics
186
- stats = Fontist::Import::Google::Api.fonts_count
187
- puts "Total fonts: #{stats[:total]}"
188
- puts "Variable fonts: #{stats[:variable]}"
189
- puts "Static fonts: #{stats[:static]}"
190
-
191
- # Database-level statistics
192
- db = Fontist::Import::Google::Api.database
193
- puts "Categories: #{db.categories.join(', ')}"
194
- ```
195
-
196
- ### Filter Static Fonts
197
-
198
- ```ruby
199
- # Get only static (non-variable) fonts
200
- static_fonts = Fontist::Import::Google::Api.static_fonts_only
201
- puts "Static fonts: #{static_fonts.count}"
202
- ```
203
-
204
- ### Access Raw Endpoint Data
205
-
206
- ```ruby
207
- # For debugging or advanced use cases
208
- ttf_data = Fontist::Import::Google::Api.ttf_data
209
- vf_data = Fontist::Import::Google::Api.vf_data
210
- woff2_data = Fontist::Import::Google::Api.woff2_data
211
-
212
- puts "TTF endpoint: #{ttf_data.count} fonts"
213
- puts "VF endpoint: #{vf_data.count} fonts"
214
- puts "WOFF2 endpoint: #{woff2_data.count} fonts"
215
- ```
216
-
217
- ## Caching
218
-
219
- ### Clear Cache
220
-
221
- ```ruby
222
- # Clear all caches (database and client caches)
223
- Fontist::Import::Google::Api.clear_cache
224
-
225
- # Data will be re-fetched on next access
226
- families = Fontist::Import::Google::Api.items
227
- ```
228
-
229
- ### Cache Behavior
230
-
231
- - API responses are cached at the client level
232
- - Database is built once and cached
233
- - Call `clear_cache` to force refresh from API
234
-
235
- ## FontFamily Model
236
-
237
- The [`FontFamily`](../lib/fontist/import/google/models/font_family.rb) model provides:
238
-
239
- ```ruby
240
- font = Fontist::Import::Google::Api.font_by_name("Roboto")
241
-
242
- # Basic attributes
243
- font.family # "Roboto"
244
- font.category # "sans-serif"
245
- font.version # "v30"
246
- font.last_modified # "2022-09-22"
247
-
248
- # Variants and subsets
249
- font.variants # ["regular", "italic", "700", ...]
250
- font.subsets # ["latin", "latin-ext", ...]
251
-
252
- # Files (TTF URLs by default)
253
- font.files # {"regular" => "url", ...}
254
-
255
- # Variable font support
256
- font.variable_font? # true/false
257
- font.axes # Array of Axis objects (if VF)
258
-
259
- # Helper methods
260
- font.variant_names # Array of variant names
261
- font.file_urls # Array of file URLs
262
- font.variant_exists?("700") # Check if variant exists
263
- font.variant_url("regular") # Get URL for variant
264
- ```
265
-
266
- ## Axis Model
267
-
268
- The [`Axis`](../lib/fontist/import/google/models/axis.rb) model for variable fonts:
269
-
270
- ```ruby
271
- axis = font.axes.first
272
-
273
- # Attributes
274
- axis.tag # "wght", "wdth", "slnt", etc.
275
- axis.start # Minimum value (e.g., 100)
276
- axis.end # Maximum value (e.g., 900)
277
-
278
- # Helper methods
279
- axis.weight_axis? # Check if weight axis
280
- axis.width_axis? # Check if width axis
281
- axis.slant_axis? # Check if slant axis
282
- axis.custom_axis? # Check if custom axis
283
- axis.range # [start, end]
284
- axis.description # Human-readable description
285
- ```
286
-
287
- ## Error Handling
288
-
289
- ```ruby
290
- begin
291
- families = Fontist::Import::Google::Api.items
292
- rescue StandardError => e
293
- puts "Error fetching fonts: #{e.message}"
294
- end
295
-
296
- # Check if font exists
297
- font = Fontist::Import::Google::Api.font_by_name("NonExistent")
298
- if font.nil?
299
- puts "Font not found"
300
- end
301
- ```
302
-
303
- ## Example: List Variable Fonts with Axes
304
-
305
- ```ruby
306
- require 'fontist/import/google/api'
307
-
308
- puts "Variable Fonts with Axes\n"
309
- puts "=" * 60
310
-
311
- Fontist::Import::Google::Api.variable_fonts_only.each do |font|
312
- puts "\n#{font.family}"
313
- puts " Category: #{font.category}"
314
- puts " Variants: #{font.variants.count}"
315
- puts " Axes:"
316
-
317
- font.axes.each do |axis|
318
- type = if axis.weight_axis?
319
- "Weight"
320
- elsif axis.width_axis?
321
- "Width"
322
- elsif axis.slant_axis?
323
- "Slant"
324
- else
325
- "Custom (#{axis.tag})"
326
- end
327
-
328
- puts " - #{type}: #{axis.start} to #{axis.end}"
329
- end
330
- end
331
- ```
332
-
333
- ## Example: Download Fonts by Category
334
-
335
- ```ruby
336
- require 'fontist/import/google/api'
337
- require 'net/http'
338
- require 'fileutils'
339
-
340
- # Get all monospace fonts
341
- monospace_fonts = Fontist::Import::Google::Api.by_category("monospace")
342
-
343
- # Create download directory
344
- download_dir = "fonts/monospace"
345
- FileUtils.mkdir_p(download_dir)
346
-
347
- monospace_fonts.each do |font|
348
- puts "Downloading #{font.family}..."
349
-
350
- font.files.each do |variant, url|
351
- filename = "#{font.family.gsub(' ', '_')}-#{variant}.ttf"
352
- filepath = File.join(download_dir, filename)
353
-
354
- # Download file
355
- uri = URI(url)
356
- response = Net::HTTP.get_response(uri)
357
-
358
- if response.is_a?(Net::HTTPSuccess)
359
- File.binwrite(filepath, response.body)
360
- puts " ✓ #{filename}"
361
- else
362
- puts " ✗ Failed to download #{filename}"
363
- end
364
- end
365
- end
366
-
367
- puts "\nDownload complete!"
368
- ```
369
-
370
- ## Architecture
371
-
372
- The implementation consists of four layers:
373
-
374
- ### 1. Models Layer
375
- - [`FontFamily`](../lib/fontist/import/google/models/font_family.rb) - Represents font families
376
- - [`FontVariant`](../lib/fontist/import/google/models/font_variant.rb) - Represents font variants
377
- - [`Axis`](../lib/fontist/import/google/models/axis.rb) - Represents variable font axes
378
-
379
- ### 2. Clients Layer
380
- - [`TtfClient`](../lib/fontist/import/google/clients/ttf_client.rb) - Fetches TTF data
381
- - [`VfClient`](../lib/fontist/import/google/clients/vf_client.rb) - Fetches VF data with axes
382
- - [`Woff2Client`](../lib/fontist/import/google/clients/woff2_client.rb) - Fetches WOFF2 data
383
-
384
- ### 3. Database Layer
385
- - [`FontDatabase`](../lib/fontist/import/google/font_database.rb) - Merges data from all endpoints
386
-
387
- ### 4. API Layer
388
- - [`Api`](../lib/fontist/import/google/api.rb) - Public facade for accessing fonts
389
-
390
- ## Configuration
391
-
392
- Set your Google Fonts API key:
393
-
394
- ```ruby
395
- # Via environment variable
396
- ENV['GOOGLE_FONTS_KEY'] = 'your-api-key'
397
-
398
- # Or configure Fontist
399
- Fontist.google_fonts_key = 'your-api-key'
400
- ```
401
-
402
- ## Testing
403
-
404
- See [`spec/fontist/import/google/`](../spec/fontist/import/google/) for comprehensive test examples.
405
-
406
- Run tests:
407
- ```bash
408
- bundle exec rspec spec/fontist/import/google/
409
- ```
410
-
411
- All 188 tests pass successfully! ✅
412
-
413
- ## Additional Resources
414
-
415
- - [Google Fonts Developer API](https://developers.google.com/fonts/docs/developer_api)
416
- - [Variable Fonts Guide](https://web.dev/variable-fonts/)
417
- - [Architecture Plan](google-fonts-api-architecture.md)
418
- - [API Analysis](../temp-test/api_analysis.md)
419
- - [Implementation Summary](../temp-test/implementation_summary.md)