@ot-builder/rectify
Advanced tools
+52
-1
@@ -5,3 +5,54 @@ { | ||
| { | ||
| "date": "Sat, 11 Sep 2021 01:06:55 GMT", | ||
| "date": "Sat, 25 Sep 2021 01:06:38 GMT", | ||
| "tag": "@ot-builder/rectify_v1.1.2", | ||
| "version": "1.1.2", | ||
| "comments": { | ||
| "patch": [ | ||
| { | ||
| "author": "otbbuilder-dev@users.noreply.github.com", | ||
| "package": "@ot-builder/rectify", | ||
| "comment": "Improve rectification performance by removing unnecessary currying when rectify geometries", | ||
| "commit": "ef0cdbe0d09a64a7f2ed4f86c9158fa9d8fe699f" | ||
| }, | ||
| { | ||
| "author": "beachball", | ||
| "package": "@ot-builder/rectify", | ||
| "comment": "Bump @ot-builder/ot to v1.1.2", | ||
| "commit": "ef0cdbe0d09a64a7f2ed4f86c9158fa9d8fe699f" | ||
| }, | ||
| { | ||
| "author": "beachball", | ||
| "package": "@ot-builder/rectify", | ||
| "comment": "Bump @ot-builder/common-impl to v1.1.2", | ||
| "commit": "ef0cdbe0d09a64a7f2ed4f86c9158fa9d8fe699f" | ||
| }, | ||
| { | ||
| "author": "beachball", | ||
| "package": "@ot-builder/rectify", | ||
| "comment": "Bump @ot-builder/ot-glyphs to v1.1.2", | ||
| "commit": "ef0cdbe0d09a64a7f2ed4f86c9158fa9d8fe699f" | ||
| }, | ||
| { | ||
| "author": "beachball", | ||
| "package": "@ot-builder/rectify", | ||
| "comment": "Bump @ot-builder/ot-metadata to v1.1.2", | ||
| "commit": "ef0cdbe0d09a64a7f2ed4f86c9158fa9d8fe699f" | ||
| }, | ||
| { | ||
| "author": "beachball", | ||
| "package": "@ot-builder/rectify", | ||
| "comment": "Bump @ot-builder/prelude to v1.1.2", | ||
| "commit": "ef0cdbe0d09a64a7f2ed4f86c9158fa9d8fe699f" | ||
| }, | ||
| { | ||
| "author": "beachball", | ||
| "package": "@ot-builder/rectify", | ||
| "comment": "Bump @ot-builder/variance to v1.1.2", | ||
| "commit": "ef0cdbe0d09a64a7f2ed4f86c9158fa9d8fe699f" | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "date": "Sat, 11 Sep 2021 01:09:21 GMT", | ||
| "tag": "@ot-builder/rectify_v1.1.1", | ||
@@ -8,0 +59,0 @@ "version": "1.1.1", |
+16
-2
| # Change Log - @ot-builder/rectify | ||
| This log was last generated on Sat, 11 Sep 2021 01:06:55 GMT and should not be manually modified. | ||
| This log was last generated on Sat, 25 Sep 2021 01:06:38 GMT and should not be manually modified. | ||
| <!-- Start content --> | ||
| ## 1.1.2 | ||
| Sat, 25 Sep 2021 01:06:38 GMT | ||
| ### Patches | ||
| - Improve rectification performance by removing unnecessary currying when rectify geometries (otbbuilder-dev@users.noreply.github.com) | ||
| - Bump @ot-builder/ot to v1.1.2 | ||
| - Bump @ot-builder/common-impl to v1.1.2 | ||
| - Bump @ot-builder/ot-glyphs to v1.1.2 | ||
| - Bump @ot-builder/ot-metadata to v1.1.2 | ||
| - Bump @ot-builder/prelude to v1.1.2 | ||
| - Bump @ot-builder/variance to v1.1.2 | ||
| ## 1.1.1 | ||
| Sat, 11 Sep 2021 01:06:55 GMT | ||
| Sat, 11 Sep 2021 01:09:21 GMT | ||
@@ -11,0 +25,0 @@ ### Patches |
+0
-21
| import * as Ot from "@ot-builder/ot"; | ||
| import { Data } from "@ot-builder/prelude"; | ||
| import { CoordRectifier, GlyphReferenceRectifier, PointAttachmentRectifier } from "../interface"; | ||
| interface PointAttachmentGlobalState { | ||
| processed: Set<Ot.Glyph>; | ||
| } | ||
| interface PointAttachmentHandlerState { | ||
| points: Data.XY<Ot.Var.Value>[]; | ||
| } | ||
| declare type PointAttachmentHandler = (st: PointAttachmentHandlerState) => null | Ot.Glyph.Geometry; | ||
| export declare class OtGhRectifyGeomPointAttachmentAlg { | ||
| private readonly recGlyphRef; | ||
| private readonly recCoord; | ||
| private readonly recPA; | ||
| private readonly context; | ||
| constructor(recGlyphRef: GlyphReferenceRectifier, recCoord: CoordRectifier, recPA: PointAttachmentRectifier, context: PointAttachmentGlobalState); | ||
| process(geom: Ot.Glyph.Geometry): PointAttachmentHandler; | ||
| contourSet(cs: Ot.Glyph.ContourSetProps): (st: PointAttachmentHandlerState) => import("@ot-builder/prelude").CaseType<typeof Ot.Glyph.GeometryType.ContourSet, Ot.Glyph.ContourSetProps>; | ||
| geometryList(processes: PointAttachmentHandler[]): (st: PointAttachmentHandlerState) => import("@ot-builder/prelude").CaseType<typeof Ot.Glyph.GeometryType.GeometryList, Ot.Glyph.GeometryListProps>; | ||
| ttReference(ref: Ot.Glyph.TtReferenceProps): (st: PointAttachmentHandlerState) => import("@ot-builder/prelude").CaseType<typeof Ot.Glyph.GeometryType.TtReference, Ot.Glyph.TtReferenceProps> | null; | ||
| private processTtReferenceImpl; | ||
| } | ||
| export declare function inPlaceRectifyGlyphStore<GS extends Ot.GlyphStore>(recGlyphRef: GlyphReferenceRectifier, recCoord: CoordRectifier, recPA: PointAttachmentRectifier, glyphs: GS): void; | ||
| export {}; | ||
| //# sourceMappingURL=index.d.ts.map |
+79
-74
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.inPlaceRectifyGlyphStore = exports.OtGhRectifyGeomPointAttachmentAlg = void 0; | ||
| exports.inPlaceRectifyGlyphStore = void 0; | ||
| const Ot = require("@ot-builder/ot"); | ||
| const interface_1 = require("../interface"); | ||
| const shared_1 = require("../shared"); | ||
| class OtGhRectifyGeomPointAttachmentAlg { | ||
| constructor(recGlyphRef, recCoord, recPA, context) { | ||
| var TraverseProgress; | ||
| (function (TraverseProgress) { | ||
| TraverseProgress[TraverseProgress["PROCESSING"] = 1] = "PROCESSING"; | ||
| TraverseProgress[TraverseProgress["PROCESSED"] = 2] = "PROCESSED"; | ||
| })(TraverseProgress || (TraverseProgress = {})); | ||
| class GeometryProcessor { | ||
| constructor(recGlyphRef, recCoord, recPA, globalState) { | ||
| this.recGlyphRef = recGlyphRef; | ||
| this.recCoord = recCoord; | ||
| this.recPA = recPA; | ||
| this.context = context; | ||
| this.globalState = globalState; | ||
| } | ||
| process(geom) { | ||
| process(geom, st) { | ||
| switch (geom.type) { | ||
| case Ot.Glyph.GeometryType.ContourSet: | ||
| return this.contourSet(geom); | ||
| return this.processContourSet(geom, st); | ||
| case Ot.Glyph.GeometryType.GeometryList: | ||
| return this.geometryList(geom.items.map(item => this.process(item))); | ||
| return this.processGeometryList(geom.items, st); | ||
| case Ot.Glyph.GeometryType.TtReference: | ||
| return this.ttReference(geom); | ||
| return this.processTtReference(geom, st); | ||
| } | ||
| } | ||
| contourSet(cs) { | ||
| return (st) => { | ||
| const cs1 = []; | ||
| for (const c of cs.contours) { | ||
| const c1 = []; | ||
| for (let zid = 0; zid < c.length; zid++) { | ||
| const z = c[zid]; | ||
| c1[zid] = Ot.Glyph.Point.create(this.recCoord.coord(z.x), this.recCoord.coord(z.y), z.kind); | ||
| } | ||
| cs1.push(c1); | ||
| processContourSet(cs, st) { | ||
| const cs1 = []; | ||
| for (const c of cs.contours) { | ||
| const c1 = []; | ||
| for (let zid = 0; zid < c.length; zid++) { | ||
| const z = c[zid]; | ||
| c1[zid] = Ot.Glyph.Point.create(this.recCoord.coord(z.x), this.recCoord.coord(z.y), z.kind); | ||
| } | ||
| const g = new Ot.Glyph.ContourSet(cs1); | ||
| for (const c of g.contours) | ||
| for (const z of c) | ||
| st.points.push(z); | ||
| return g; | ||
| }; | ||
| cs1.push(c1); | ||
| } | ||
| const g = new Ot.Glyph.ContourSet(cs1); | ||
| for (const c of g.contours) | ||
| for (const z of c) | ||
| st.points.push(z); | ||
| return g; | ||
| } | ||
| geometryList(processes) { | ||
| return (st) => { | ||
| const children = []; | ||
| for (const proc of processes) { | ||
| const childGeom = proc(st); | ||
| if (childGeom) | ||
| children.push(childGeom); | ||
| } | ||
| return new Ot.Glyph.GeometryList(children); | ||
| }; | ||
| processGeometryList(items, st) { | ||
| const sink = []; | ||
| for (const item of items) { | ||
| const processed = this.process(item, st); | ||
| if (processed) | ||
| sink.push(processed); | ||
| } | ||
| if (sink.length) | ||
| return new Ot.Glyph.GeometryList(sink); | ||
| else | ||
| return null; | ||
| } | ||
| ttReference(ref) { | ||
| return (st) => { | ||
| const to1 = this.recGlyphRef.glyphRef(ref.to); | ||
| if (!to1) | ||
| return null; | ||
| processGlyph(this.recGlyphRef, this.recCoord, this.recPA, to1, this.context); | ||
| const ref1 = new Ot.Glyph.TtReference(to1, { | ||
| ...ref.transform, | ||
| dx: this.recCoord.coord(ref.transform.dx), | ||
| dy: this.recCoord.coord(ref.transform.dy) | ||
| }); | ||
| ref1.roundXyToGrid = ref.roundXyToGrid; | ||
| ref1.useMyMetrics = ref.useMyMetrics; | ||
| ref1.pointAttachment = ref.pointAttachment; | ||
| const innerPoints = shared_1.RectifyImpl.getGlyphPoints(to1); | ||
| this.processTtReferenceImpl(innerPoints, st, ref1); | ||
| for (const z of innerPoints) { | ||
| st.points.push(Ot.Glyph.PointOps.applyTransform(Ot.Glyph.Point.create(z.x, z.y), ref1.transform)); | ||
| } | ||
| return ref1; | ||
| }; | ||
| processTtReference(ref, st) { | ||
| const to1 = this.recGlyphRef.glyphRef(ref.to); | ||
| if (!to1) | ||
| return null; | ||
| processGlyph(this.recGlyphRef, this.recCoord, this.recPA, to1, this.globalState); | ||
| const ref1 = new Ot.Glyph.TtReference(to1, { | ||
| ...ref.transform, | ||
| dx: this.recCoord.coord(ref.transform.dx), | ||
| dy: this.recCoord.coord(ref.transform.dy) | ||
| }); | ||
| ref1.roundXyToGrid = ref.roundXyToGrid; | ||
| ref1.useMyMetrics = ref.useMyMetrics; | ||
| ref1.pointAttachment = ref.pointAttachment; | ||
| const innerPoints = shared_1.RectifyImpl.getGlyphPoints(to1); | ||
| this.processTtReferenceImpl(innerPoints, st, ref1); | ||
| for (const z of innerPoints) { | ||
| st.points.push(Ot.Glyph.PointOps.applyTransform(Ot.Glyph.Point.create(z.x, z.y), ref1.transform)); | ||
| } | ||
| return ref1; | ||
| } | ||
@@ -111,4 +113,3 @@ processTtReferenceImpl(innerPoints, st, ref1) { | ||
| } | ||
| exports.OtGhRectifyGeomPointAttachmentAlg = OtGhRectifyGeomPointAttachmentAlg; | ||
| class RectifyHintCoordAlg { | ||
| class HintProcessor { | ||
| constructor(rec) { | ||
@@ -120,28 +121,28 @@ this.rec = rec; | ||
| case Ot.Glyph.HintType.TtInstruction: | ||
| return this.ttInstructions(geom); | ||
| return this.processTtInstructions(geom); | ||
| case Ot.Glyph.HintType.CffHint: | ||
| return this.cffHint(geom); | ||
| return this.processCffHint(geom); | ||
| } | ||
| } | ||
| ttInstructions(tt) { | ||
| processTtInstructions(tt) { | ||
| return new Ot.Glyph.TtInstruction(tt.instructions); | ||
| } | ||
| cffHint(ch) { | ||
| processCffHint(ch) { | ||
| const stemHMap = new Map(); | ||
| const stemVMap = new Map(); | ||
| for (const s of ch.hStems) | ||
| stemHMap.set(s, this.rectifyHintStem(s)); | ||
| stemHMap.set(s, this.processHintStem(s)); | ||
| for (const s of ch.vStems) | ||
| stemVMap.set(s, this.rectifyHintStem(s)); | ||
| stemVMap.set(s, this.processHintStem(s)); | ||
| const h1 = new Ot.Glyph.CffHint(); | ||
| h1.hStems = [...stemHMap.values()]; | ||
| h1.vStems = [...stemVMap.values()]; | ||
| h1.hintMasks = ch.hintMasks.map(m => this.rectifyMask(m, stemHMap, stemVMap)); | ||
| h1.counterMasks = ch.counterMasks.map(m => this.rectifyMask(m, stemHMap, stemVMap)); | ||
| h1.hintMasks = ch.hintMasks.map(m => this.processMask(m, stemHMap, stemVMap)); | ||
| h1.counterMasks = ch.counterMasks.map(m => this.processMask(m, stemHMap, stemVMap)); | ||
| return h1; | ||
| } | ||
| rectifyHintStem(stem) { | ||
| processHintStem(stem) { | ||
| return Ot.Glyph.CffHint.createStem(this.rec.coord(stem.start), this.rec.coord(stem.end)); | ||
| } | ||
| rectifyMask(mask, stemHMap, stemVMap) { | ||
| processMask(mask, stemHMap, stemVMap) { | ||
| const maskH = new Set(); | ||
@@ -162,11 +163,15 @@ const maskV = new Set(); | ||
| } | ||
| function processGlyph(recGlyphRef, recCoord, recPA, glyph, gs) { | ||
| if (gs.processed.has(glyph)) | ||
| function processGlyph(recGlyphRef, recCoord, recPA, glyph, state) { | ||
| const preProgress = state.progress.get(glyph); | ||
| if (preProgress === TraverseProgress.PROCESSING) | ||
| throw new Error(`Circular reference found around glyph ${glyph.name}`); | ||
| if (preProgress === TraverseProgress.PROCESSED) | ||
| return; | ||
| state.progress.set(glyph, TraverseProgress.PROCESSING); | ||
| if (glyph.geometry) { | ||
| const alg = new OtGhRectifyGeomPointAttachmentAlg(recGlyphRef, recCoord, recPA, gs); | ||
| glyph.geometry = alg.process(glyph.geometry)({ points: [] }); | ||
| const alg = new GeometryProcessor(recGlyphRef, recCoord, recPA, state); | ||
| glyph.geometry = alg.process(glyph.geometry, { points: [] }); | ||
| } | ||
| if (glyph.hints) { | ||
| glyph.hints = new RectifyHintCoordAlg(recCoord).process(glyph.hints); | ||
| glyph.hints = new HintProcessor(recCoord).process(glyph.hints); | ||
| } | ||
@@ -181,7 +186,7 @@ glyph.horizontal = { | ||
| }; | ||
| gs.processed.add(glyph); | ||
| state.progress.set(glyph, TraverseProgress.PROCESSED); | ||
| } | ||
| function inPlaceRectifyGlyphStore(recGlyphRef, recCoord, recPA, glyphs) { | ||
| const gOrd = glyphs.decideOrder(); | ||
| const st = { processed: new Set() }; | ||
| const st = { progress: new Map() }; | ||
| for (const g of gOrd) | ||
@@ -188,0 +193,0 @@ processGlyph(recGlyphRef, recCoord, recPA, g, st); |
+7
-7
| { | ||
| "name": "@ot-builder/rectify", | ||
| "version": "1.1.1", | ||
| "version": "1.1.2", | ||
| "license": "MIT", | ||
@@ -26,8 +26,8 @@ "repository": { | ||
| "dependencies": { | ||
| "@ot-builder/ot": "1.1.1", | ||
| "@ot-builder/common-impl": "1.1.1", | ||
| "@ot-builder/ot-glyphs": "1.1.1", | ||
| "@ot-builder/ot-metadata": "1.1.1", | ||
| "@ot-builder/prelude": "1.1.1", | ||
| "@ot-builder/variance": "1.1.1", | ||
| "@ot-builder/ot": "1.1.2", | ||
| "@ot-builder/common-impl": "1.1.2", | ||
| "@ot-builder/ot-glyphs": "1.1.2", | ||
| "@ot-builder/ot-metadata": "1.1.2", | ||
| "@ot-builder/prelude": "1.1.2", | ||
| "@ot-builder/variance": "1.1.2", | ||
| "tslib": "^2.0.0" | ||
@@ -34,0 +34,0 @@ }, |
110766
1.13%2420
1.47%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated