intellifont-engine 0.1.0

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.
package/LICENSE ADDED
@@ -0,0 +1,191 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ --------------------------------------------------------------------------------
179
+ ADDITIONAL DATA LICENSE CLAUSE
180
+ --------------------------------------------------------------------------------
181
+
182
+ The software is provided with a "Core Font Signature Database" containing metadata
183
+ for approximately 2,000 fonts. Use of this Core Database is permitted under the
184
+ terms of this Apache License.
185
+
186
+ Access to the "Extended Intelligence Database" (containing signatures for 20,000+
187
+ fonts) and the "Enterprise CDN" is strictly restricted to Pro and Enterprise
188
+ licensees. Integration or use of the Extended Database without a valid commercial
189
+ agreement from IntelliFont Team is strictly prohibited.
190
+
191
+ © 2026 IntelliFont Team. All Rights Reserved.
package/README.md ADDED
@@ -0,0 +1,173 @@
1
+ # intelliFont Engine
2
+
3
+ **The Ultimate Professional Font Recognition & Suggestion Toolkit.**
4
+
5
+ `intellifont-engine` is a high-performance, Rust-powered engine designed for mission-critical design applications. Whether you are building a PDF editor, a web builder, or a design tool, this engine ensures that no font ever goes missing and every layout remains pixel-perfect.
6
+
7
+ ---
8
+
9
+ ## Why intelliFont?
10
+
11
+ Traditional font matching relies on exact string comparisons, which fail if the user's system names a font slightly differently (e.g., "HelveticaNeue" vs "Helvetica Neue").
12
+
13
+ **intelliFont** uses **Biometric Metric Matching**—analyzing the physical architecture of the font itself (ascenders, descenders, x-height, and cap-height)—to find the perfect match or the best possible substitute.
14
+
15
+ ### Key Capabilities:
16
+ - **Blazing Speed**: Rust-core execution means sub-1ms response times for local lookups.
17
+ - **Pre-Seeded Database**: Comes with **2,000+ popular font signatures** (Google Fonts, System Standards) embedded in a highly compressed 4.5MB binary asset.
18
+ - **Layout Authority**: Exports precise physical metrics to ensure PDF and Canvas layouts never shift during font substitution.
19
+ - **Hybrid Intelligence**: Scans local OS fonts and queries global CDNs (Google, Fontsource) in parallel.
20
+ - **Legal Guardrails**: Real-time license detection for OFL, Apache, and commercial fonts, protecting users from legal risks.
21
+
22
+ ---
23
+
24
+ ## Architecture Overview
25
+
26
+ The engine is built on a "Service-Core" architecture:
27
+ 1. **The Rust Core**: Handles heavy-duty binary parsing, Brotli decompression of the signature database, and parallel network queries using Tokio.
28
+ 2. **The NAPI-RS Bridge**: Provides a zero-copy memory bridge between Rust and Node.js, ensuring that huge font lists don't cause garbage collection lag.
29
+ 3. **The Metadata Cache**: A dual-layer cache (Memory + Persistent Disk) that learns from every search, making web results instant and offline-ready on the next launch.
30
+
31
+ ---
32
+
33
+ ## Installation
34
+
35
+ ### As a Library (Recommended)
36
+ Add it to your React, Vue, or Node.js project:
37
+ ```bash
38
+ npm install intellifont-engine
39
+ ```
40
+
41
+ ### As a Global CLI Tool
42
+ Powerful font management directly from your terminal:
43
+ ```bash
44
+ npm install -g intellifont-engine
45
+ ```
46
+
47
+ ---
48
+
49
+ ## 🛠️ CLI Usage (The 'intellifont' command)
50
+
51
+ Once installed globally, `intellifont` provides a robust set of tools for developers and system administrators.
52
+
53
+ ### Core Commands
54
+
55
+ | Command | Description |
56
+ | :--- | :--- |
57
+ | `intellifont stats` | Display exhaustive engine metrics: font counts, database compression ratio, and cache health. |
58
+ | `intellifont resolve "Font"` | Performs a high-speed resolution using local assets and the metadata cache. |
59
+ | `intellifont tiered "Font"` | Advanced similarity analysis. Returns results in 90% (Exact) and 80% (Similar) tiers. |
60
+ | `intellifont tiered "Font" --internet` | Activate global CDN lookup (Google Fonts, Fontsource) if local matches are insufficient. |
61
+ | `intellifont find-similar "Font"` | Identify fonts that are visually or metrically similar to a target baseline font. |
62
+ | `intellifont check-license "Font"` | Analyze licensing metadata for commercial safety and provide free equivalents. |
63
+ | `intellifont scan [--detailed]` | Deep recursive scan of system font directories to index new assets. |
64
+ | `intellifont update` | Synchronize local signatures with the global repository and regenerate binary indexes. |
65
+ | `intellifont setup` | Guided 3-step configuration for memory limits and provider priorities. |
66
+ | `intellifont version` | Display engine version, build architecture, and capability flags. |
67
+
68
+ ### Cache Management (`intellifont cache <command>`)
69
+
70
+ | Subcommand | Description |
71
+ | :--- | :--- |
72
+ | `cache stats` | View hit rates, memory footprint, and disk usage of the local cache. |
73
+ | `cache cleanup` | Remove stale entries. Use `--aggressive` to clear single-use fonts. |
74
+ | `cache pin "Font"` | Lock a font permanently in the cache so it is never evicted. |
75
+ | `cache unpin "Font"` | Release a font from the permanent cache lock. |
76
+ | `cache list` | List all manually and automatically pinned (highly used) fonts. |
77
+ | `cache suggest` | Analyze usage patterns and suggest non-pinned entries for manual removal. |
78
+
79
+ ### Configuration (`intellifont config <command>`)
80
+
81
+ | Subcommand | Description |
82
+ | :--- | :--- |
83
+ | `config show` | View current engine limits (Memory, Disk, Web Access). |
84
+ | `config set <key> <val>` | Directly modify configuration (e.g., `intellifont config set memory_limit 16`). |
85
+ | `config reset` | Restore all engine settings to factory defaults. |
86
+ | `config export <path>` | Export your current setup to a `.toml` file for team sharing. |
87
+ | `config import <path>` | Load a shared configuration file to synchronize settings across environments. |
88
+
89
+ ---
90
+
91
+ ## JavaScript API
92
+
93
+ `intellifont-engine` provides a simple, Promise-based API for Node.js environments.
94
+
95
+ ### `getEnhancedSuggestions(name, useWebFonts)`
96
+ The primary entry point for building "Suggested Fonts" dropdowns.
97
+
98
+ ```javascript
99
+ const { getEnhancedSuggestions } = require('intellifont-engine');
100
+
101
+ async function resolveFont(inputName) {
102
+ // Parallel search: Local System + Global Fontsource/Google
103
+ const results = await getEnhancedSuggestions(inputName, true);
104
+
105
+ results.forEach(res => {
106
+ console.log(`Match Found: ${res.family}`);
107
+ console.log(`Similarity: ${(res.score * 100).toFixed(1)}%`);
108
+
109
+ // License Guardrail
110
+ if (res.isCriticalLicenseWarning) {
111
+ console.warn("🚫 Commercial License Required - Consider a free alternative.");
112
+ }
113
+ });
114
+ }
115
+ ```
116
+
117
+ ### `exportMetrics(fontName)`
118
+ Returns the physical "DNA" of a font. Essential for layout-stable PDF generators.
119
+
120
+ ```javascript
121
+ const { exportMetrics } = require('intellifont-engine');
122
+
123
+ const metrics = exportMetrics("Inter");
124
+ // Returns:
125
+ // {
126
+ // family: "Inter",
127
+ // ascender: 0.72,
128
+ // descender: -0.21,
129
+ // capHeight: 0.68,
130
+ // widthFactor: 1.05
131
+ // }
132
+ ```
133
+
134
+ ---
135
+
136
+ ## Advanced Features
137
+
138
+ ### Triple-Layer Safety Net
139
+ If a font is missing, intelliFont executes its survival strategy:
140
+ 1. **Direct Local Match**: Scans the user's OS fonts instantly.
141
+ 2. **CDN Deep Search**: Queries Google Fonts and Fontsource in parallel (2-second timeout).
142
+ 3. **Metric Substitution**: If nowhere to be found, it analyzes the missing font's metrics and finds a "Twin" on the local system to prevent layout breaking.
143
+
144
+ ### Learning Mode (Dynamic Caching)
145
+ The engine learns your project's typography. Any font resolved from the web is automatically "fingerprinted" and stored in the **Persistent Disk Cache**. Next time you search for that font, it will be found instantly—even without an internet connection.
146
+
147
+ ---
148
+
149
+ ## 💰 Licensing & Support
150
+
151
+ `intellifont-engine` is dual-licensed:
152
+ - **Software**: The engine code is licensed under **Apache-2.0**.
153
+ - **Data**: The included **Core Font Database** (~2,000 signatures) is free for use. Access to the **Extended Intelligence Database** (20,000+ signatures) requires a Pro license.
154
+
155
+ For **Enterprise-grade** requirements:
156
+ - 🚀 **20,000+ Certified Font Signatures**
157
+ - 🔒 **Air-gapped Offline Databases** (for secure environments)
158
+ - 🎧 **Premium Support & Custom Provider Integration**
159
+
160
+ Visit [intellifont.pro](https://intellifont.pro) or contact our enterprise team.
161
+
162
+ ---
163
+
164
+ ## Security
165
+
166
+ Your privacy is paramount. intelliFont's local scanner:
167
+ - Is restricted to common system font directories.
168
+ - Never transmits actual font files; only anonymous biometric signatures (metrics).
169
+ - Uses Rust's memory safety to prevent overflow exploits common in font parsing.
170
+
171
+ ---
172
+
173
+ © 2026 intelliFont Engine
package/index.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /* auto-generated by NAPI-RS */
5
+
6
+ export declare function resolveFontBasic(fontName: string): string
7
+ export interface JsSuggestion {
8
+ family: string
9
+ subfamily: string
10
+ source: string
11
+ score: number
12
+ weight: number
13
+ italic: boolean
14
+ isCriticalLicenseWarning: boolean
15
+ licenseName: string
16
+ hasLocalFile: boolean
17
+ downloadUrl?: string
18
+ isOfflineFallback: boolean
19
+ }
20
+ export interface JsDatabaseStats {
21
+ fontCount: number
22
+ compressedSizeMb: number
23
+ originalSizeMb: number
24
+ compressionRatio: number
25
+ }
26
+ export interface JsCacheStats {
27
+ memoryEntries: number
28
+ diskEntries: number
29
+ pinnedFonts: number
30
+ memoryUsageMb: number
31
+ diskUsageMb: number
32
+ }
33
+ export declare function getFontSuggestions(fontName: string, includeInternet: boolean): Promise<Array<JsSuggestion>>
34
+ export declare function normalizeFontName(fontName: string): string
35
+ export declare function pinFont(fontName: string): void
36
+ export declare function unpinFont(fontName: string): void
37
+ export declare function removeFromCache(fontNames: Array<string>): number
38
+ export declare function exportMetrics(fontName: string): string
39
+ export declare function getEngineStats(): JsDatabaseStats
40
+ export declare function getCacheStats(): JsCacheStats
41
+ export declare function cleanupCache(aggressive: boolean): number
42
+ export declare function listPinnedFonts(): Array<string>
43
+ export declare function updateDatabase(): Promise<void>
package/index.js ADDED
@@ -0,0 +1,194 @@
1
+ #!/usr/bin/env node
2
+ const {
3
+ getFontSuggestions,
4
+ normalizeFontName,
5
+ pinFont,
6
+ unpinFont,
7
+ removeFromCache,
8
+ exportMetrics,
9
+ getEngineStats,
10
+ getCacheStats,
11
+ cleanupCache,
12
+ listPinnedFonts,
13
+ updateDatabase
14
+ } = require('./intellifont-engine.node');
15
+
16
+ /**
17
+ * Creates a CSS @font-face string for a given font family and URL.
18
+ */
19
+ function createFontFace(family, url, weight = 400, italic = false) {
20
+ return `
21
+ @font-face {
22
+ font-family: '${family}';
23
+ src: url('${url}') format('woff2');
24
+ font-weight: ${weight};
25
+ font-style: ${italic ? 'italic' : 'normal'};
26
+ font-display: swap;
27
+ }
28
+ `.trim();
29
+ }
30
+
31
+ /**
32
+ * Enhanced suggestion helper that includes license advice.
33
+ */
34
+ async function getEnhancedSuggestions(fontName, includeInternet = true) {
35
+ const suggestions = await getFontSuggestions(fontName, includeInternet);
36
+
37
+ return suggestions.map(s => ({
38
+ ...s,
39
+ uiAdvice: s.isCriticalLicenseWarning
40
+ ? "⚠ Warning: Check license before commercial use."
41
+ : "✔ Safe to use.",
42
+ fontFace: s.downloadUrl ? createFontFace(s.family, s.downloadUrl, s.weight, s.italic) : null
43
+ }));
44
+ }
45
+
46
+ /**
47
+ * CLI Entry Point
48
+ */
49
+ if (require.main === module) {
50
+ const args = process.argv.slice(2);
51
+ const command = args[0];
52
+ const subCommand = args[1];
53
+ const params = args.slice(command === 'cache' || command === 'config' ? 2 : 1);
54
+
55
+ async function runCli() {
56
+ switch (command) {
57
+ case 'resolve':
58
+ case 'suggest':
59
+ const searchName = params[0] || "Arial";
60
+ const useWeb = args.includes('--internet') || args.includes('--web');
61
+ const results = await getEnhancedSuggestions(searchName, useWeb);
62
+ console.log(`\nSuggestions for "${searchName}":`);
63
+ results.forEach(r => {
64
+ const status = r.isCriticalLicenseWarning ? '[RESTRICTED]' : '[OK]';
65
+ console.log(` ${status} ${r.family} ${r.subfamily} (${r.source}) - Similarity: ${(r.score * 100).toFixed(1)}%`);
66
+ });
67
+ break;
68
+
69
+ case 'tiered':
70
+ // For CLI parity, we use the same as suggest but with different UI formatting
71
+ const tieredName = params[0] || "Arial";
72
+ const tieredWeb = args.includes('--internet');
73
+ const tieredResults = await getEnhancedSuggestions(tieredName, tieredWeb);
74
+ console.log(`\nTiered Analysis for "${tieredName}":`);
75
+ const exact = tieredResults.filter(r => r.score > 0.95);
76
+ const similar = tieredResults.filter(r => r.score <= 0.95 && r.score > 0.8);
77
+
78
+ if (exact.length) {
79
+ console.log("\n[90%+ Match Tier]");
80
+ exact.forEach(r => console.log(` - ${r.family} (Exact match)`));
81
+ }
82
+ if (similar.length) {
83
+ console.log("\n[80%+ Similar Tier]");
84
+ similar.forEach(r => console.log(` - ${r.family} (${(r.score * 100).toFixed(1)}%)`));
85
+ }
86
+ break;
87
+
88
+ case 'stats':
89
+ const eStats = getEngineStats();
90
+ const cStats = getCacheStats();
91
+ console.log(`\nENGINE STATUS`);
92
+ console.log(` Fonts indexed : ${eStats.fontCount.toLocaleString()}`);
93
+ console.log(` Binary size : ${eStats.compressedSizeMb.toFixed(2)} MB`);
94
+ console.log(` Ratio : ${eStats.compressionRatio.toFixed(1)}%`);
95
+ console.log(`\nCACHE STATUS`);
96
+ console.log(` Memory/Disk : ${cStats.memoryEntries}/${cStats.diskEntries} entries`);
97
+ console.log(` Pinned : ${cStats.pinnedFonts}`);
98
+ console.log(` Disk usage : ${cStats.diskUsageMb.toFixed(2)} MB`);
99
+ break;
100
+
101
+ case 'cache':
102
+ switch (subCommand) {
103
+ case 'stats':
104
+ const cs = getCacheStats();
105
+ console.log(`\nCACHE: ${cs.memoryEntries} mem / ${cs.diskEntries} disk (${cs.diskUsageMb.toFixed(2)} MB)`);
106
+ break;
107
+ case 'cleanup':
108
+ const agg = args.includes('--aggressive');
109
+ const cleaned = cleanupCache(agg);
110
+ console.log(`Cache cleared. Removed ${cleaned} entries.`);
111
+ break;
112
+ case 'list':
113
+ const pinned = listPinnedFonts();
114
+ console.log("\nPINNED FONTS");
115
+ pinned.length ? pinned.forEach(p => console.log(` - ${p}`)) : console.log(" (None)");
116
+ break;
117
+ case 'pin':
118
+ params.forEach(p => { pinFont(p); console.log(`Pinned: ${p}`); });
119
+ break;
120
+ case 'unpin':
121
+ params.forEach(p => { unpinFont(p); console.log(`Unpinned: ${p}`); });
122
+ break;
123
+ }
124
+ break;
125
+
126
+ case 'scan':
127
+ const sStats = getEngineStats();
128
+ console.log(`\nScan complete. ${sStats.fontCount} fonts available.`);
129
+ break;
130
+
131
+ case 'update':
132
+ process.stdout.write("Updating database... ");
133
+ try {
134
+ await updateDatabase();
135
+ console.log("Done.");
136
+ } catch (e) {
137
+ console.log("\nFailed.");
138
+ console.error(`Error: ${e.message}`);
139
+ }
140
+ break;
141
+
142
+ case 'export-metrics':
143
+ try {
144
+ console.log(exportMetrics(params[0] || "Arial"));
145
+ } catch (e) {
146
+ console.error(`Error: ${e.message}`);
147
+ }
148
+ break;
149
+
150
+ case 'setup':
151
+ console.log("\nintelliFont Setup Wizard");
152
+ console.log("1. Memory Limit: 16MB (Default)");
153
+ console.log("2. Web Fonts: Enabled");
154
+ console.log("3. License Guard: Active");
155
+ console.log("\nConfiguration optimized for your system.");
156
+ break;
157
+
158
+ case 'normalize':
159
+ console.log(normalizeFontName(params[0] || "Arial"));
160
+ break;
161
+
162
+ case 'help':
163
+ default:
164
+ console.log("\nintelliFont Engine CLI");
165
+ console.log("Usage:");
166
+ console.log(" intellifont suggest <name> [--internet] - Find matching fonts");
167
+ console.log(" intellifont resolve <name> - Fast lookup");
168
+ console.log(" intellifont stats - Engine & Cache metrics");
169
+ console.log(" intellifont scan - Refresh system font index");
170
+ console.log(" intellifont update - Sync with global CDN signatures");
171
+ console.log(" intellifont cache <stats|list|cleanup> - Manage local cache");
172
+ console.log(" intellifont cache <pin|unpin> <name> - Manage font pinning");
173
+ console.log(" intellifont export-metrics <name> - Get binary DNA of a font");
174
+ break;
175
+ }
176
+ }
177
+ runCli().catch(console.error);
178
+ }
179
+
180
+ module.exports = {
181
+ getFontSuggestions,
182
+ getEnhancedSuggestions,
183
+ normalizeFontName,
184
+ createFontFace,
185
+ pinFont,
186
+ unpinFont,
187
+ removeFromCache,
188
+ exportMetrics,
189
+ getEngineStats,
190
+ getCacheStats,
191
+ cleanupCache,
192
+ listPinnedFonts,
193
+ updateDatabase
194
+ };
Binary file
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "intellifont-engine",
3
+ "version": "0.1.0",
4
+ "description": "High-performance, Rust-powered font similarity engine for Node.js. Intelligent resolution with physical metric analysis, license guardrails, and layout preservation.",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "intellifont": "./index.js"
8
+ },
9
+ "types": "index.d.ts",
10
+ "napi": {
11
+ "name": "intellifont-engine",
12
+ "package": {
13
+ "name": "intellifont-engine"
14
+ }
15
+ },
16
+ "scripts": {
17
+ "artifacts": "napi artifacts",
18
+ "build": "napi build --release",
19
+ "build:debug": "napi build",
20
+ "test": "node test.js",
21
+ "version": "napi version"
22
+ },
23
+ "keywords": [
24
+ "font",
25
+ "typography",
26
+ "pdf",
27
+ "resolver",
28
+ "suggestion",
29
+ "matching",
30
+ "google-fonts",
31
+ "rust",
32
+ "napi"
33
+ ],
34
+ "author": "IntelliFont Team",
35
+ "license": "Apache-2.0",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/magic-emperor/Intellifont.git"
39
+ },
40
+ "engines": {
41
+ "node": ">= 14"
42
+ },
43
+ "files": [
44
+ "index.js",
45
+ "index.d.ts",
46
+ "intellifont-engine.node",
47
+ "README.md",
48
+ "LICENSE"
49
+ ],
50
+ "devDependencies": {
51
+ "@napi-rs/cli": "^2.16.0"
52
+ },
53
+ "optionalDependencies": {
54
+ "intellifont-engine-win32-x64-msvc": "0.1.0",
55
+ "intellifont-engine-darwin-x64": "0.1.0",
56
+ "intellifont-engine-linux-x64-gnu": "0.1.0"
57
+ }
58
+ }