pa_font 0.2.6 → 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.
- package/dist/paFont.cjs +14 -14
- package/dist/paFont.cjs.map +1 -1
- package/dist/paFont.js +14 -14
- package/dist/paFont.js.map +1 -1
- package/package.json +1 -1
package/dist/paFont.js
CHANGED
|
@@ -233,7 +233,7 @@ function translateRect(rect, tx, ty) {
|
|
|
233
233
|
h: rect.h
|
|
234
234
|
};
|
|
235
235
|
}
|
|
236
|
-
function copyRing
|
|
236
|
+
function copyRing(ring) {
|
|
237
237
|
const len = ring.length;
|
|
238
238
|
const result = new Array(len);
|
|
239
239
|
for (let i = 0; i < len; i++) result[i] = [ring[i][0], ring[i][1]];
|
|
@@ -962,8 +962,8 @@ function createDerivedShape(shape, parts) {
|
|
|
962
962
|
}
|
|
963
963
|
function createRegionCollection(shape) {
|
|
964
964
|
return shape.parts.map((part) => ({
|
|
965
|
-
outer: copyRing
|
|
966
|
-
holes: part.holes.map((hole) => copyRing
|
|
965
|
+
outer: copyRing(part.outer),
|
|
966
|
+
holes: part.holes.map((hole) => copyRing(hole)),
|
|
967
967
|
bbox: { ...part.bbox }
|
|
968
968
|
}));
|
|
969
969
|
}
|
|
@@ -973,8 +973,8 @@ function copyParts(parts) {
|
|
|
973
973
|
function copyPart(part) {
|
|
974
974
|
return {
|
|
975
975
|
...part,
|
|
976
|
-
outer: copyRing
|
|
977
|
-
holes: part.holes.map((hole) => copyRing
|
|
976
|
+
outer: copyRing(part.outer),
|
|
977
|
+
holes: part.holes.map((hole) => copyRing(hole)),
|
|
978
978
|
anchors: part.anchors ? part.anchors.map((point) => [point[0], point[1]]) : void 0,
|
|
979
979
|
bbox: { ...part.bbox }
|
|
980
980
|
};
|
|
@@ -983,7 +983,7 @@ function copyContours(contours) {
|
|
|
983
983
|
return contours.map((contour) => ({
|
|
984
984
|
...contour,
|
|
985
985
|
bbox: { ...contour.bbox },
|
|
986
|
-
ring: copyRing
|
|
986
|
+
ring: copyRing(contour.ring)
|
|
987
987
|
}));
|
|
988
988
|
}
|
|
989
989
|
function groupPartsByGlyphPosition(parts) {
|
|
@@ -1099,8 +1099,8 @@ function resolveGeometryEpsilon(width) {
|
|
|
1099
1099
|
}
|
|
1100
1100
|
function openPartWithSlit(part, width, epsilon) {
|
|
1101
1101
|
if (!part.holes || part.holes.length === 0) return copyPart(part);
|
|
1102
|
-
let outer = copyRing
|
|
1103
|
-
const holes = part.holes.map((hole) => copyRing
|
|
1102
|
+
let outer = copyRing(part.outer);
|
|
1103
|
+
const holes = part.holes.map((hole) => copyRing(hole));
|
|
1104
1104
|
const anchors = [];
|
|
1105
1105
|
const blockers = [];
|
|
1106
1106
|
while (holes.length > 0) {
|
|
@@ -1327,7 +1327,7 @@ function normalizeCutLocation(name, ring, cut, epsilon) {
|
|
|
1327
1327
|
};
|
|
1328
1328
|
}
|
|
1329
1329
|
function ringPath(ring, startIndex, endIndex) {
|
|
1330
|
-
if (startIndex == null || endIndex == null) return copyRing
|
|
1330
|
+
if (startIndex == null || endIndex == null) return copyRing(ring);
|
|
1331
1331
|
const path = [ring[startIndex]];
|
|
1332
1332
|
let cursor = startIndex;
|
|
1333
1333
|
while (cursor !== endIndex) {
|
|
@@ -1342,7 +1342,7 @@ function appendPath(target, path, epsilon) {
|
|
|
1342
1342
|
});
|
|
1343
1343
|
}
|
|
1344
1344
|
function resampleRing(ring, step, anchors = []) {
|
|
1345
|
-
if (ring.length < 3) return copyRing
|
|
1345
|
+
if (ring.length < 3) return copyRing(ring);
|
|
1346
1346
|
const normalizedAnchors = normalizeAnchorPoints(ring, anchors);
|
|
1347
1347
|
if (normalizedAnchors.length >= 2) return resampleRingWithAnchors(ring, step, normalizedAnchors);
|
|
1348
1348
|
return resampleClosedPath(ring, step);
|
|
@@ -1363,21 +1363,21 @@ function resampleRingWithAnchors(ring, step, anchorIndices) {
|
|
|
1363
1363
|
appendPath(result, resampleOpenPath(ringPath(ring, startIndex, endIndex), step), 1e-6);
|
|
1364
1364
|
}
|
|
1365
1365
|
if (result.length > 1 && pointsAlmostEqual2D(result[0], result[result.length - 1], 1e-6)) result.pop();
|
|
1366
|
-
if (result.length < 3 || result.length >= ring.length) return copyRing
|
|
1366
|
+
if (result.length < 3 || result.length >= ring.length) return copyRing(ring);
|
|
1367
1367
|
return result;
|
|
1368
1368
|
}
|
|
1369
1369
|
function resampleClosedPath(ring, step) {
|
|
1370
1370
|
const cumulative = buildCumulativeDistances(ring);
|
|
1371
1371
|
const perimeter = cumulative[ring.length];
|
|
1372
|
-
if (perimeter <= 1e-9) return copyRing
|
|
1372
|
+
if (perimeter <= 1e-9) return copyRing(ring);
|
|
1373
1373
|
const pointCount = Math.max(3, Math.round(perimeter / step));
|
|
1374
|
-
if (pointCount >= ring.length) return copyRing
|
|
1374
|
+
if (pointCount >= ring.length) return copyRing(ring);
|
|
1375
1375
|
const sampled = [];
|
|
1376
1376
|
for (let index = 0; index < pointCount; index++) {
|
|
1377
1377
|
const point = pointAtClosedPathDistanceFast(ring, cumulative, perimeter * index / pointCount);
|
|
1378
1378
|
if (sampled.length === 0 || !pointsAlmostEqual2D(sampled[sampled.length - 1], point, 1e-6)) sampled.push(point);
|
|
1379
1379
|
}
|
|
1380
|
-
if (sampled.length < 3 || sampled.length >= ring.length) return copyRing
|
|
1380
|
+
if (sampled.length < 3 || sampled.length >= ring.length) return copyRing(ring);
|
|
1381
1381
|
return sampled;
|
|
1382
1382
|
}
|
|
1383
1383
|
function resampleOpenPath(path, step) {
|