intellifont-engine 1.2.0 → 2.0.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/README.md CHANGED
@@ -1,255 +1,355 @@
1
- # intelliFont Engine
2
-
3
- **The Ultimate Professional Font Identification Toolkit.**
4
-
5
- `intellifont-engine` is a high-performance, Rust-powered engine designed to **visually identify** unknown font files. Whether you are building a design tool or a font management system, this engine tells you exactly what font family a file belongs to by analyzing its glyph shapes.
6
-
7
- ---
8
-
9
- ## Why intelliFont?
10
- **intelliFont** uses **Visual DNA Analysis**—measuring the physical curves, stroke width, and ink density of the characters—to fingerprint and identify the font family with high precision.
11
-
12
- Traditional tools rely on reading metadata (names), which can be missing, scrambled, or incorrect (e.g., "subset.ttf").
13
-
14
-
15
-
16
- ### Key Capabilities:
17
- - **Visual Recognition**: Identifies fonts based on *geometry*, not file names.
18
- - **AI Similarity Suggestion**: **[NEW]** Find visually similar alternatives matching the "AI DNA" of a font.
19
- - **Microservice Ready**: **[NEW]** Run as a high-performance HTTP server for any-language integration.
20
- - **Raw Buffer Support**: Works directly with memory buffers from web uploads.
21
- - **Sub-millisecond Speed**: Visual analysis takes <1ms per file.
22
- - **Privacy First**: Analysis happens entirely offline/on-server.
23
-
24
- ---
25
-
26
- ## Architecture Overview
27
-
28
- The engine is built on a "Service-Core" architecture:
29
- 1. **The Rust Core**: Performs the heavy-duty mathematical analysis of glyph curves.
30
- 2. **The NAPI-RS Bridge**: Exposes this power to Node.js as a simple native function.
31
- 3. **The Signature Database**: A highly-compressed binary index of known font shapes (Google Fonts, System Fonts).
32
-
33
- ---
34
-
35
- ## Installation
36
-
37
- ### As a Library (Recommended)
38
- Add it to your React, Vue, or Node.js project:
39
- ```bash
40
- npm install intellifont-engine
41
- ```
42
-
43
- ### As a Global CLI Tool
44
- Powerful font management directly from your terminal:
45
- ```bash
46
- npm install -g intellifont-engine
47
- ```
48
- ---
49
-
50
- ## JavaScript API
51
-
52
- `intellifont-engine` provides a simple, Promise-based API for Node.js environments.
53
-
54
- ### `identify_visual_font(path, chars, limit)`
55
- **[NEW]** Identify a font file visually using its glyph shape signatures.
56
-
57
- ```javascript
58
- const { identify_visual_font } = require('intellifont-engine');
59
-
60
- // Identify an unknown file
61
- const results = identify_visual_font("./unknown_font.ttf", "RQWM", 5);
62
-
63
- console.log(results[0]);
64
- // {
65
- // family: "Arial",
66
- // subfamily: "Regular",
67
- // confidence: 0.99,
68
- // source: "Database"
69
- // }
70
- ```
71
-
72
- ### `identify_visual_font_buffer(buffer, chars, limit)`
73
- **[NEW]** Identify a font from valid font memory buffer (e.g. from file upload). No disk save required.
74
-
75
- ```javascript
76
- const fs = require('fs');
77
- const { identify_visual_font_buffer } = require('intellifont-engine');
78
-
79
- // Simulate a file upload (Buffer)
80
- const buffer = fs.readFileSync("./uploaded_font.ttf");
81
-
82
- const matches = identify_visual_font_buffer(buffer, "RQWM", 5);
83
- console.log(matches[0]);
84
- // { family: "Roboto", confidence: 1.0, ... }
85
- ```
86
-
87
- ### `aiSuggestSimilar(path, limit)`
88
- **[NEW]** Find visually similar fonts using AI pattern matching.
89
-
90
- ```javascript
91
- const { aiSuggestSimilar } = require('intellifont-engine');
92
-
93
- const suggestions = aiSuggestSimilar("./my_font.ttf", 5);
94
- console.log(suggestions[0]);
95
- // {
96
- // family: "Consolas",
97
- // confidence: 0.92,
98
- // match_quality: "high"
99
- // }
100
- ```
101
-
102
- ### `aiSuggestSimilarBuffer(buffer, limit)`
103
- **[NEW]** Find similar fonts directly from memory buffer.
104
- ```
105
-
106
- ### `exportMetrics(fontName)`
107
- Returns the physical "DNA" of a font. Essential for layout-stable PDF generators.
108
-
109
- ```javascript
110
- const { exportMetrics } = require('intellifont-engine');
111
- const metrics = exportMetrics("Inter");
112
- ```
113
-
114
- ---
115
-
116
- ## 📦 Integration: Real-World Web App
117
-
118
- Here is a complete example of how to integrate `intellifont-engine` into an **Express.js** backend to handle file uploads.
119
-
120
- ### 1. Install Dependencies
121
- ```bash
122
- npm install express multer intellifont-engine
123
- ```
124
-
125
- ### 2. Create the Backend Service (`server.js`)
126
- This service receives a file upload (font) and returns the identification result.
127
-
128
- ```javascript
129
- const express = require('express');
130
- const multer = require('multer');
131
- const { identify_visual_font_buffer } = require('intellifont-engine');
132
-
133
- const app = express();
134
- // Use memory storage so we can access the buffer directly
135
- const upload = multer({ storage: multer.memoryStorage() });
136
-
137
- // Endpoint: POST /api/identify
138
- app.post('/api/identify', upload.single('fontFile'), (req, res) => {
139
- try {
140
- if (!req.file) {
141
- return res.status(400).json({ error: "No font file uploaded" });
142
- }
143
-
144
- // 1. Get the Raw Buffer
145
- const fontBuffer = req.file.buffer;
146
-
147
- // 2. Identify the Font (Pass specific characters for better accuracy)
148
- const results = identify_visual_font_buffer(fontBuffer, "RQWM", 5);
149
-
150
- // 3. Return JSON to Frontend
151
- res.json({ success: true, matches: results });
152
-
153
- } catch (error) {
154
- res.status(500).json({ error: error.message });
155
- }
156
- });
157
-
158
- app.listen(3000, () => console.log('Server running on port 3000 🚀'));
159
- ```
160
-
161
- ### 3. Usage from Frontend
162
- ```javascript
163
- const formData = new FormData();
164
- formData.append('fontFile', fileInput.files[0]);
165
-
166
- const response = await fetch('/api/identify', { method: 'POST', body: formData });
167
- const data = await response.json();
168
- console.log("Identified Font:", data.matches[0].family);
169
- // Output: "Arial"
170
- ```
171
-
172
- ---
173
-
174
- ## FAQ: Inputs & Performance
175
-
176
- **Q: Why do I need to pass the `.ttf/.otf` file? Can't I just pass text?**
177
- **A:** "Text" (like "Hello") is just a code (e.g., `U+0048`). It has no shape. The `.ttf` file contains the **mathematical curves** (geometry) that determine if it looks like Arial or Times New Roman. We need those curves to calculate the visual signature.
178
-
179
- **Q: Isn't uploading a font file slow/heavy?**
180
- **A:** No. Font files are vector graphics and are surprisingly small (~50KB - 200KB). Uploading a font buffer to your backend takes milliseconds.
181
-
182
- ---
183
-
184
- ## 🛠️ CLI Usage (The 'intellifont' command)
185
-
186
- Once installed globally, `intellifont` provides tools for visual identification and database management.
187
-
188
- | Command | Description |
189
- | :--- | :--- |
190
- | `intellifont identify "file.ttf"` | **Identify a font file visually** using its glyph signatures. |
191
- | `intellifont ai-suggest "file.ttf"` | **[AI]** Find visually similar alternatives for a font file. |
192
- | `intellifont serve --port 3000` | **[NEW]** Run as an HTTP microservice for universal integration. |
193
- | `intellifont build-web-db` | Download and index popular **Google Fonts/Web Fonts** automatically. |
194
- | `intellifont build-glyph-db <dir>` | Index a local directory of fonts into a compressed signature database. |
195
- | `intellifont stats` | Display engine metrics and database compression stats. |
196
-
197
- ### JSON Output for Automation
198
- Add `--json` flag to get machine-readable output:
199
- ```bash
200
- intellifont identify "file.ttf" --json
201
- # Returns: [{"family": "Arial", "confidence": 0.99, ...}]
202
- ```
203
-
204
- ---
205
-
206
- ## 🐍 Python & Universal Integration
207
-
208
- Since `intellifont` is a standalone CLI tool, you can use it from **any language** (Python, Go, PHP, C#, Ruby) by calling the CLI and parsing JSON.
209
-
210
- **Python Example:**
211
- ```python
212
- import subprocess
213
- import json
214
-
215
- def identify_font(file_path):
216
- result = subprocess.run(
217
- ["intellifont", "identify", file_path, "--json"],
218
- capture_output=True, text=True
219
- )
220
- matches = json.loads(result.stdout)
221
- return matches[0] if matches else None
222
-
223
- # Usage
224
- font = identify_font("./mystery.ttf")
225
- print(f"Identified: {font['family']} ({font['confidence']*100:.0f}% confidence)")
226
- ```
227
-
228
-
229
- ---
230
-
231
- ## 💰 Licensing & Support
232
-
233
- `intellifont-engine` is dual-licensed:
234
- - **Software**: The engine code is licensed under **Apache-2.0**.
235
- - **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.
236
-
237
- For **Enterprise-grade** requirements:
238
- - 🚀 **20,000+ Certified Font Signatures**
239
- - 🔒 **Air-gapped Offline Databases** (for secure environments)
240
- - 🎧 **Premium Support & Custom Provider Integration**
241
-
242
- Visit [intellifont.pro](https://intellifont.pro) or contact our enterprise team.
243
-
244
- ---
245
-
246
- ## Security
247
-
248
- Your privacy is paramount. intelliFont's local scanner:
249
- - Is restricted to common system font directories.
250
- - Never transmits actual font files; only anonymous biometric signatures (metrics).
251
- - Uses Rust's memory safety to prevent overflow exploits common in font parsing.
252
-
253
- ---
254
-
255
- © 2026 intelliFont Engine
1
+ # Intellifont — AI-Powered Font Recognition Engine
2
+
3
+ **Identify any font in seconds.** Intellifont uses AI-driven visual matching to recognize fonts from images, documents, websites, and web pages. Completely offline, private, and runs in your browser or Node.js. No internet required, no data sent to servers.
4
+
5
+ Works on screenshots, PDFs, Word documents, PowerPoint presentations, and images. Returns the top matching fonts with confidence scores.
6
+
7
+ ---
8
+
9
+ ## Where to Get Intellifont
10
+
11
+ **Choose your platform:**
12
+
13
+ | Platform | Installation | Use Case |
14
+ |---|---|---|
15
+ | **Chrome Extension** | [Download v2.0.0](https://github.com/magic-emperor/Intellifont/releases/download/v2.0.0/intellifont-chrome-2.0.0.zip) \| [Load unpacked](#browser-extension-setup) | Right-click on any image in Chrome |
16
+ | **Firefox Extension** | [Download v2.0.0](https://github.com/magic-emperor/Intellifont/releases/download/v2.0.0/intellifont-firefox-2.0.0.zip) \| [Load unpacked](#browser-extension-setup) | Right-click on any image in Firefox |
17
+ | **NPM Package** | `npm install intellifont-engine` | Identify fonts in Node.js apps |
18
+ | **WASM** | `npm install intellifont-wasm` | Identify fonts in browsers / serverless |
19
+ | **Server API** | `git clone && npm start` | REST API on localhost:3001 |
20
+
21
+ ---
22
+
23
+ ## What It Can Do
24
+
25
+ | Input | Method | Accuracy |
26
+ |---|---|---|
27
+ | **Font file** (TTF/OTF/WOFF) | Direct file analysis | ~95% |
28
+ | **Website font** | URL inspection | ~95% |
29
+ | **PDF / Document** | Embedded font extraction | ~95% |
30
+ | **Text in image** | Visual analysis | 92% top-1 \* |
31
+
32
+ \* *Accuracy varies by image quality. We actively improve this with every release.*
33
+
34
+ ---
35
+
36
+ ## Quick Start
37
+
38
+ ### For Users Browser Extension
39
+ **Chrome & Firefox** — load unpacked (coming to stores):
40
+
41
+ 1. Clone: `git clone https://github.com/magic-emperor/Intellifont.git`
42
+ 2. **Chrome**: `chrome://extensions` Developer Mode Load unpacked select `extension/`
43
+ 3. **Firefox**: `about:debugging` Load Temporary Add-on select `extension-firefox/manifest.json`
44
+ 4. Right-click any image **"Identify font in image"**
45
+
46
+ ### For Developers — NPM Package
47
+
48
+ ```bash
49
+ npm install intellifont-engine
50
+ ```
51
+
52
+ ```javascript
53
+ const intellifont = require('intellifont-engine');
54
+
55
+ // Identify font from a file
56
+ const matches = intellifont.identifyVisualFont('./sample.ttf', 'Hello');
57
+ console.log(matches);
58
+ // Output:
59
+ // [
60
+ // { family: 'Roboto', confidence: 0.98 },
61
+ // { family: 'Open Sans', confidence: 0.94 },
62
+ // ...
63
+ // ]
64
+ ```
65
+
66
+ ### WASM (Browser / Serverless)
67
+
68
+ ```bash
69
+ npm install intellifont-wasm
70
+ ```
71
+
72
+ ```javascript
73
+ import init from 'intellifont-wasm';
74
+
75
+ const engine = await init();
76
+ const results = engine.identifyFont(glyphMetrics, 8);
77
+ ```
78
+
79
+ ---
80
+
81
+ ## Browser Extension Setup
82
+
83
+ ### Installing the Chrome Extension
84
+
85
+ 1. **Download** the extension: [intellifont-chrome-2.0.0.zip](https://github.com/magic-emperor/Intellifont/releases/download/v2.0.0/intellifont-chrome-2.0.0.zip)
86
+ 2. **Extract** the ZIP file to a folder (e.g., `Downloads/intellifont-chrome`)
87
+ 3. Open **Chrome** and go to `chrome://extensions`
88
+ 4. Enable **Developer Mode** (toggle in top-right corner)
89
+ 5. Click **Load unpacked**
90
+ 6. Select the extracted `intellifont-chrome` folder
91
+ 7. Extension appears in your toolbar
92
+ 8. **Use it**: Right-click any image "Identify font in image"
93
+
94
+ ### Installing the Firefox Extension
95
+
96
+ 1. **Download** the extension: [intellifont-firefox-2.0.0.zip](https://github.com/magic-emperor/Intellifont/releases/download/v2.0.0/intellifont-firefox-2.0.0.zip)
97
+ 2. **Extract** the ZIP file to a folder (e.g., `Downloads/intellifont-firefox`)
98
+ 3. Open **Firefox** and go to `about:debugging`
99
+ 4. Click **This Firefox** (left sidebar)
100
+ 5. Click **Load Temporary Add-on**
101
+ 6. Select any file from the extracted `intellifont-firefox` folder (e.g., `manifest.json`)
102
+ 7. Extension appears in your toolbar
103
+ 8. **Use it**: Right-click any image "Identify font"
104
+
105
+ ### How to Use the Extension
106
+
107
+ 1. **Right-click on any image** on any webpage
108
+ 2. Select **"Identify font in image"** (or "Identify font in image region..." for partial image)
109
+ 3. Wait for analysis (usually 1-2 seconds)
110
+ 4. A popup appears with:
111
+ - **Top matching fonts** (confidence % shown)
112
+ - **Font family, weight, style** for each match
113
+ - Copy button for easy access
114
+
115
+ ### Known Extension Limitations
116
+
117
+ - Only works on images you can right-click (no cross-origin restrictions thanks to local processing)
118
+ - Image must contain **readable text** (8px+ font size)
119
+ - Accuracy varies by image quality (see [Accuracy](#accuracy-by-condition))
120
+ - **Rotation**: Deskew images first if heavily tilted
121
+
122
+ ---
123
+
124
+ ## Delivery Channels
125
+
126
+ ### **Browser Extension** (Chrome & Firefox)
127
+ Right-click on images identify fonts. Offline first, 100% private.
128
+
129
+ **Download:**
130
+ - **Chrome**: [Download v2.0.0 ZIP](https://github.com/magic-emperor/Intellifont/releases/download/v2.0.0/intellifont-chrome-2.0.0.zip)
131
+ - **Firefox**: [Download v2.0.0 ZIP](https://github.com/magic-emperor/Intellifont/releases/download/v2.0.0/intellifont-firefox-2.0.0.zip)
132
+
133
+ **Installation** (see [Browser Extension Setup](#browser-extension-setup) below):
134
+ 1. Extract the ZIP file
135
+ 2. Load unpacked in Chrome/Firefox Developer Mode
136
+ 3. Right-click any image "Identify font"
137
+
138
+ **Coming soon**: Chrome Web Store & Firefox Add-ons (submit after testing)
139
+
140
+ ### **NPM Package** (`intellifont-engine`)
141
+ ```bash
142
+ npm install intellifont-engine
143
+ ```
144
+
145
+ 20+ functions for font identification, analysis, and caching:
146
+ - `identifyVisualFont()` — Identify from TTF/OTF file
147
+ - `identifyVisualFontBuffer()` Identify from buffer
148
+ - `aiSuggestSimilar()` Find similar fonts (ML)
149
+ - `getFontSuggestions()` — Name-based search
150
+ - `analyzeImage()` Full image processing
151
+
152
+ **TypeScript types included.**
153
+
154
+ ### **WASM Module**
155
+ Pure JavaScript, zero native dependencies. Perfect for browsers, serverless, Deno.
156
+
157
+ ```bash
158
+ npm install intellifont-wasm
159
+ ```
160
+
161
+ ### **API Server**
162
+ ```bash
163
+ cd server && npm start
164
+ # POST /api/identify — upload image
165
+ # GET /api/identify-url?url=... — scan web page
166
+ # POST /api/identify-document analyze PDF/DOCX
167
+ # GET /api/similar?font=Roboto find alternatives
168
+ ```
169
+
170
+ ---
171
+
172
+ ## Accuracy by Condition
173
+
174
+ | Scenario | Accuracy |
175
+ |---|---|
176
+ | Font file (TTF/OTF) | ~95% |
177
+ | Web font (downloaded) | ~95% |
178
+ | PDF/Document embedded font | ~95% |
179
+ | Image: clean text | 92% top-1 |
180
+ | Image: mixed conditions | 57% top-5 |
181
+
182
+ *Image accuracy depends on text quality, size, contrast, and clarity. Rotation is a known limitation (improving).*
183
+
184
+ ---
185
+
186
+ ## How It Works
187
+
188
+ ```
189
+ Input (Image / Document / Font / URL)
190
+
191
+ [Preprocessing] Binarize, deskew, extract text regions
192
+
193
+ [Glyph Analysis] Compute pixel metrics (density, symmetry, strokes, serif)
194
+
195
+ [Visual Matching] Compare 64—64 thumbnails against 2,042 fonts
196
+
197
+ [ML Enhancement] Optional: CosFace embeddings for better ranking
198
+
199
+ [Return Top 8] Sorted by confidence score
200
+
201
+ Output: Font family, weight, confidence %
202
+ ```
203
+
204
+ **Key points:**
205
+ - **Visual matching**: Character-agnostic (label-independent)
206
+ - **ML-powered**: Trained on 2,042 real fonts
207
+ - **Offline**: All data bundled, no network calls
208
+ - **Private**: Images never leave your device
209
+
210
+ ---
211
+
212
+ ## Full API Reference
213
+
214
+ ### Node.js Exports
215
+
216
+ **Core Identification**
217
+ ```javascript
218
+ identifyVisualFont(fontPath: string, characters: string, limit?: number): VisualMatch[]
219
+ identifyVisualFontBuffer(buffer: Buffer, characters: string, limit?: number): VisualMatch[]
220
+ aiSuggestSimilar(fontPath: string, limit?: number): AiSuggestion[]
221
+ getFontSuggestions(fontName: string, includeInternet?: boolean): Promise<Suggestion[]>
222
+ ```
223
+
224
+ **Image Processing**
225
+ ```javascript
226
+ analyzeImage(imageSource: string | Buffer): Promise<ImageAnalysisResult>
227
+ extractGlyphSignature(fontPath: string, character: string): GlyphSignature
228
+ compareGlyphSignatures(fontPathA: string, fontPathB: string, character: string): number
229
+ ```
230
+
231
+ **Utilities**
232
+ ```javascript
233
+ normalizeFontName(fontName: string): string
234
+ ```
235
+
236
+ **Cache Management**
237
+ ```javascript
238
+ pinFont(fontName: string): void
239
+ unpinFont(fontName: string): void
240
+ listPinnedFonts(): string[]
241
+ cleanupCache(aggressive?: boolean): number
242
+ getCacheStats(): CacheStats
243
+ getEngineStats(): EngineStats
244
+ ```
245
+
246
+ Full TypeScript types in `index.d.ts`.
247
+
248
+ ---
249
+
250
+ ## Browser Support
251
+
252
+ | Browser | Version | Status |
253
+ |---|---|---|
254
+ | Chrome | 80+ | Full |
255
+ | Firefox | 109+ | Full |
256
+ | Edge | 80+ | Full |
257
+ | Safari | 14+ | Planned |
258
+
259
+ WASM module works on 99%+ of users' devices.
260
+
261
+ ---
262
+
263
+ ## Database
264
+
265
+ **2,042 fonts** covering:
266
+ - Google Fonts (complete)
267
+ - System fonts (Windows, macOS, Linux)
268
+ - Popular design fonts
269
+ - Open-source typefaces
270
+
271
+ **Included in extension and NPM:**
272
+ - Glyph signatures: 2 MB
273
+ - Pixel signatures: 1.7 MB
274
+ - Visual thumbnails: 15 MB
275
+
276
+ ---
277
+
278
+ ## Performance
279
+
280
+ | Task | Time | Notes |
281
+ |---|---|---|
282
+ | Identify 1 glyph | 5-50ms | CPU-bound |
283
+ | Full image analysis | 100-500ms | Includes preprocessing |
284
+ | ML similarity ranking | 10-100ms | Optional |
285
+
286
+ No initialization delay. Ready immediately.
287
+
288
+ ---
289
+
290
+ ## Privacy & Security
291
+
292
+ **100% Offline** — All processing on your device
293
+ **No Tracking** — Zero telemetry
294
+ **No Uploads** — Images never leave your computer
295
+ **Open Source** — Inspect the code
296
+ **Apache 2.0** — Free for commercial use
297
+
298
+ ---
299
+
300
+ ## Installation
301
+
302
+ ### From NPM
303
+ ```bash
304
+ npm install intellifont-engine
305
+ ```
306
+
307
+ ### From Source (Development)
308
+ ```bash
309
+ git clone https://github.com/magic-emperor/Intellifont.git
310
+ cd Intellifont
311
+
312
+ # Build Rust bindings
313
+ cd Rust/font-resolver
314
+ cargo build --release
315
+ cd bindings/node
316
+ npm install
317
+ npm run build
318
+ ```
319
+
320
+ ---
321
+
322
+ ## Known Limitations
323
+
324
+ - **Rotation**: Tilted text is difficult (deskew first)
325
+ - **Rare fonts**: Only covers 2,042 fonts (expand DB for your use case)
326
+ - **Stylized text**: Heavily styled/outlined text has lower accuracy
327
+ - **Small text**: < 8px is hard to analyze
328
+
329
+ ---
330
+
331
+ ## Contributing
332
+
333
+ Found a bug? Want to help? Open an issue or PR on [GitHub](https://github.com/magic-emperor/Intellifont).
334
+
335
+ ---
336
+
337
+ ## License
338
+
339
+ **Apache License 2.0.** See [LICENSE](LICENSE).
340
+
341
+ ---
342
+
343
+ ## Credits
344
+
345
+ - **Rust** engine with NAPI-RS bindings
346
+ - **WebAssembly** for browser support
347
+ - **CosFace** ML embeddings
348
+ - **2,042 test fonts** for training
349
+
350
+ ---
351
+
352
+ ** 2026 Intellifont Engine. Built by the Intellifont Team.**
353
+
354
+ Questions? Email [faizan77603@gmail.com](mailto:faizan77603@gmail.com) or open an issue on [GitHub](https://github.com/magic-emperor/Intellifont).
355
+