@ot-builder/io-bin-ttf 1.7.8 → 1.9.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.
@@ -1,4 +1,5 @@
1
1
  export interface TtfCfgProps {
2
+ glyfIncludeOverlapSimpleFlag?: boolean;
2
3
  gvarOptimizeTolerance?: number;
3
4
  gvarForceProduceGVD?: boolean;
4
5
  gvarForceZeroGapsBetweenGVD?: boolean;
package/lib/cfg/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DefaultTtfCfgProps = void 0;
4
4
  exports.DefaultTtfCfgProps = {
5
+ glyfIncludeOverlapSimpleFlag: true,
5
6
  gvarOptimizeTolerance: 1 / 128,
6
7
  gvarForceProduceGVD: false,
7
8
  gvarForceZeroGapsBetweenGVD: false,
@@ -1,6 +1,6 @@
1
- import { BinaryView, Frag } from "@ot-builder/bin-util";
2
- import * as ImpLib from "@ot-builder/common-impl";
3
- import { Cvt } from "@ot-builder/ot-glyphs";
1
+ import type { BinaryView, Frag } from "@ot-builder/bin-util";
2
+ import type * as ImpLib from "@ot-builder/common-impl";
3
+ import type { Cvt } from "@ot-builder/ot-glyphs";
4
4
  import { OtVar } from "@ot-builder/variance";
5
5
  export declare const CvarIo: {
6
6
  read(view: BinaryView, cvt: Cvt.Table, designSpace: OtVar.DesignSpace): void;
@@ -1,4 +1,4 @@
1
- import { BinaryView, Frag } from "@ot-builder/bin-util";
1
+ import type { BinaryView, Frag } from "@ot-builder/bin-util";
2
2
  import { Cvt } from "@ot-builder/ot-glyphs";
3
3
  export declare const CvtIo: {
4
4
  read(view: BinaryView): Cvt.Table;
@@ -1,4 +1,4 @@
1
- import { BinaryView, Frag } from "@ot-builder/bin-util";
1
+ import type { BinaryView, Frag } from "@ot-builder/bin-util";
2
2
  import { Fpgm, Prep } from "@ot-builder/ot-glyphs";
3
3
  export declare const FpgmIo: {
4
4
  read(view: BinaryView): Fpgm.Table;
@@ -1,5 +1,5 @@
1
1
  import { OtGlyph } from "@ot-builder/ot-glyphs";
2
- import { Data } from "@ot-builder/prelude";
2
+ import type { Data } from "@ot-builder/prelude";
3
3
  export declare class GlyphClassifier {
4
4
  private gOrd;
5
5
  constructor(gOrd: Data.Order<OtGlyph>);
@@ -1,5 +1,5 @@
1
- import { BinaryView, Frag } from "@ot-builder/bin-util";
2
- import { Head, Maxp } from "@ot-builder/ot-metadata";
1
+ import type { BinaryView, Frag } from "@ot-builder/bin-util";
2
+ import type { Head, Maxp } from "@ot-builder/ot-metadata";
3
3
  export declare const LocaTag = "loca";
4
4
  export interface LocaTable {
5
5
  glyphOffsets: number[];
@@ -1,6 +1,6 @@
1
1
  import { Read } from "@ot-builder/bin-util";
2
2
  import { OtGlyph } from "@ot-builder/ot-glyphs";
3
- import { Data } from "@ot-builder/prelude";
4
- import { LocaTable } from "./loca";
3
+ import type { Data } from "@ot-builder/prelude";
4
+ import type { LocaTable } from "./loca";
5
5
  export declare const GlyfTableRead: Read<void, [loca: LocaTable, gOrd: Data.Order<OtGlyph>, coStat: OtGlyph.CoStat.Source]>;
6
6
  //# sourceMappingURL=read.d.ts.map
package/lib/glyf/read.js CHANGED
@@ -178,6 +178,7 @@ const CompositeGlyph = (0, bin_util_1.Read)((view, gOrd) => {
178
178
  return { references, instructions };
179
179
  });
180
180
  exports.GlyfTableRead = (0, bin_util_1.Read)((view, loca, gOrd, coStat) => {
181
+ var _a;
181
182
  for (let gid = 0; gid < gOrd.length; gid++) {
182
183
  const glyph = gOrd.at(gid);
183
184
  const offset = loca.glyphOffsets[gid];
@@ -193,14 +194,14 @@ exports.GlyfTableRead = (0, bin_util_1.Read)((view, loca, gOrd, coStat) => {
193
194
  if (numberOfContours >= 0) {
194
195
  const { geometry, instructions } = vGlyph.next(SimpleGlyph, numberOfContours);
195
196
  glyph.geometry = geometry;
196
- if (instructions && instructions.byteLength) {
197
+ if (instructions.byteLength) {
197
198
  glyph.hints = new ot_glyphs_1.OtGlyph.TtInstruction(instructions);
198
199
  }
199
200
  }
200
201
  else {
201
202
  const r = vGlyph.next(CompositeGlyph, gOrd);
202
203
  glyph.geometry = new ot_glyphs_1.OtGlyph.GeometryList(r.references);
203
- if (r.instructions && r.instructions.byteLength) {
204
+ if ((_a = r.instructions) === null || _a === void 0 ? void 0 : _a.byteLength) {
204
205
  glyph.hints = new ot_glyphs_1.OtGlyph.TtInstruction(r.instructions);
205
206
  }
206
207
  }
@@ -1,7 +1,8 @@
1
1
  import { Write } from "@ot-builder/bin-util";
2
2
  import { OtGlyph } from "@ot-builder/ot-glyphs";
3
- import { Data } from "@ot-builder/prelude";
4
- import { TtfWritingExtraInfoSink } from "../extra-info-sink/index";
5
- import { LocaTable } from "./loca";
6
- export declare const GlyfTableWrite: Write<Data.Order<OtGlyph>, [outLoca: LocaTable, stat: OtGlyph.Stat.Sink, extraInfoSink: TtfWritingExtraInfoSink]>;
3
+ import type { Data } from "@ot-builder/prelude";
4
+ import type { TtfCfg } from "../cfg";
5
+ import type { TtfWritingExtraInfoSink } from "../extra-info-sink/index";
6
+ import type { LocaTable } from "./loca";
7
+ export declare const GlyfTableWrite: Write<Data.Order<OtGlyph>, [cfg: TtfCfg, outLoca: LocaTable, stat: OtGlyph.Stat.Sink, extraInfoSink: TtfWritingExtraInfoSink]>;
7
8
  //# sourceMappingURL=write.d.ts.map
package/lib/glyf/write.js CHANGED
@@ -1,15 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GlyfTableWrite = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const bin_util_1 = require("@ot-builder/bin-util");
5
- const ImpLib = require("@ot-builder/common-impl");
6
+ const ImpLib = tslib_1.__importStar(require("@ot-builder/common-impl"));
6
7
  const ot_glyphs_1 = require("@ot-builder/ot-glyphs");
7
8
  const primitive_1 = require("@ot-builder/primitive");
8
9
  const variance_1 = require("@ot-builder/variance");
9
10
  const classifier_1 = require("./classifier");
10
11
  const shared_1 = require("./shared");
11
12
  class FlagShrinker {
12
- constructor() {
13
+ constructor(cfg) {
14
+ this.cfg = cfg;
13
15
  this.flags = [];
14
16
  this.repeating = 0;
15
17
  this.last = 0;
@@ -42,8 +44,7 @@ class FlagShrinker {
42
44
  this.count++;
43
45
  }
44
46
  finalizeAndGetFlags() {
45
- // Always set overlapping flag
46
- if (this.flags.length) {
47
+ if (this.cfg.ttf.glyfIncludeOverlapSimpleFlag && this.flags.length) {
47
48
  this.flags[0] |= shared_1.SimpleGlyphFlag.OVERLAP_SIMPLE;
48
49
  }
49
50
  return this.flags;
@@ -68,10 +69,10 @@ class FlagShrinker {
68
69
  }
69
70
  }
70
71
  // TODO: could we optimize MORE?
71
- function collectSimpleGlyphOutlineData(sg) {
72
+ function collectSimpleGlyphOutlineData(sg, cfg) {
72
73
  let endPtsOfContours = -1;
73
74
  const endPtsOfContoursArray = [];
74
- const shrinker = new FlagShrinker();
75
+ const shrinker = new FlagShrinker(cfg);
75
76
  const fragX = new bin_util_1.Frag();
76
77
  const fragY = new bin_util_1.Frag();
77
78
  let cx = 0, cy = 0;
@@ -93,14 +94,14 @@ function collectSimpleGlyphOutlineData(sg) {
93
94
  }
94
95
  return { flags: shrinker.finalizeAndGetFlags(), fragX, fragY, endPtsOfContoursArray };
95
96
  }
96
- const SimpleGlyphData = (0, bin_util_1.Write)((frag, sg) => {
97
+ const SimpleGlyphData = (0, bin_util_1.Write)((frag, sg, cfg) => {
97
98
  const st = sg.getStatData();
98
99
  frag.int16(st.eigenContours)
99
100
  .int16(st.extent.xMin)
100
101
  .int16(st.extent.yMin)
101
102
  .int16(st.extent.xMax)
102
103
  .int16(st.extent.yMax);
103
- const analysis = collectSimpleGlyphOutlineData(sg);
104
+ const analysis = collectSimpleGlyphOutlineData(sg, cfg);
104
105
  for (const zid of analysis.endPtsOfContoursArray)
105
106
  frag.uint16(zid);
106
107
  frag.uint16(sg.instructions.byteLength);
@@ -217,7 +218,7 @@ const CompositeGlyphData = (0, bin_util_1.Write)((frag, cg, iGlyph, gOrd, extraI
217
218
  );
218
219
  }
219
220
  });
220
- exports.GlyfTableWrite = (0, bin_util_1.Write)((frag, gOrd, outLoca, stat, extraInfoSink) => {
221
+ exports.GlyfTableWrite = (0, bin_util_1.Write)((frag, gOrd, cfg, outLoca, stat, extraInfoSink) => {
221
222
  const sink = new StdGlyfDataSink(outLoca, frag);
222
223
  sink.begin();
223
224
  stat.setNumGlyphs(gOrd.length);
@@ -228,7 +229,7 @@ exports.GlyfTableWrite = (0, bin_util_1.Write)((frag, gOrd, outLoca, stat, extra
228
229
  cg.stat(stat);
229
230
  const fGlyph = new bin_util_1.Frag();
230
231
  if (cg instanceof classifier_1.SimpleGlyph) {
231
- fGlyph.push(SimpleGlyphData, cg);
232
+ fGlyph.push(SimpleGlyphData, cg, cfg);
232
233
  }
233
234
  else if (cg instanceof classifier_1.CompositeGlyph) {
234
235
  fGlyph.push(CompositeGlyphData, cg, iGlyph, gOrd, extraInfoSink);
@@ -1,8 +1,8 @@
1
1
  import { Read } from "@ot-builder/bin-util";
2
2
  import { OtGlyph } from "@ot-builder/ot-glyphs";
3
- import { Data } from "@ot-builder/prelude";
3
+ import type { Data } from "@ot-builder/prelude";
4
4
  import { OtVar } from "@ot-builder/variance";
5
- import { TtfCfg } from "../cfg";
5
+ import type { TtfCfg } from "../cfg";
6
6
  export interface GvarReadIgnore {
7
7
  horizontalMetric?: boolean;
8
8
  verticalMetric?: boolean;
@@ -1,8 +1,8 @@
1
1
  import { Write } from "@ot-builder/bin-util";
2
- import * as ImpLib from "@ot-builder/common-impl";
2
+ import type * as ImpLib from "@ot-builder/common-impl";
3
3
  import { OtGlyph } from "@ot-builder/ot-glyphs";
4
- import { Data } from "@ot-builder/prelude";
5
- import { OtVar } from "@ot-builder/variance";
6
- import { TtfCfg } from "../cfg";
4
+ import type { Data } from "@ot-builder/prelude";
5
+ import type { OtVar } from "@ot-builder/variance";
6
+ import type { TtfCfg } from "../cfg";
7
7
  export declare const GvarTableWrite: Write<Data.Order<OtGlyph>, [cfg: TtfCfg, designSpace: OtVar.DesignSpace, acEmpty?: ImpLib.Access<boolean> | undefined]>;
8
8
  //# sourceMappingURL=write.d.ts.map
package/lib/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { LocaTable } from "./glyf/loca";
2
- export * from "./cvt/index";
3
- export * from "./cvar/index";
4
- export * from "./fpgm-prep/index";
1
+ import { type LocaTable } from "./glyf/loca";
5
2
  export * from "./cfg/index";
3
+ export * from "./cvar/index";
4
+ export * from "./cvt/index";
6
5
  export * from "./extra-info-sink/index";
7
- export * from "./rectify/rectify";
6
+ export * from "./fpgm-prep/index";
8
7
  export * from "./glyf/shared";
8
+ export * from "./rectify/rectify";
9
9
  export declare namespace Loca {
10
10
  type Table = LocaTable;
11
11
  const Tag = "loca";
@@ -17,7 +17,7 @@ export declare namespace Loca {
17
17
  export declare namespace Glyf {
18
18
  const Tag = "glyf";
19
19
  const Read: import("@ot-builder/bin-util").Read<void, [loca: LocaTable, gOrd: import("@ot-builder/prelude/lib/data").Order<import("@ot-builder/ot-glyphs").OtGlyph>, coStat: import("@ot-builder/ot-glyphs/lib/ot-glyph/co-stat").Source]>;
20
- const Write: import("@ot-builder/bin-util").Write<import("@ot-builder/prelude/lib/data").Order<import("@ot-builder/ot-glyphs").OtGlyph>, [outLoca: LocaTable, stat: import("@ot-builder/ot-glyphs/lib/ot-glyph/stat").Sink, extraInfoSink: import("./extra-info-sink/index").TtfWritingExtraInfoSink]>;
20
+ const Write: import("@ot-builder/bin-util").Write<import("@ot-builder/prelude/lib/data").Order<import("@ot-builder/ot-glyphs").OtGlyph>, [cfg: import("./cfg/index").TtfCfg, outLoca: LocaTable, stat: import("@ot-builder/ot-glyphs/lib/ot-glyph/stat").Sink, extraInfoSink: import("./extra-info-sink/index").TtfWritingExtraInfoSink]>;
21
21
  }
22
22
  export declare namespace Gvar {
23
23
  const Tag = "gvar";
package/lib/index.js CHANGED
@@ -9,13 +9,13 @@ const write_1 = require("./glyf/write");
9
9
  const read_2 = require("./gvar/read");
10
10
  const shared_2 = require("./gvar/shared");
11
11
  const write_2 = require("./gvar/write");
12
- tslib_1.__exportStar(require("./cvt/index"), exports);
13
- tslib_1.__exportStar(require("./cvar/index"), exports);
14
- tslib_1.__exportStar(require("./fpgm-prep/index"), exports);
15
12
  tslib_1.__exportStar(require("./cfg/index"), exports);
13
+ tslib_1.__exportStar(require("./cvar/index"), exports);
14
+ tslib_1.__exportStar(require("./cvt/index"), exports);
16
15
  tslib_1.__exportStar(require("./extra-info-sink/index"), exports);
17
- tslib_1.__exportStar(require("./rectify/rectify"), exports);
16
+ tslib_1.__exportStar(require("./fpgm-prep/index"), exports);
18
17
  tslib_1.__exportStar(require("./glyf/shared"), exports);
18
+ tslib_1.__exportStar(require("./rectify/rectify"), exports);
19
19
  var Loca;
20
20
  (function (Loca) {
21
21
  Loca.Tag = loca_1.LocaTag;
@@ -1,4 +1,4 @@
1
1
  import { OtGlyph } from "@ot-builder/ot-glyphs";
2
- import { Data } from "@ot-builder/prelude";
2
+ import type { Data } from "@ot-builder/prelude";
3
3
  export declare function rectifyGlyphOrder(gOrd: Data.Order<OtGlyph>): void;
4
4
  //# sourceMappingURL=rectify.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ot-builder/io-bin-ttf",
3
3
  "description": "",
4
- "version": "1.7.8",
4
+ "version": "1.9.0",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -24,23 +24,23 @@
24
24
  "access": "public"
25
25
  },
26
26
  "dependencies": {
27
- "@ot-builder/bin-util": "1.7.8",
28
- "@ot-builder/common-impl": "1.7.7",
29
- "@ot-builder/errors": "1.7.7",
30
- "@ot-builder/ot-glyphs": "1.7.8",
31
- "@ot-builder/ot-metadata": "1.7.8",
32
- "@ot-builder/prelude": "1.7.7",
33
- "@ot-builder/primitive": "1.7.8",
34
- "@ot-builder/stat-glyphs": "1.7.8",
35
- "@ot-builder/var-store": "1.7.8",
36
- "@ot-builder/variance": "1.7.8",
27
+ "@ot-builder/bin-util": "1.8.0",
28
+ "@ot-builder/common-impl": "1.8.0",
29
+ "@ot-builder/errors": "1.8.0",
30
+ "@ot-builder/ot-glyphs": "1.8.0",
31
+ "@ot-builder/ot-metadata": "1.8.0",
32
+ "@ot-builder/prelude": "1.8.0",
33
+ "@ot-builder/primitive": "1.8.0",
34
+ "@ot-builder/stat-glyphs": "1.8.0",
35
+ "@ot-builder/var-store": "1.8.0",
36
+ "@ot-builder/variance": "1.8.0",
37
37
  "tslib": "^2.8.1"
38
38
  },
39
39
  "devDependencies": {
40
- "@ot-builder/ot-sfnt": "1.7.8",
41
- "@ot-builder/io-bin-metadata": "1.7.8",
42
- "@ot-builder/io-bin-sfnt": "1.7.8",
43
- "@ot-builder/test-util": "1.7.8",
40
+ "@ot-builder/ot-sfnt": "1.8.0",
41
+ "@ot-builder/io-bin-metadata": "1.8.0",
42
+ "@ot-builder/io-bin-sfnt": "1.8.0",
43
+ "@ot-builder/test-util": "1.8.0",
44
44
  "@types/jest": "^30.0.0",
45
45
  "jest": "^30.2.0"
46
46
  }