three-text 0.4.0 → 0.4.2

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.
@@ -79,7 +79,6 @@ interface LineBreakContext {
79
79
  export declare class LineBreak {
80
80
  private static badness;
81
81
  private static fitnessClass;
82
- private static computeCumulativeWidths;
83
82
  static findHyphenationPoints(word: string, language?: string, availablePatterns?: HyphenationPatternsMap, lefthyphenmin?: number, righthyphenmin?: number): number[];
84
83
  static itemizeText(text: string, measureText: (text: string) => number, measureTextWidths: ((text: string) => number[]) | undefined, hyphenate?: boolean, language?: string, availablePatterns?: HyphenationPatternsMap, lefthyphenmin?: number, righthyphenmin?: number, context?: LineBreakContext, lineWidth?: number): Item[];
85
84
  static isCJK(char: string): boolean;
@@ -0,0 +1,97 @@
1
+ import type { TextAlign, TextDirection, LineInfo, HyphenationPatternsMap } from '../types';
2
+ export declare enum ItemType {
3
+ BOX = 0,
4
+ GLUE = 1,
5
+ PENALTY = 2,
6
+ DISCRETIONARY = 3
7
+ }
8
+ export declare enum FitnessClass {
9
+ VERY_LOOSE = 0,
10
+ LOOSE = 1,
11
+ DECENT = 2,
12
+ TIGHT = 3
13
+ }
14
+ interface Item {
15
+ type: ItemType;
16
+ width: number;
17
+ text?: string;
18
+ originIndex?: number;
19
+ }
20
+ export interface Box extends Item {
21
+ type: ItemType.BOX;
22
+ }
23
+ export interface Glue extends Item {
24
+ type: ItemType.GLUE;
25
+ stretch: number;
26
+ shrink: number;
27
+ }
28
+ export interface Penalty extends Item {
29
+ type: ItemType.PENALTY;
30
+ penalty: number;
31
+ flagged?: boolean;
32
+ }
33
+ export interface Discretionary extends Item {
34
+ type: ItemType.DISCRETIONARY;
35
+ preBreak: string;
36
+ postBreak: string;
37
+ noBreak: string;
38
+ preBreakWidth: number;
39
+ penalty: number;
40
+ flagged?: boolean;
41
+ }
42
+ export interface LineBreakOptions {
43
+ text: string;
44
+ width?: number;
45
+ align?: TextAlign;
46
+ direction?: TextDirection;
47
+ hyphenate?: boolean;
48
+ language?: string;
49
+ measureText: (text: string) => number;
50
+ measureTextWidths?: (text: string) => number[];
51
+ respectExistingBreaks?: boolean;
52
+ hyphenationPatterns?: HyphenationPatternsMap;
53
+ unitsPerEm?: number;
54
+ letterSpacing?: number;
55
+ tolerance?: number;
56
+ pretolerance?: number;
57
+ emergencyStretch?: number;
58
+ autoEmergencyStretch?: number;
59
+ lefthyphenmin?: number;
60
+ righthyphenmin?: number;
61
+ linepenalty?: number;
62
+ adjdemerits?: number;
63
+ hyphenpenalty?: number;
64
+ exhyphenpenalty?: number;
65
+ doublehyphendemerits?: number;
66
+ finalhyphendemerits?: number;
67
+ }
68
+ interface LineBreakContext {
69
+ linePenalty: number;
70
+ adjDemerits: number;
71
+ doubleHyphenDemerits: number;
72
+ finalHyphenDemerits: number;
73
+ hyphenPenalty: number;
74
+ exHyphenPenalty: number;
75
+ currentAlign: TextAlign;
76
+ unitsPerEm?: number;
77
+ letterSpacingFU?: number;
78
+ }
79
+ export declare class LineBreakDelta {
80
+ private static badness;
81
+ private static fitnessClass;
82
+ static findHyphenationPoints(word: string, language?: string, availablePatterns?: HyphenationPatternsMap, lefthyphenmin?: number, righthyphenmin?: number): number[];
83
+ static itemizeText(text: string, measureText: (text: string) => number, measureTextWidths: ((text: string) => number[]) | undefined, hyphenate?: boolean, language?: string, availablePatterns?: HyphenationPatternsMap, lefthyphenmin?: number, righthyphenmin?: number, context?: LineBreakContext, lineWidth?: number): Item[];
84
+ static isCJK(char: string): boolean;
85
+ static isCJClosingPunctuation(char: string): boolean;
86
+ static isCJOpeningPunctuation(char: string): boolean;
87
+ static isCJPunctuation(char: string): boolean;
88
+ private static itemizeCJKText;
89
+ private static itemizeParagraph;
90
+ private static itemizeWordBased;
91
+ private static lineBreak;
92
+ private static insertAfterNode;
93
+ private static removeNode;
94
+ static breakText(options: LineBreakOptions): LineInfo[];
95
+ private static postLineBreak;
96
+ }
97
+ export {};
@@ -101,7 +101,9 @@ function createWebGPUBuffers(device, textGeometry) {
101
101
  buffers.glyphCenter = glyphCenterBuffer;
102
102
  layout.glyphCenter = {
103
103
  arrayStride: 12,
104
- attributes: [{ shaderLocation: nextShaderLocation++, offset: 0, format: 'float32x3' }]
104
+ attributes: [
105
+ { shaderLocation: nextShaderLocation++, offset: 0, format: 'float32x3' }
106
+ ]
105
107
  };
106
108
  glyphIndexBuffer = device.createBuffer({
107
109
  size: glyphAttributes.glyphIndex.byteLength,
@@ -113,7 +115,9 @@ function createWebGPUBuffers(device, textGeometry) {
113
115
  buffers.glyphIndex = glyphIndexBuffer;
114
116
  layout.glyphIndex = {
115
117
  arrayStride: 4,
116
- attributes: [{ shaderLocation: nextShaderLocation++, offset: 0, format: 'float32' }]
118
+ attributes: [
119
+ { shaderLocation: nextShaderLocation++, offset: 0, format: 'float32' }
120
+ ]
117
121
  };
118
122
  glyphLineIndexBuffer = device.createBuffer({
119
123
  size: glyphAttributes.glyphLineIndex.byteLength,
@@ -125,7 +129,9 @@ function createWebGPUBuffers(device, textGeometry) {
125
129
  buffers.glyphLineIndex = glyphLineIndexBuffer;
126
130
  layout.glyphLineIndex = {
127
131
  arrayStride: 4,
128
- attributes: [{ shaderLocation: nextShaderLocation++, offset: 0, format: 'float32' }]
132
+ attributes: [
133
+ { shaderLocation: nextShaderLocation++, offset: 0, format: 'float32' }
134
+ ]
129
135
  };
130
136
  glyphProgressBuffer = device.createBuffer({
131
137
  size: glyphAttributes.glyphProgress.byteLength,
@@ -137,7 +143,9 @@ function createWebGPUBuffers(device, textGeometry) {
137
143
  buffers.glyphProgress = glyphProgressBuffer;
138
144
  layout.glyphProgress = {
139
145
  arrayStride: 4,
140
- attributes: [{ shaderLocation: nextShaderLocation++, offset: 0, format: 'float32' }]
146
+ attributes: [
147
+ { shaderLocation: nextShaderLocation++, offset: 0, format: 'float32' }
148
+ ]
141
149
  };
142
150
  glyphBaselineYBuffer = device.createBuffer({
143
151
  size: glyphAttributes.glyphBaselineY.byteLength,
@@ -149,7 +157,9 @@ function createWebGPUBuffers(device, textGeometry) {
149
157
  buffers.glyphBaselineY = glyphBaselineYBuffer;
150
158
  layout.glyphBaselineY = {
151
159
  arrayStride: 4,
152
- attributes: [{ shaderLocation: nextShaderLocation++, offset: 0, format: 'float32' }]
160
+ attributes: [
161
+ { shaderLocation: nextShaderLocation++, offset: 0, format: 'float32' }
162
+ ]
153
163
  };
154
164
  }
155
165
  return {
@@ -99,7 +99,9 @@ function createWebGPUBuffers(device, textGeometry) {
99
99
  buffers.glyphCenter = glyphCenterBuffer;
100
100
  layout.glyphCenter = {
101
101
  arrayStride: 12,
102
- attributes: [{ shaderLocation: nextShaderLocation++, offset: 0, format: 'float32x3' }]
102
+ attributes: [
103
+ { shaderLocation: nextShaderLocation++, offset: 0, format: 'float32x3' }
104
+ ]
103
105
  };
104
106
  glyphIndexBuffer = device.createBuffer({
105
107
  size: glyphAttributes.glyphIndex.byteLength,
@@ -111,7 +113,9 @@ function createWebGPUBuffers(device, textGeometry) {
111
113
  buffers.glyphIndex = glyphIndexBuffer;
112
114
  layout.glyphIndex = {
113
115
  arrayStride: 4,
114
- attributes: [{ shaderLocation: nextShaderLocation++, offset: 0, format: 'float32' }]
116
+ attributes: [
117
+ { shaderLocation: nextShaderLocation++, offset: 0, format: 'float32' }
118
+ ]
115
119
  };
116
120
  glyphLineIndexBuffer = device.createBuffer({
117
121
  size: glyphAttributes.glyphLineIndex.byteLength,
@@ -123,7 +127,9 @@ function createWebGPUBuffers(device, textGeometry) {
123
127
  buffers.glyphLineIndex = glyphLineIndexBuffer;
124
128
  layout.glyphLineIndex = {
125
129
  arrayStride: 4,
126
- attributes: [{ shaderLocation: nextShaderLocation++, offset: 0, format: 'float32' }]
130
+ attributes: [
131
+ { shaderLocation: nextShaderLocation++, offset: 0, format: 'float32' }
132
+ ]
127
133
  };
128
134
  glyphProgressBuffer = device.createBuffer({
129
135
  size: glyphAttributes.glyphProgress.byteLength,
@@ -135,7 +141,9 @@ function createWebGPUBuffers(device, textGeometry) {
135
141
  buffers.glyphProgress = glyphProgressBuffer;
136
142
  layout.glyphProgress = {
137
143
  arrayStride: 4,
138
- attributes: [{ shaderLocation: nextShaderLocation++, offset: 0, format: 'float32' }]
144
+ attributes: [
145
+ { shaderLocation: nextShaderLocation++, offset: 0, format: 'float32' }
146
+ ]
139
147
  };
140
148
  glyphBaselineYBuffer = device.createBuffer({
141
149
  size: glyphAttributes.glyphBaselineY.byteLength,
@@ -147,7 +155,9 @@ function createWebGPUBuffers(device, textGeometry) {
147
155
  buffers.glyphBaselineY = glyphBaselineYBuffer;
148
156
  layout.glyphBaselineY = {
149
157
  arrayStride: 4,
150
- attributes: [{ shaderLocation: nextShaderLocation++, offset: 0, format: 'float32' }]
158
+ attributes: [
159
+ { shaderLocation: nextShaderLocation++, offset: 0, format: 'float32' }
160
+ ]
151
161
  };
152
162
  }
153
163
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-text",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "3D mesh font geometry and text layout engine for the web",
5
5
  "main": "dist/three/index.cjs",
6
6
  "module": "dist/three/index.js",