three-text 0.2.5 → 0.2.7

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.
@@ -1,6 +1,13 @@
1
1
  import { ExtractedMetrics, FontMetrics, VerticalMetrics } from '../types';
2
2
  export declare class FontMetadataExtractor {
3
3
  static extractMetadata(fontBuffer: ArrayBuffer): ExtractedMetrics;
4
+ static extractFeatureTags(fontBuffer: ArrayBuffer): {
5
+ tags: string[];
6
+ names: {
7
+ [tag: string]: string;
8
+ };
9
+ } | undefined;
10
+ private static extractFeatureDataFromTable;
4
11
  private static extractAxisNames;
5
12
  private static getNameFromNameTable;
6
13
  static getVerticalMetrics(metrics: ExtractedMetrics): VerticalMetrics;
@@ -3,3 +3,13 @@ export declare const FONT_SIGNATURE_OPEN_TYPE_CFF = 1330926671;
3
3
  export declare const FONT_SIGNATURE_TRUE_TYPE_COLLECTION = 1953784678;
4
4
  export declare const FONT_SIGNATURE_WOFF = 2001684038;
5
5
  export declare const FONT_SIGNATURE_WOFF2 = 2001684018;
6
+ export declare const TABLE_TAG_HEAD = 1751474532;
7
+ export declare const TABLE_TAG_HHEA = 1751672161;
8
+ export declare const TABLE_TAG_OS2 = 1330851634;
9
+ export declare const TABLE_TAG_FVAR = 1719034226;
10
+ export declare const TABLE_TAG_STAT = 1398030676;
11
+ export declare const TABLE_TAG_NAME = 1851878757;
12
+ export declare const TABLE_TAG_CFF = 1128678944;
13
+ export declare const TABLE_TAG_CFF2 = 1128678962;
14
+ export declare const TABLE_TAG_GSUB = 1196643650;
15
+ export declare const TABLE_TAG_GPOS = 1196445523;
@@ -0,0 +1,3 @@
1
+ export declare function convertFontFeaturesToString(features?: {
2
+ [tag: string]: boolean | number;
3
+ }): string | undefined;
@@ -65,10 +65,17 @@ export interface LoadedFont {
65
65
  fontVariations?: {
66
66
  [key: string]: number;
67
67
  };
68
+ fontFeatures?: {
69
+ [tag: string]: boolean | number;
70
+ };
68
71
  isVariable?: boolean;
69
72
  variationAxes?: {
70
73
  [key: string]: VariationAxis;
71
74
  };
75
+ availableFeatures?: string[];
76
+ featureNames?: {
77
+ [tag: string]: string;
78
+ };
72
79
  _buffer?: ArrayBuffer;
73
80
  }
74
81
  export interface HarfBuzzModule {
@@ -87,7 +94,7 @@ export interface HarfBuzzAPI {
87
94
  createFace: (blob: HarfBuzzBlob, index: number) => HarfBuzzFace;
88
95
  createFont: (face: HarfBuzzFace) => HarfBuzzFont;
89
96
  createBuffer: () => HarfBuzzBuffer;
90
- shape: (font: HarfBuzzFont, buffer: HarfBuzzBuffer) => void;
97
+ shape: (font: HarfBuzzFont, buffer: HarfBuzzBuffer, features?: string) => void;
91
98
  }
92
99
  export interface HarfBuzzBlob {
93
100
  destroy: () => void;
@@ -270,6 +277,9 @@ export interface TextOptions {
270
277
  fontVariations?: {
271
278
  [key: string]: number;
272
279
  };
280
+ fontFeatures?: {
281
+ [tag: string]: boolean | number;
282
+ };
273
283
  maxTextLength?: number;
274
284
  removeOverlaps?: boolean;
275
285
  curveFidelity?: CurveFidelityConfig;
@@ -0,0 +1,38 @@
1
+ export interface LRUCacheOptions<K, V> {
2
+ maxEntries?: number;
3
+ maxMemoryBytes?: number;
4
+ calculateSize?: (value: V) => number;
5
+ onEvict?: (key: K, value: V) => void;
6
+ }
7
+ export interface LRUCacheStats {
8
+ hits: number;
9
+ misses: number;
10
+ evictions: number;
11
+ size: number;
12
+ memoryUsage: number;
13
+ }
14
+ export declare class LRUCache<K, V> {
15
+ private cache;
16
+ private head;
17
+ private tail;
18
+ private stats;
19
+ private options;
20
+ constructor(options?: LRUCacheOptions<K, V>);
21
+ get(key: K): V | undefined;
22
+ has(key: K): boolean;
23
+ set(key: K, value: V): void;
24
+ delete(key: K): boolean;
25
+ clear(): void;
26
+ getStats(): LRUCacheStats & {
27
+ hitRate: number;
28
+ memoryUsageMB: number;
29
+ };
30
+ keys(): K[];
31
+ get size(): number;
32
+ private evictIfNeeded;
33
+ private evictTail;
34
+ private addToHead;
35
+ private removeNode;
36
+ private removeTail;
37
+ private moveToHead;
38
+ }
@@ -1,8 +1,8 @@
1
1
  export declare const isLogEnabled: boolean;
2
- declare class DebugLogger {
2
+ declare class Logger {
3
3
  warn(message: string, ...args: any[]): void;
4
4
  error(message: string, ...args: any[]): void;
5
5
  log(message: string, ...args: any[]): void;
6
6
  }
7
- export declare const debugLogger: DebugLogger;
7
+ export declare const logger: Logger;
8
8
  export {};
@@ -13,6 +13,7 @@ declare class PerformanceLogger {
13
13
  printSummary(): void;
14
14
  printBaseline(): void;
15
15
  clear(): void;
16
+ reset(): void;
16
17
  time<T>(name: string, fn: () => T, metadata?: Record<string, any>): T;
17
18
  timeAsync<T>(name: string, fn: () => Promise<T>, metadata?: Record<string, any>): Promise<T>;
18
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-text",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "3D font rendering and text layout engine for the web",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -50,6 +50,7 @@
50
50
  "prepublishOnly": "npm run clean && npm run test:build && npm run build",
51
51
  "test": "vitest run",
52
52
  "test:build": "node scripts/verifyBuild.mjs",
53
+ "benchmark": "THREE_TEXT_LOG=true vitest run test/pipelinePerf.test.ts",
53
54
  "format": "prettier --write \"**/*.{js,ts,json,md}\"",
54
55
  "format:check": "prettier --check \"**/*.{js,ts,json,md}\""
55
56
  },