abstract-image 3.3.3 → 3.4.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/CHANGELOG.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
- ## [Unreleased](https://github.com/dividab/abstract-visuals/compare/abstract-image@3.3.3...master)
5
+ ## [Unreleased](https://github.com/dividab/abstract-visuals/compare/abstract-image@3.4.0...master)
6
6
 
7
7
  ### Added
8
8
 
@@ -10,6 +10,16 @@ All notable changes to this project will be documented in this file. The format
10
10
 
11
11
  ### Removed
12
12
 
13
+ ## [v3.4.0](https://github.com/dividab/abstract-visuals/compare/abstract-image@3.3.3...abstract-image@3.4.0)
14
+
15
+ ### Added
16
+
17
+ - Added support for exporting EPS images with "ISOLatin1Encoding" encoding
18
+
19
+ ### Changed
20
+
21
+ ### Removed
22
+
13
23
  ## [v3.3.3](https://github.com/dividab/abstract-visuals/compare/abstract-image@3.3.2...abstract-image@3.3.3) - 2023-05-25
14
24
 
15
25
  ### Added
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=svg-export-image.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg-export-image.test.d.ts","sourceRoot":"","sources":["../../../src/_tests_/exporters/svg-export-image.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ const AbstractImage = __importStar(require("../../../src/index"));
23
+ describe("svg export", () => {
24
+ it("doesnt throw exception and produces output", () => {
25
+ const components = [
26
+ AbstractImage.createLine(AbstractImage.createPoint(25, 25), AbstractImage.createPoint(80, 60), AbstractImage.black, 2),
27
+ AbstractImage.createRectangle(AbstractImage.createPoint(10, 50), AbstractImage.createPoint(50, 60), AbstractImage.blue, 2, AbstractImage.red),
28
+ ];
29
+ const image = AbstractImage.createAbstractImage(AbstractImage.createPoint(0, 0), AbstractImage.createSize(400, 400), AbstractImage.white, components);
30
+ const svg = AbstractImage.createSVG(image);
31
+ // console.log(svg);
32
+ expect(svg !== "").toEqual(true);
33
+ });
34
+ });
35
+ //# sourceMappingURL=svg-export-image.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg-export-image.test.js","sourceRoot":"","sources":["../../../src/_tests_/exporters/svg-export-image.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,kEAAoD;AAEpD,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,UAAU,GAAG;YACjB,aAAa,CAAC,UAAU,CACtB,aAAa,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,CAAC,EACjC,aAAa,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,CAAC,EACjC,aAAa,CAAC,KAAK,EACnB,CAAC,CACF;YACD,aAAa,CAAC,eAAe,CAC3B,aAAa,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,CAAC,EACjC,aAAa,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,CAAC,EACjC,aAAa,CAAC,IAAI,EAClB,CAAC,EACD,aAAa,CAAC,GAAG,CAClB;SACF,CAAC;QACF,MAAM,KAAK,GAAG,aAAa,CAAC,mBAAmB,CAC7C,aAAa,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAC/B,aAAa,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,EAClC,aAAa,CAAC,KAAK,EACnB,UAAU,CACX,CAAC;QACF,MAAM,GAAG,GAAG,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC3C,oBAAoB;QACpB,MAAM,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -7,7 +7,7 @@ exports.tests = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const test_utils_1 = require("@abstract-visuals/test-utils");
9
9
  exports.tests = (0, test_utils_1.loadTests)(path_1.default.join(__dirname, "test-defs/"));
10
- describe("svg-export-image", () => {
10
+ describe("eps-export-image", () => {
11
11
  (0, test_utils_1.onlySkip)(exports.tests).forEach((item) => {
12
12
  test(item.name, async () => {
13
13
  expect(item.abstractImage).toEqual(item.expectedImage);
@@ -0,0 +1,3 @@
1
+ import { ExportTestDef } from "../export-test-def";
2
+ export declare const test: ExportTestDef;
3
+ //# sourceMappingURL=eps-text-iso-latin1-encoding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eps-text-iso-latin1-encoding.d.ts","sourceRoot":"","sources":["../../../../../src/exporters/__tests__/eps-export-image/test-defs/eps-text-iso-latin1-encoding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AA6BnD,eAAO,MAAM,IAAI,EAAE,aAyClB,CAAC"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.test = void 0;
23
+ const AbstractImage = __importStar(require("../../../../../src/index"));
24
+ const components = [
25
+ AbstractImage.createText(AbstractImage.createPoint(10, 10), "Q [m³/h]", "Arial", 12, AbstractImage.black, "bold", 0, "center", "right", "down", 2, AbstractImage.red, false),
26
+ ];
27
+ const image = AbstractImage.createAbstractImage(AbstractImage.createPoint(0, 0), AbstractImage.createSize(400, 400), AbstractImage.white, components);
28
+ const eps = new TextDecoder("iso-8859-1").decode(AbstractImage.epsExportImage(image, "iso-latin-1-encoding"));
29
+ exports.test = {
30
+ name: "eps text",
31
+ abstractImage: eps,
32
+ expectedImage: `%!PS-Adobe-3.0 EPSF-3.0
33
+ %%BoundingBox: 0 0 400 400
34
+ /ellipse {7 dict begin
35
+ /endangle exch def
36
+ /startangle exch def
37
+ /yradius exch def
38
+ /xradius exch def
39
+ /yC exch def
40
+ /xC exch def
41
+ /savematrix matrix currentmatrix def
42
+ xC yC translate
43
+ xradius yradius scale
44
+ 0 0 1 startangle endangle arc
45
+ savematrix setmatrix
46
+ end
47
+ } def
48
+ /Arial findfont
49
+ dup length dict begin
50
+ { 1 index /FID ne
51
+ {def}
52
+ {pop pop}
53
+ ifelse
54
+ } forall
55
+ /Encoding ISOLatin1Encoding def
56
+ currentdict
57
+ end
58
+ /Arial-ISOLatin1 exch definefont pop
59
+ 0 0 0 setrgbcolor
60
+ gsave
61
+ /Arial-ISOLatin1 findfont
62
+ 12 scalefont setfont
63
+ 10 390 moveto
64
+ 0
65
+ gsave (Q [m³/h]) true charpath pathbbox exch pop 3 -1 roll pop sub grestore
66
+ rmoveto
67
+ 0 rotate
68
+ (Q [m³/h]) show
69
+ grestore`,
70
+ };
71
+ //# sourceMappingURL=eps-text-iso-latin1-encoding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eps-text-iso-latin1-encoding.js","sourceRoot":"","sources":["../../../../../src/exporters/__tests__/eps-export-image/test-defs/eps-text-iso-latin1-encoding.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,wEAA0D;AAE1D,MAAM,UAAU,GAAG;IACjB,aAAa,CAAC,UAAU,CACtB,aAAa,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,CAAC,EACjC,UAAU,EACV,OAAO,EACP,EAAE,EACF,aAAa,CAAC,KAAK,EACnB,MAAM,EACN,CAAC,EACD,QAAQ,EACR,OAAO,EACP,MAAM,EACN,CAAC,EACD,aAAa,CAAC,GAAG,EACjB,KAAK,CACN;CACF,CAAC;AACF,MAAM,KAAK,GAAG,aAAa,CAAC,mBAAmB,CAC7C,aAAa,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAC/B,aAAa,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,EAClC,aAAa,CAAC,KAAK,EACnB,UAAU,CACX,CAAC;AAEF,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC,KAAK,EAAE,sBAAsB,CAAC,CAAC,CAAC;AAEjG,QAAA,IAAI,GAAkB;IACjC,IAAI,EAAE,UAAU;IAChB,aAAa,EAAE,GAAG;IAClB,aAAa,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAqCR;CACR,CAAC"}
@@ -1,3 +1,5 @@
1
1
  import * as AI from "../model/index";
2
2
  export declare function epsExportImage(root: AI.AbstractImage): string;
3
+ export declare function epsExportImage(root: AI.AbstractImage, characterEncoding: "standard-encoding"): string;
4
+ export declare function epsExportImage(root: AI.AbstractImage, characterEncoding: "iso-latin-1-encoding"): Uint8Array;
3
5
  //# sourceMappingURL=eps-export-image.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"eps-export-image.d.ts","sourceRoot":"","sources":["../../src/exporters/eps-export-image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGrC,wBAAgB,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,GAAG,MAAM,CAsB7D"}
1
+ {"version":3,"file":"eps-export-image.d.ts","sourceRoot":"","sources":["../../src/exporters/eps-export-image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAKrC,wBAAgB,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,GAAG,MAAM,CAAC;AAC/D,wBAAgB,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,EAAE,iBAAiB,EAAE,mBAAmB,GAAG,MAAM,CAAC;AACvG,wBAAgB,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,EAAE,iBAAiB,EAAE,sBAAsB,GAAG,UAAU,CAAC"}
@@ -21,7 +21,24 @@ var __importStar = (this && this.__importStar) || function (mod) {
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.epsExportImage = void 0;
23
23
  const R = __importStar(require("ramda"));
24
- function epsExportImage(root) {
24
+ function epsExportImage(root, characterEncoding) {
25
+ if (characterEncoding === "iso-latin-1-encoding") {
26
+ const eps = [
27
+ ...createEpsHeaderLines(root),
28
+ ...createIsoLatin1FontLines(root),
29
+ ...R.unnest(root.components.map((c) => epsExportComponent(c, root.size.height, "iso-latin-1-encoding"))),
30
+ ].join("\n");
31
+ return encodeLatin1Encoding(eps);
32
+ }
33
+ else {
34
+ return [
35
+ ...createEpsHeaderLines(root),
36
+ ...R.unnest(root.components.map((c) => epsExportComponent(c, root.size.height, "standard-encoding"))),
37
+ ].join("\n");
38
+ }
39
+ }
40
+ exports.epsExportImage = epsExportImage;
41
+ function createEpsHeaderLines(root) {
25
42
  return [
26
43
  "%!PS-Adobe-3.0 EPSF-3.0",
27
44
  `%%BoundingBox: 0 0 ${root.size.width} ${root.size.height}`,
@@ -39,11 +56,9 @@ function epsExportImage(root) {
39
56
  "savematrix setmatrix",
40
57
  "end",
41
58
  "} def",
42
- ...R.unnest(root.components.map(c => epsExportComponent(c, root.size.height)))
43
- ].join("\n");
59
+ ];
44
60
  }
45
- exports.epsExportImage = epsExportImage;
46
- function epsExportComponent(c, height) {
61
+ function epsExportComponent(c, height, characterEncoding) {
47
62
  switch (c.type) {
48
63
  case "ellipse": {
49
64
  const cx = (c.topLeft.x + c.bottomRight.x) * 0.5;
@@ -51,72 +66,66 @@ function epsExportComponent(c, height) {
51
66
  const rx = 0.5 * (c.bottomRight.x - c.topLeft.x);
52
67
  const ry = 0.5 * (c.bottomRight.y - c.topLeft.y);
53
68
  return [
54
- ...getColored(c.fillColor, [
55
- `${cx} ${cy} ${rx} ${ry} 0 360 ellipse`,
56
- "closepath",
57
- "fill"
58
- ]),
69
+ ...getColored(c.fillColor, [`${cx} ${cy} ${rx} ${ry} 0 360 ellipse`, "closepath", "fill"]),
59
70
  ...getColored(c.strokeColor, [
60
71
  `${cx} ${cy} ${rx} ${ry} 0 360 ellipse`,
61
72
  "closepath",
62
73
  `${c.strokeThickness} setlinewidth`,
63
- "stroke"
64
- ])
74
+ "stroke",
75
+ ]),
65
76
  ];
66
77
  }
67
78
  case "group": {
68
- return R.unnest(c.children.map(cc => epsExportComponent(cc, height)));
79
+ return R.unnest(c.children.map((cc) => epsExportComponent(cc, height, characterEncoding)));
69
80
  }
70
81
  case "line": {
71
82
  return getColored(c.strokeColor, [
72
83
  `${c.start.x} ${height - c.start.y} moveto`,
73
84
  `${c.end.x} ${height - c.end.y} lineto`,
74
85
  `${c.strokeThickness} setlinewidth`,
75
- "stroke"
86
+ "stroke",
76
87
  ]);
77
88
  }
78
89
  case "polygon": {
79
90
  return [
80
91
  ...getColored(c.fillColor, [
81
92
  `${c.points[0].x} ${height - c.points[0].y} moveto`,
82
- ...c.points.map(p => `${p.x} ${height - p.y} lineto`),
93
+ ...c.points.map((p) => `${p.x} ${height - p.y} lineto`),
83
94
  "closepath",
84
95
  `${c.strokeThickness} setlinewidth`,
85
- "fill"
96
+ "fill",
86
97
  ]),
87
98
  ...getColored(c.strokeColor, [
88
99
  `${c.points[0].x} ${height - c.points[0].y} moveto`,
89
- ...c.points.map(p => `${p.x} ${height - p.y} lineto`),
100
+ ...c.points.map((p) => `${p.x} ${height - p.y} lineto`),
90
101
  "closepath",
91
- "stroke"
92
- ])
102
+ "stroke",
103
+ ]),
93
104
  ];
94
105
  }
95
106
  case "polyline": {
96
107
  return getColored(c.strokeColor, [
97
108
  `${c.points[0].x} ${height - c.points[0].y} moveto`,
98
- ...c.points.map(p => `${p.x} ${height - p.y} lineto`),
109
+ ...c.points.map((p) => `${p.x} ${height - p.y} lineto`),
99
110
  `${c.strokeThickness} setlinewidth`,
100
- "stroke"
111
+ "stroke",
101
112
  ]);
102
113
  }
103
114
  case "rectangle": {
104
115
  const w = c.bottomRight.x - c.topLeft.x;
105
116
  const h = c.bottomRight.y - c.topLeft.y;
106
117
  return [
107
- ...getColored(c.fillColor, [
108
- `${c.topLeft.x} ${height - c.bottomRight.y} ${w} ${h} rectfill`
109
- ]),
118
+ ...getColored(c.fillColor, [`${c.topLeft.x} ${height - c.bottomRight.y} ${w} ${h} rectfill`]),
110
119
  ...getColored(c.strokeColor, [
111
120
  `${c.strokeThickness} setlinewidth`,
112
- `${c.topLeft.x} ${height - c.bottomRight.y} ${w} ${h} rectstroke`
113
- ])
121
+ `${c.topLeft.x} ${height - c.bottomRight.y} ${w} ${h} rectstroke`,
122
+ ]),
114
123
  ];
115
124
  }
116
125
  case "text": {
117
126
  return getColored(c.textColor, [
118
127
  `gsave`,
119
- `/${c.fontFamily} findfont`,
128
+ `/${createFontName(characterEncoding, c.fontFamily)} findfont`,
120
129
  `${c.fontSize} scalefont setfont`,
121
130
  `${c.position.x} ${height - c.position.y} moveto`,
122
131
  getTextXOffset(c),
@@ -124,7 +133,7 @@ function epsExportComponent(c, height) {
124
133
  `rmoveto`,
125
134
  `${-c.clockwiseRotationDegrees} rotate`,
126
135
  `(${c.text}) show`,
127
- `grestore`
136
+ `grestore`,
128
137
  ]);
129
138
  }
130
139
  default:
@@ -157,9 +166,81 @@ function getColored(color, instructions) {
157
166
  if (color.a === 0) {
158
167
  return [];
159
168
  }
160
- return [
161
- `${color.r / 255} ${color.g / 255} ${color.b / 255} setrgbcolor`,
162
- ...instructions
163
- ];
169
+ return [`${color.r / 255} ${color.g / 255} ${color.b / 255} setrgbcolor`, ...instructions];
170
+ }
171
+ function createFontName(characterEncoding, fontFamily) {
172
+ if (characterEncoding === "iso-latin-1-encoding") {
173
+ return `${fontFamily}-ISOLatin1`;
174
+ }
175
+ else {
176
+ return fontFamily;
177
+ }
178
+ }
179
+ function encodeLatin1Encoding(text) {
180
+ // ISOLatin1Encoding is close to iso-8859-1 encoding (https://en.wikipedia.org/wiki/PostScript_Latin_1_Encoding)
181
+ // Code points 0-256 returned by codePointAt() maps to iso-8859-1
182
+ const unknownCharacter = "?".codePointAt(0) || 32;
183
+ const output = [];
184
+ // Array.from() to handle characters consisting of multiple code points
185
+ for (const c of Array.from(text)) {
186
+ if (c.length > 1) {
187
+ output.push(unknownCharacter);
188
+ }
189
+ else {
190
+ const cp = c.codePointAt(0) || 32;
191
+ if (cp > 255) {
192
+ output.push(unknownCharacter);
193
+ }
194
+ output.push(cp);
195
+ }
196
+ }
197
+ return new Uint8Array(output);
198
+ }
199
+ function createIsoLatin1FontLines(root) {
200
+ const fontFamilies = getUsedFontFamilies(root.components);
201
+ const lines = [];
202
+ for (const fontFamily of fontFamilies) {
203
+ // 1. Makes a copy of the font dictionary, including all entries except the one whose
204
+ // key is FID. (This exclusion is necessary only in LanguageLevel 1; in Language-
205
+ // Level 2, the interpreter ignores any existing FID entry in a font being defined.)
206
+ //
207
+ // 2. Installs the desired change: replaces the font’s Encoding array with the value of
208
+ // ISOLatin1Encoding, which is a built-in, 256-element array of character names
209
+ // defined in systemdict.
210
+ //
211
+ // 3. Registers this modified font under a new name (Helvetica-ISOLatin1).
212
+ //
213
+ // https://www.adobe.com/jp/print/postscript/pdfs/PLRM.pdf
214
+ lines.push(...[
215
+ `/${fontFamily} findfont`,
216
+ "dup length dict begin",
217
+ " { 1 index /FID ne",
218
+ " {def}",
219
+ " {pop pop}",
220
+ " ifelse",
221
+ " } forall",
222
+ " /Encoding ISOLatin1Encoding def",
223
+ " currentdict",
224
+ "end",
225
+ `/${createFontName("iso-latin-1-encoding", fontFamily)} exch definefont pop`,
226
+ ]);
227
+ }
228
+ return lines;
229
+ }
230
+ function getUsedFontFamilies(components) {
231
+ const families = [];
232
+ for (const c of components) {
233
+ switch (c.type) {
234
+ case "text":
235
+ families.push(c.fontFamily);
236
+ break;
237
+ case "group":
238
+ families.push(...getUsedFontFamilies(c.children));
239
+ break;
240
+ default:
241
+ break;
242
+ }
243
+ }
244
+ return R.uniq(families);
164
245
  }
165
246
  //# sourceMappingURL=eps-export-image.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"eps-export-image.js","sourceRoot":"","sources":["../../src/exporters/eps-export-image.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,yCAA2B;AAE3B,SAAgB,cAAc,CAAC,IAAsB;IACnD,OAAO;QACL,yBAAyB;QACzB,sBAAsB,IA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,YAAY,GAAG,mBAAmB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC1D,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,KAAK,MAAM,UAAU,IAAI,YAAY,EAAE;QACrC,qFAAqF;QACrF,iFAAiF;QACjF,oFAAoF;QACpF,EAAE;QACF,uFAAuF;QACvF,+EAA+E;QAC/E,yBAAyB;QACzB,EAAE;QACF,0EAA0E;QAC1E,EAAE;QACF,0DAA0D;QAC1D,KAAK,CAAC,IAAI,CACR,GAAG;YACD,IAAI,UAAU,WAAW;YACzB,uBAAuB;YACvB,qBAAqB;YACrB,aAAa;YACb,iBAAiB;YACjB,YAAY;YACZ,YAAY;YACZ,mCAAmC;YACnC,eAAe;YACf,KAAK;YACL,IAAI,cAAc,CAAC,sBAAsB,EAAE,UAAU,CAAC,sBAAsB;SAC7E,CACF,CAAC;KACH;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,mBAAmB,CAAC,UAAuC;IAClE,MAAM,QAAQ,GAAG,EAAE,CAAC;IACpB,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE;QAC1B,QAAQ,CAAC,CAAC,IAAI,EAAE;YACd,KAAK,MAAM;gBACT,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;gBAC5B,MAAM;YACR,KAAK,OAAO;gBACV,QAAQ,CAAC,IAAI,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAClD,MAAM;YACR;gBACE,MAAM;SACT;KACF;IACD,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abstract-image",
3
- "version": "3.3.3",
3
+ "version": "3.4.0",
4
4
  "description": "Dynamically create images using code or JSX and render to any format",
5
5
  "repository": "https://github.com/dividab/abstract-visuals/tree/master/packages/abstract-image",
6
6
  "main": "lib/index.js",
@@ -26,5 +26,5 @@
26
26
  "@types/react": "^16.9.0",
27
27
  "@types/react-dom": "^16.9.0"
28
28
  },
29
- "gitHead": "e78e62680b8ae6ff53cd593c1e229c34573ec2e2"
29
+ "gitHead": "cc48e3f14a9ec319766ae3322bcdd98748718cab"
30
30
  }
@@ -4,7 +4,7 @@ import { ExportTestDef } from "./export-test-def";
4
4
 
5
5
  export const tests = loadTests<ExportTestDef>(path.join(__dirname, "test-defs/"));
6
6
 
7
- describe("svg-export-image", () => {
7
+ describe("eps-export-image", () => {
8
8
  onlySkip(tests).forEach((item) => {
9
9
  test(item.name, async () => {
10
10
  expect(item.abstractImage).toEqual(item.expectedImage);
@@ -0,0 +1,71 @@
1
+ import { ExportTestDef } from "../export-test-def";
2
+ import * as AbstractImage from "../../../../../src/index";
3
+
4
+ const components = [
5
+ AbstractImage.createText(
6
+ AbstractImage.createPoint(10, 10),
7
+ "Q [m³/h]",
8
+ "Arial",
9
+ 12,
10
+ AbstractImage.black,
11
+ "bold",
12
+ 0,
13
+ "center",
14
+ "right",
15
+ "down",
16
+ 2,
17
+ AbstractImage.red,
18
+ false
19
+ ),
20
+ ];
21
+ const image = AbstractImage.createAbstractImage(
22
+ AbstractImage.createPoint(0, 0),
23
+ AbstractImage.createSize(400, 400),
24
+ AbstractImage.white,
25
+ components
26
+ );
27
+
28
+ const eps = new TextDecoder("iso-8859-1").decode(AbstractImage.epsExportImage(image, "iso-latin-1-encoding"));
29
+
30
+ export const test: ExportTestDef = {
31
+ name: "eps text",
32
+ abstractImage: eps,
33
+ expectedImage: `%!PS-Adobe-3.0 EPSF-3.0
34
+ %%BoundingBox: 0 0 400 400
35
+ /ellipse {7 dict begin
36
+ /endangle exch def
37
+ /startangle exch def
38
+ /yradius exch def
39
+ /xradius exch def
40
+ /yC exch def
41
+ /xC exch def
42
+ /savematrix matrix currentmatrix def
43
+ xC yC translate
44
+ xradius yradius scale
45
+ 0 0 1 startangle endangle arc
46
+ savematrix setmatrix
47
+ end
48
+ } def
49
+ /Arial findfont
50
+ dup length dict begin
51
+ { 1 index /FID ne
52
+ {def}
53
+ {pop pop}
54
+ ifelse
55
+ } forall
56
+ /Encoding ISOLatin1Encoding def
57
+ currentdict
58
+ end
59
+ /Arial-ISOLatin1 exch definefont pop
60
+ 0 0 0 setrgbcolor
61
+ gsave
62
+ /Arial-ISOLatin1 findfont
63
+ 12 scalefont setfont
64
+ 10 390 moveto
65
+ 0
66
+ gsave (Q [m³/h]) true charpath pathbbox exch pop 3 -1 roll pop sub grestore
67
+ rmoveto
68
+ 0 rotate
69
+ (Q [m³/h]) show
70
+ grestore`,
71
+ };
@@ -1,7 +1,28 @@
1
1
  import * as AI from "../model/index";
2
2
  import * as R from "ramda";
3
3
 
4
- export function epsExportImage(root: AI.AbstractImage): string {
4
+ type CharacterEncoding = "standard-encoding" | "iso-latin-1-encoding";
5
+
6
+ export function epsExportImage(root: AI.AbstractImage): string;
7
+ export function epsExportImage(root: AI.AbstractImage, characterEncoding: "standard-encoding"): string;
8
+ export function epsExportImage(root: AI.AbstractImage, characterEncoding: "iso-latin-1-encoding"): Uint8Array;
9
+ export function epsExportImage(root: AI.AbstractImage, characterEncoding?: CharacterEncoding): string | Uint8Array {
10
+ if (characterEncoding === "iso-latin-1-encoding") {
11
+ const eps = [
12
+ ...createEpsHeaderLines(root),
13
+ ...createIsoLatin1FontLines(root),
14
+ ...R.unnest<string>(root.components.map((c) => epsExportComponent(c, root.size.height, "iso-latin-1-encoding"))),
15
+ ].join("\n");
16
+ return encodeLatin1Encoding(eps);
17
+ } else {
18
+ return [
19
+ ...createEpsHeaderLines(root),
20
+ ...R.unnest<string>(root.components.map((c) => epsExportComponent(c, root.size.height, "standard-encoding"))),
21
+ ].join("\n");
22
+ }
23
+ }
24
+
25
+ function createEpsHeaderLines(root: AI.AbstractImage): ReadonlyArray<string> {
5
26
  return [
6
27
  "%!PS-Adobe-3.0 EPSF-3.0",
7
28
  `%%BoundingBox: 0 0 ${root.size.width} ${root.size.height}`,
@@ -19,13 +40,10 @@ export function epsExportImage(root: AI.AbstractImage): string {
19
40
  "savematrix setmatrix",
20
41
  "end",
21
42
  "} def",
22
- ...R.unnest<string>(
23
- root.components.map(c => epsExportComponent(c, root.size.height))
24
- )
25
- ].join("\n");
43
+ ];
26
44
  }
27
45
 
28
- function epsExportComponent(c: AI.Component, height: number): Array<string> {
46
+ function epsExportComponent(c: AI.Component, height: number, characterEncoding: CharacterEncoding): Array<string> {
29
47
  switch (c.type) {
30
48
  case "ellipse": {
31
49
  const cx = (c.topLeft.x + c.bottomRight.x) * 0.5;
@@ -33,74 +51,66 @@ function epsExportComponent(c: AI.Component, height: number): Array<string> {
33
51
  const rx = 0.5 * (c.bottomRight.x - c.topLeft.x);
34
52
  const ry = 0.5 * (c.bottomRight.y - c.topLeft.y);
35
53
  return [
36
- ...getColored(c.fillColor, [
37
- `${cx} ${cy} ${rx} ${ry} 0 360 ellipse`,
38
- "closepath",
39
- "fill"
40
- ]),
54
+ ...getColored(c.fillColor, [`${cx} ${cy} ${rx} ${ry} 0 360 ellipse`, "closepath", "fill"]),
41
55
  ...getColored(c.strokeColor, [
42
56
  `${cx} ${cy} ${rx} ${ry} 0 360 ellipse`,
43
57
  "closepath",
44
58
  `${c.strokeThickness} setlinewidth`,
45
- "stroke"
46
- ])
59
+ "stroke",
60
+ ]),
47
61
  ];
48
62
  }
49
63
  case "group": {
50
- return R.unnest<string>(
51
- c.children.map(cc => epsExportComponent(cc, height))
52
- );
64
+ return R.unnest<string>(c.children.map((cc) => epsExportComponent(cc, height, characterEncoding)));
53
65
  }
54
66
  case "line": {
55
67
  return getColored(c.strokeColor, [
56
68
  `${c.start.x} ${height - c.start.y} moveto`,
57
69
  `${c.end.x} ${height - c.end.y} lineto`,
58
70
  `${c.strokeThickness} setlinewidth`,
59
- "stroke"
71
+ "stroke",
60
72
  ]);
61
73
  }
62
74
  case "polygon": {
63
75
  return [
64
76
  ...getColored(c.fillColor, [
65
77
  `${c.points[0].x} ${height - c.points[0].y} moveto`,
66
- ...c.points.map(p => `${p.x} ${height - p.y} lineto`),
78
+ ...c.points.map((p) => `${p.x} ${height - p.y} lineto`),
67
79
  "closepath",
68
80
  `${c.strokeThickness} setlinewidth`,
69
- "fill"
81
+ "fill",
70
82
  ]),
71
83
  ...getColored(c.strokeColor, [
72
84
  `${c.points[0].x} ${height - c.points[0].y} moveto`,
73
- ...c.points.map(p => `${p.x} ${height - p.y} lineto`),
85
+ ...c.points.map((p) => `${p.x} ${height - p.y} lineto`),
74
86
  "closepath",
75
- "stroke"
76
- ])
87
+ "stroke",
88
+ ]),
77
89
  ];
78
90
  }
79
91
  case "polyline": {
80
92
  return getColored(c.strokeColor, [
81
93
  `${c.points[0].x} ${height - c.points[0].y} moveto`,
82
- ...c.points.map(p => `${p.x} ${height - p.y} lineto`),
94
+ ...c.points.map((p) => `${p.x} ${height - p.y} lineto`),
83
95
  `${c.strokeThickness} setlinewidth`,
84
- "stroke"
96
+ "stroke",
85
97
  ]);
86
98
  }
87
99
  case "rectangle": {
88
100
  const w = c.bottomRight.x - c.topLeft.x;
89
101
  const h = c.bottomRight.y - c.topLeft.y;
90
102
  return [
91
- ...getColored(c.fillColor, [
92
- `${c.topLeft.x} ${height - c.bottomRight.y} ${w} ${h} rectfill`
93
- ]),
103
+ ...getColored(c.fillColor, [`${c.topLeft.x} ${height - c.bottomRight.y} ${w} ${h} rectfill`]),
94
104
  ...getColored(c.strokeColor, [
95
105
  `${c.strokeThickness} setlinewidth`,
96
- `${c.topLeft.x} ${height - c.bottomRight.y} ${w} ${h} rectstroke`
97
- ])
106
+ `${c.topLeft.x} ${height - c.bottomRight.y} ${w} ${h} rectstroke`,
107
+ ]),
98
108
  ];
99
109
  }
100
110
  case "text": {
101
111
  return getColored(c.textColor, [
102
112
  `gsave`,
103
- `/${c.fontFamily} findfont`,
113
+ `/${createFontName(characterEncoding, c.fontFamily)} findfont`,
104
114
  `${c.fontSize} scalefont setfont`,
105
115
  `${c.position.x} ${height - c.position.y} moveto`,
106
116
  getTextXOffset(c),
@@ -108,7 +118,7 @@ function epsExportComponent(c: AI.Component, height: number): Array<string> {
108
118
  `rmoveto`,
109
119
  `${-c.clockwiseRotationDegrees} rotate`,
110
120
  `(${c.text}) show`,
111
- `grestore`
121
+ `grestore`,
112
122
  ]);
113
123
  }
114
124
  default:
@@ -128,27 +138,96 @@ function getTextXOffset(c: AI.Text): string {
128
138
 
129
139
  function getTextYOffset(c: AI.Text): string {
130
140
  if (c.verticalGrowthDirection === "down") {
131
- return `gsave (${
132
- c.text
133
- }) true charpath pathbbox exch pop 3 -1 roll pop sub grestore`;
141
+ return `gsave (${c.text}) true charpath pathbbox exch pop 3 -1 roll pop sub grestore`;
134
142
  } else if (c.verticalGrowthDirection === "uniform") {
135
- return `gsave (${
136
- c.text
137
- }) true charpath pathbbox exch pop 3 -1 roll pop sub 0.5 mul grestore`;
143
+ return `gsave (${c.text}) true charpath pathbbox exch pop 3 -1 roll pop sub 0.5 mul grestore`;
138
144
  } else {
139
145
  return `0`;
140
146
  }
141
147
  }
142
148
 
143
- function getColored(
144
- color: AI.Color,
145
- instructions: Array<string>
146
- ): Array<string> {
149
+ function getColored(color: AI.Color, instructions: Array<string>): Array<string> {
147
150
  if (color.a === 0) {
148
151
  return [];
149
152
  }
150
- return [
151
- `${color.r / 255} ${color.g / 255} ${color.b / 255} setrgbcolor`,
152
- ...instructions
153
- ];
153
+ return [`${color.r / 255} ${color.g / 255} ${color.b / 255} setrgbcolor`, ...instructions];
154
+ }
155
+
156
+ function createFontName(characterEncoding: CharacterEncoding, fontFamily: string): string {
157
+ if (characterEncoding === "iso-latin-1-encoding") {
158
+ return `${fontFamily}-ISOLatin1`;
159
+ } else {
160
+ return fontFamily;
161
+ }
162
+ }
163
+
164
+ function encodeLatin1Encoding(text: string): Uint8Array {
165
+ // ISOLatin1Encoding is close to iso-8859-1 encoding (https://en.wikipedia.org/wiki/PostScript_Latin_1_Encoding)
166
+ // Code points 0-256 returned by codePointAt() maps to iso-8859-1
167
+ const unknownCharacter = "?".codePointAt(0) || 32;
168
+ const output: Array<number> = [];
169
+ // Array.from() to handle characters consisting of multiple code points
170
+ for (const c of Array.from(text)) {
171
+ if (c.length > 1) {
172
+ output.push(unknownCharacter);
173
+ } else {
174
+ const cp = c.codePointAt(0) || 32;
175
+ if (cp > 255) {
176
+ output.push(unknownCharacter);
177
+ }
178
+ output.push(cp);
179
+ }
180
+ }
181
+ return new Uint8Array(output);
182
+ }
183
+
184
+ function createIsoLatin1FontLines(root: AI.AbstractImage): ReadonlyArray<string> {
185
+ const fontFamilies = getUsedFontFamilies(root.components);
186
+ const lines = [];
187
+ for (const fontFamily of fontFamilies) {
188
+ // 1. Makes a copy of the font dictionary, including all entries except the one whose
189
+ // key is FID. (This exclusion is necessary only in LanguageLevel 1; in Language-
190
+ // Level 2, the interpreter ignores any existing FID entry in a font being defined.)
191
+ //
192
+ // 2. Installs the desired change: replaces the font’s Encoding array with the value of
193
+ // ISOLatin1Encoding, which is a built-in, 256-element array of character names
194
+ // defined in systemdict.
195
+ //
196
+ // 3. Registers this modified font under a new name (Helvetica-ISOLatin1).
197
+ //
198
+ // https://www.adobe.com/jp/print/postscript/pdfs/PLRM.pdf
199
+ lines.push(
200
+ ...[
201
+ `/${fontFamily} findfont`,
202
+ "dup length dict begin",
203
+ " { 1 index /FID ne",
204
+ " {def}",
205
+ " {pop pop}",
206
+ " ifelse",
207
+ " } forall",
208
+ " /Encoding ISOLatin1Encoding def",
209
+ " currentdict",
210
+ "end",
211
+ `/${createFontName("iso-latin-1-encoding", fontFamily)} exch definefont pop`,
212
+ ]
213
+ );
214
+ }
215
+ return lines;
216
+ }
217
+
218
+ function getUsedFontFamilies(components: ReadonlyArray<AI.Component>): ReadonlyArray<string> {
219
+ const families = [];
220
+ for (const c of components) {
221
+ switch (c.type) {
222
+ case "text":
223
+ families.push(c.fontFamily);
224
+ break;
225
+ case "group":
226
+ families.push(...getUsedFontFamilies(c.children));
227
+ break;
228
+ default:
229
+ break;
230
+ }
231
+ }
232
+ return R.uniq(families);
154
233
  }