@mark1russell7/typeset 0.1.3 → 0.1.4
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/build/chunks/font.d.ts.map +1 -1
- package/build/chunks/font.js +161 -136
- package/build/chunks/font.js.map +1 -1
- package/build/chunks/fonts.d.ts +1 -1
- package/build/chunks/fonts.d.ts.map +1 -1
- package/build/chunks/fonts.js +11 -10
- package/build/chunks/fonts.js.map +1 -1
- package/build/fonts-inspect.d.ts +5 -0
- package/build/fonts-inspect.d.ts.map +1 -1
- package/build/fonts-inspect.js +1 -1
- package/package.json +1 -1
- package/src/fonts/bound.ts +10 -7
- package/src/fonts/font.ts +10 -2
- package/src/fonts/indic.ts +8 -105
- package/src/fonts/normalize.ts +144 -0
- package/src/fonts-inspect.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font.d.ts","names":[],"sources":["../../src/fonts/substitution.ts","../../src/fonts/variations.ts","../../src/fonts/kerning.ts","../../src/fonts/font.ts"],"mappings":";;;;;cAQa;;;;;UA6CI;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;WAES;;;UAIM;;WAEN;;WAEA;;WAEA;;;UAIM;;WAEN;;WAEA;;WAEA;;WAEA;;;;;;EAMT,MAAM,kBAAkB,kBAAkB;;;;;;EAM1C,WAAW,kBAAkB,OAAO,aAAa,cAAc;;;;;EAK/D,WAAW;;;;;;EAMX,4BAA4B;;;UC3Gb;WACN;WACA;WACA;WACA;;;KAIC,WAAW,SAAS;;UCLf;WACN;WACA;;WAEA;;WAEA;;WAEA;;;UAIM;WACN;;;;;WAKA,QAAQ;;EAEjB,KAAK,eAAe,iBAAiB;;;;;EAKrC,QAAQ,QAAQ,sBAAsB;;;UAIvB;WACN;WACA;;;
|
|
1
|
+
{"version":3,"file":"font.d.ts","names":[],"sources":["../../src/fonts/substitution.ts","../../src/fonts/variations.ts","../../src/fonts/kerning.ts","../../src/fonts/font.ts"],"mappings":";;;;;cAQa;;;;;UA6CI;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;WAES;;;UAIM;;WAEN;;WAEA;;WAEA;;;UAIM;;WAEN;;WAEA;;WAEA;;WAEA;;;;;;EAMT,MAAM,kBAAkB,kBAAkB;;;;;;EAM1C,WAAW,kBAAkB,OAAO,aAAa,cAAc;;;;;EAK/D,WAAW;;;;;;EAMX,4BAA4B;;;UC3Gb;WACN;WACA;WACA;WACA;;;KAIC,WAAW,SAAS;;UCLf;WACN;WACA;;WAEA;;WAEA;;WAEA;;;UAIM;WACN;;;;;WAKA,QAAQ;;EAEjB,KAAK,eAAe,iBAAiB;;;;;EAKrC,QAAQ,QAAQ,sBAAsB;;;UAIvB;WACN;WACA;;;UCvBM;;WAEN,aAAa;;;;;WAKb,WAAW;;;;;WAKX;;;;;WAKA;;;;;WAKA;;;KAIC;;UAGK;;;;;WAKN;WACA;;WAEA,eAAe;;WAEf,UAAU;;WAEV;;WAEA,eAAe;WACf;;EAET,MAAM;;EAEN,QAAQ;;EAER,WAAW;;EAEX,QAAQ,0BAA0B;;EAElC,cAAc,gBAAgB,uCAAuC;;EAErE,GAAG,UAAU,WAAW;;;iBAIV,SAAS,OAAO,YAAY,UAAS,cAAmB;;UA8JvD;;WAEN;;;;;WAKA;;WAEA;;;;;;WAMA;;;;;;WAMA;;;;;WAKA;;;;;WAKA;;;;;WAKA;;;;;;iBAYK,aAAa;;;;;;;iBAuEb,cAAc,MAAM,MAAM,cAAc,UAAS;EAAwB;EAAkB;;;;;;iBAkG3F,aAAa,MAAM,MAAM,cAAc,cAAc,UAAS"}
|
package/build/chunks/font.js
CHANGED
|
@@ -1194,7 +1194,7 @@ function readAxes(fvar) {
|
|
|
1194
1194
|
* This function gives the normalized coordinates of an instance. Each coordinate is in -1 to 1, on the 2.14 grid. The
|
|
1195
1195
|
* segment maps of `avar` change it when the font has them. A value outside the range of an axis is clamped to the range.
|
|
1196
1196
|
*/
|
|
1197
|
-
function normalize
|
|
1197
|
+
function normalize(axes, avar, instance) {
|
|
1198
1198
|
const coordinates = axes.map((axis) => {
|
|
1199
1199
|
const value = Math.min(axis.max, Math.max(axis.min, instance[axis.tag] ?? axis.default));
|
|
1200
1200
|
if (value < axis.default) return toF2dot14(axis.default === axis.min ? 0 : (value - axis.default) / (axis.default - axis.min));
|
|
@@ -1521,6 +1521,144 @@ function gvarAdvanceDeltas(gvar, pointCounts, coordinates, deltas) {
|
|
|
1521
1521
|
}
|
|
1522
1522
|
return result;
|
|
1523
1523
|
}
|
|
1524
|
+
// src/fonts/normalize.ts
|
|
1525
|
+
/**
|
|
1526
|
+
* The Unicode normalization of HarfBuzz, from `hb-ot-shape-normalize.cc`. HarfBuzz decomposes each cluster of a base and its marks.
|
|
1527
|
+
* It then sorts the marks, and composes each mark with its base when the font has the glyph of the composite.
|
|
1528
|
+
*/
|
|
1529
|
+
const unicodeMark = /\p{M}/u;
|
|
1530
|
+
/**
|
|
1531
|
+
* The classes of HarfBuzz for the marks of Hebrew and Arabic, from `hb-unicode.hh`. Their order is not the canonical order:
|
|
1532
|
+
* for example the shadda comes first. Each other pair of marks uses the canonical order.
|
|
1533
|
+
*/
|
|
1534
|
+
const sortClasses = /* @__PURE__ */ new Map([
|
|
1535
|
+
[1456, 22],
|
|
1536
|
+
[1457, 15],
|
|
1537
|
+
[1458, 16],
|
|
1538
|
+
[1459, 17],
|
|
1539
|
+
[1460, 23],
|
|
1540
|
+
[1461, 18],
|
|
1541
|
+
[1462, 19],
|
|
1542
|
+
[1463, 20],
|
|
1543
|
+
[1464, 21],
|
|
1544
|
+
[1465, 14],
|
|
1545
|
+
[1466, 14],
|
|
1546
|
+
[1467, 24],
|
|
1547
|
+
[1468, 12],
|
|
1548
|
+
[1469, 25],
|
|
1549
|
+
[1471, 13],
|
|
1550
|
+
[1473, 10],
|
|
1551
|
+
[1474, 11],
|
|
1552
|
+
[1479, 21],
|
|
1553
|
+
[64286, 26],
|
|
1554
|
+
[1560, 31],
|
|
1555
|
+
[1561, 32],
|
|
1556
|
+
[1562, 33],
|
|
1557
|
+
[1611, 28],
|
|
1558
|
+
[1612, 29],
|
|
1559
|
+
[1613, 30],
|
|
1560
|
+
[1614, 31],
|
|
1561
|
+
[1615, 32],
|
|
1562
|
+
[1616, 33],
|
|
1563
|
+
[1617, 27],
|
|
1564
|
+
[1618, 34],
|
|
1565
|
+
[1648, 35],
|
|
1566
|
+
[2288, 28],
|
|
1567
|
+
[2289, 29],
|
|
1568
|
+
[2290, 30]
|
|
1569
|
+
]);
|
|
1570
|
+
/** This function tells if a code point is a mark of Unicode. The first mark of Unicode is U+0300. */
|
|
1571
|
+
function isMark(codePoint) {
|
|
1572
|
+
return codePoint >= 768 && unicodeMark.test(String.fromCodePoint(codePoint));
|
|
1573
|
+
}
|
|
1574
|
+
/** This function tells if a text has a mark of Unicode. */
|
|
1575
|
+
function hasMark(text) {
|
|
1576
|
+
return unicodeMark.test(text);
|
|
1577
|
+
}
|
|
1578
|
+
function decomposed(codePoint) {
|
|
1579
|
+
return String.fromCodePoint(codePoint).normalize("NFD");
|
|
1580
|
+
}
|
|
1581
|
+
/**
|
|
1582
|
+
* This function tells if the mark `second` sorts before the mark `first`. That is true when the class of `first` is larger
|
|
1583
|
+
* than the class of `second`, and neither class is 0. The form NFD of JavaScript gives the canonical order, so no table is needed.
|
|
1584
|
+
*/
|
|
1585
|
+
function reorders(first, second) {
|
|
1586
|
+
const firstClass = sortClasses.get(first);
|
|
1587
|
+
const secondClass = sortClasses.get(second);
|
|
1588
|
+
if (firstClass !== void 0 && secondClass !== void 0) return firstClass > secondClass;
|
|
1589
|
+
const text = decomposed(first) + decomposed(second);
|
|
1590
|
+
return text.normalize("NFD") !== text;
|
|
1591
|
+
}
|
|
1592
|
+
/** This function tells if a code point has the combining class 0. U+0345 has the largest class of Unicode. */
|
|
1593
|
+
function isStarter(codePoint) {
|
|
1594
|
+
return !isMark(codePoint) || codePoint !== 837 && !reorders(837, codePoint);
|
|
1595
|
+
}
|
|
1596
|
+
/** This function gives the canonical composite of two code points, or `undefined`. A mark does not compose with a mark. */
|
|
1597
|
+
function compose(first, second) {
|
|
1598
|
+
if (isMark(first)) return void 0;
|
|
1599
|
+
const [single, ...rest] = [...String.fromCodePoint(first, second).normalize("NFC")];
|
|
1600
|
+
return rest.length === 0 && single !== void 0 ? single.codePointAt(0) : void 0;
|
|
1601
|
+
}
|
|
1602
|
+
/**
|
|
1603
|
+
* This function gives the code points of a character after the decomposition. A character keeps its form when the font has
|
|
1604
|
+
* no glyph for one of its parts, or when the set `kept` has the character.
|
|
1605
|
+
*/
|
|
1606
|
+
function decomposition(codePoint, hasGlyph, kept) {
|
|
1607
|
+
const parts = kept.has(codePoint) ? [codePoint] : Array.from(decomposed(codePoint), (part) => part.codePointAt(0));
|
|
1608
|
+
return (parts.length > 1 || parts[0] !== codePoint) && parts.every(hasGlyph) ? parts : [codePoint];
|
|
1609
|
+
}
|
|
1610
|
+
/**
|
|
1611
|
+
* This function normalizes code points as HarfBuzz does. It decomposes the characters by `rules`. A text with a mark after
|
|
1612
|
+
* its first character then gets more steps. The function sorts the marks, and composes each mark with its starter again
|
|
1613
|
+
* when the font has the glyph of the composite. A mark between them with the same class or a larger class blocks this.
|
|
1614
|
+
*/
|
|
1615
|
+
function normalizeCodePoints(codePoints, rules) {
|
|
1616
|
+
const { hasGlyph, shortCircuit, kept = /* @__PURE__ */ new Set() } = rules;
|
|
1617
|
+
const marked = codePoints.map(isMark);
|
|
1618
|
+
const parts = codePoints.flatMap((codePoint, i) => {
|
|
1619
|
+
const simple = marked[i + 1] !== true && !(i > 0 && marked[i]);
|
|
1620
|
+
return shortCircuit && simple && hasGlyph(codePoint) ? [codePoint] : decomposition(codePoint, hasGlyph, kept);
|
|
1621
|
+
});
|
|
1622
|
+
if (!marked.slice(1).includes(true)) return parts;
|
|
1623
|
+
for (let i = 1; i < parts.length; i++) for (let j = i; j > 0 && isMark(parts[j - 1]) && isMark(parts[j]) && reorders(parts[j - 1], parts[j]); j--) [parts[j - 1], parts[j]] = [parts[j], parts[j - 1]];
|
|
1624
|
+
const out = parts.slice(0, 1);
|
|
1625
|
+
let starter = 0;
|
|
1626
|
+
for (let i = 1; i < parts.length; i++) {
|
|
1627
|
+
const codePoint = parts[i];
|
|
1628
|
+
if (isMark(codePoint) && (starter === out.length - 1 || reorders(codePoint, out[out.length - 1]))) {
|
|
1629
|
+
const composed = compose(out[starter], codePoint);
|
|
1630
|
+
if (composed !== void 0 && hasGlyph(composed)) {
|
|
1631
|
+
out[starter] = composed;
|
|
1632
|
+
continue;
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
out.push(codePoint);
|
|
1636
|
+
if (isStarter(codePoint)) starter = out.length - 1;
|
|
1637
|
+
}
|
|
1638
|
+
return out;
|
|
1639
|
+
}
|
|
1640
|
+
/** This function gives the forms of a set of characters. It repeats the compositions until the set of code points is stable. */
|
|
1641
|
+
function normalForms(characters, hasGlyph, kept = /* @__PURE__ */ new Set()) {
|
|
1642
|
+
const parts = new Map([...characters].map((codePoint) => [codePoint, decomposition(codePoint, hasGlyph, kept)]));
|
|
1643
|
+
const codePoints = /* @__PURE__ */ new Set([...characters, ...[...parts.values()].flat()]);
|
|
1644
|
+
const composites = /* @__PURE__ */ new Map();
|
|
1645
|
+
for (let size = 0; size !== codePoints.size;) {
|
|
1646
|
+
size = codePoints.size;
|
|
1647
|
+
const marks = [...codePoints].filter(isMark);
|
|
1648
|
+
for (const starter of codePoints) for (const mark of marks) {
|
|
1649
|
+
const composed = compose(starter, mark);
|
|
1650
|
+
if (composed === void 0 || !hasGlyph(composed)) continue;
|
|
1651
|
+
const known = composites.get(starter) ?? [];
|
|
1652
|
+
if (!known.includes(composed)) composites.set(starter, [...known, composed]);
|
|
1653
|
+
codePoints.add(composed);
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
return {
|
|
1657
|
+
parts,
|
|
1658
|
+
composites,
|
|
1659
|
+
codePoints
|
|
1660
|
+
};
|
|
1661
|
+
}
|
|
1524
1662
|
// src/fonts/indic.ts
|
|
1525
1663
|
/** The OpenType script tags that use the Indic shaper in this model. */
|
|
1526
1664
|
const indicScripts = ["deva"];
|
|
@@ -1775,70 +1913,8 @@ function indicProperties(codePoint) {
|
|
|
1775
1913
|
}
|
|
1776
1914
|
return [X, END];
|
|
1777
1915
|
}
|
|
1778
|
-
/**
|
|
1779
|
-
* The canonical combining classes of the marks of the Devanagari blocks that are not 0. The normalization uses them to
|
|
1780
|
-
* sort the marks and to block a composition. A mark of another block has the class 0 in this model.
|
|
1781
|
-
*/
|
|
1782
|
-
const combiningClasses = [
|
|
1783
|
-
2364,
|
|
1784
|
-
2364,
|
|
1785
|
-
7,
|
|
1786
|
-
2381,
|
|
1787
|
-
2381,
|
|
1788
|
-
9,
|
|
1789
|
-
2385,
|
|
1790
|
-
2385,
|
|
1791
|
-
230,
|
|
1792
|
-
2386,
|
|
1793
|
-
2386,
|
|
1794
|
-
220,
|
|
1795
|
-
2387,
|
|
1796
|
-
2388,
|
|
1797
|
-
230,
|
|
1798
|
-
7376,
|
|
1799
|
-
7378,
|
|
1800
|
-
230,
|
|
1801
|
-
7380,
|
|
1802
|
-
7380,
|
|
1803
|
-
1,
|
|
1804
|
-
7381,
|
|
1805
|
-
7385,
|
|
1806
|
-
220,
|
|
1807
|
-
7386,
|
|
1808
|
-
7387,
|
|
1809
|
-
230,
|
|
1810
|
-
7388,
|
|
1811
|
-
7391,
|
|
1812
|
-
220,
|
|
1813
|
-
7392,
|
|
1814
|
-
7392,
|
|
1815
|
-
230,
|
|
1816
|
-
7394,
|
|
1817
|
-
7400,
|
|
1818
|
-
1,
|
|
1819
|
-
7405,
|
|
1820
|
-
7405,
|
|
1821
|
-
220,
|
|
1822
|
-
7412,
|
|
1823
|
-
7412,
|
|
1824
|
-
230,
|
|
1825
|
-
7416,
|
|
1826
|
-
7417,
|
|
1827
|
-
230,
|
|
1828
|
-
43232,
|
|
1829
|
-
43249,
|
|
1830
|
-
230
|
|
1831
|
-
];
|
|
1832
|
-
function combiningClass(codePoint) {
|
|
1833
|
-
for (let i = 0; i < combiningClasses.length; i += 3) if (codePoint >= combiningClasses[i] && codePoint <= combiningClasses[i + 1]) return combiningClasses[i + 2];
|
|
1834
|
-
return 0;
|
|
1835
|
-
}
|
|
1836
|
-
const unicodeMark = /\p{M}/u;
|
|
1837
1916
|
/** The general categories from `FORMAT` to `NON_SPACING_MARK` of HarfBuzz: a letter, a mark, or a format or other code point. */
|
|
1838
1917
|
const letterOrMark = /[\p{L}\p{M}\p{Cf}\p{Cn}\p{Co}\p{Cs}]/u;
|
|
1839
|
-
function isMark(codePoint) {
|
|
1840
|
-
return unicodeMark.test(String.fromCodePoint(codePoint));
|
|
1841
|
-
}
|
|
1842
1918
|
/**
|
|
1843
1919
|
* This function inserts a dotted circle in each vowel sequence of Devanagari that looks like another vowel, as
|
|
1844
1920
|
* `_hb_preprocess_text_vowel_constraints` does.
|
|
@@ -1887,75 +1963,11 @@ function vowelConstraints(codePoints) {
|
|
|
1887
1963
|
while (i < codePoints.length) out.push(codePoints[i++]);
|
|
1888
1964
|
return out;
|
|
1889
1965
|
}
|
|
1890
|
-
/**
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
* U+0931 does not decompose. A text with a mark after its first character then gets more steps. The function sorts the
|
|
1894
|
-
* marks, and composes each mark with its starter again when the font has the glyph of the composite.
|
|
1895
|
-
*/
|
|
1896
|
-
function normalize(codePoints, hasGlyph) {
|
|
1897
|
-
const allSimple = !codePoints.some((codePoint, i) => i > 0 && isMark(codePoint));
|
|
1898
|
-
const decomposed = codePoints.flatMap((codePoint) => decomposition(codePoint, hasGlyph));
|
|
1899
|
-
if (allSimple) return decomposed;
|
|
1900
|
-
for (let i = 1; i < decomposed.length; i++) for (let j = i; j > 0; j--) {
|
|
1901
|
-
const before = combiningClass(decomposed[j - 1]);
|
|
1902
|
-
const after = combiningClass(decomposed[j]);
|
|
1903
|
-
if (after === 0 || before <= after) break;
|
|
1904
|
-
[decomposed[j - 1], decomposed[j]] = [decomposed[j], decomposed[j - 1]];
|
|
1905
|
-
}
|
|
1906
|
-
const out = decomposed.slice(0, 1);
|
|
1907
|
-
let starter = 0;
|
|
1908
|
-
for (let i = 1; i < decomposed.length; i++) {
|
|
1909
|
-
const codePoint = decomposed[i];
|
|
1910
|
-
if (isMark(codePoint) && (starter === out.length - 1 || combiningClass(out[out.length - 1]) < combiningClass(codePoint))) {
|
|
1911
|
-
const composed = compose(out[starter], codePoint);
|
|
1912
|
-
if (composed !== void 0 && hasGlyph(composed)) {
|
|
1913
|
-
out[starter] = composed;
|
|
1914
|
-
continue;
|
|
1915
|
-
}
|
|
1916
|
-
}
|
|
1917
|
-
out.push(codePoint);
|
|
1918
|
-
if (combiningClass(codePoint) === 0) starter = out.length - 1;
|
|
1919
|
-
}
|
|
1920
|
-
return out;
|
|
1921
|
-
}
|
|
1922
|
-
/** This function gives the code points of a character after the decomposition of `normalize`. */
|
|
1923
|
-
function decomposition(codePoint, hasGlyph) {
|
|
1924
|
-
const parts = codePoint === 2353 ? [codePoint] : [...String.fromCodePoint(codePoint).normalize("NFD")].map((part) => part.codePointAt(0));
|
|
1925
|
-
return (parts.length > 1 || parts[0] !== codePoint) && parts.every(hasGlyph) ? parts : [codePoint];
|
|
1926
|
-
}
|
|
1927
|
-
/**
|
|
1928
|
-
* This function gives the code points that the normalization can give for the characters `characters`. A composite is
|
|
1929
|
-
* not always in the set: a nukta that follows U+0928 gives U+0929. The function repeats until no new composite appears.
|
|
1930
|
-
*/
|
|
1966
|
+
/** The code points of Devanagari that do not decompose. */
|
|
1967
|
+
const kept = /* @__PURE__ */ new Set([2353]);
|
|
1968
|
+
/** This function gives the code points that `normalizeCodePoints` and `vowelConstraints` can give for a set of characters. */
|
|
1931
1969
|
function indicForms(characters, hasGlyph) {
|
|
1932
|
-
|
|
1933
|
-
const codePoints = new Set([...parts.values()].flat());
|
|
1934
|
-
for (const codePoint of characters) codePoints.add(codePoint);
|
|
1935
|
-
codePoints.add(9676);
|
|
1936
|
-
const composites = /* @__PURE__ */ new Map();
|
|
1937
|
-
for (let size = 0; size !== codePoints.size;) {
|
|
1938
|
-
size = codePoints.size;
|
|
1939
|
-
const marks = [...codePoints].filter(isMark);
|
|
1940
|
-
for (const starter of codePoints) for (const mark of marks) {
|
|
1941
|
-
const composed = compose(starter, mark);
|
|
1942
|
-
if (composed === void 0 || !hasGlyph(composed)) continue;
|
|
1943
|
-
const known = composites.get(starter) ?? [];
|
|
1944
|
-
if (!known.includes(composed)) composites.set(starter, [...known, composed]);
|
|
1945
|
-
codePoints.add(composed);
|
|
1946
|
-
}
|
|
1947
|
-
}
|
|
1948
|
-
return {
|
|
1949
|
-
parts,
|
|
1950
|
-
composites,
|
|
1951
|
-
codePoints
|
|
1952
|
-
};
|
|
1953
|
-
}
|
|
1954
|
-
/** This function gives the canonical composite of two code points, or `undefined`. A mark does not compose with a mark. */
|
|
1955
|
-
function compose(first, second) {
|
|
1956
|
-
if (isMark(first)) return void 0;
|
|
1957
|
-
const [single, ...rest] = [...[(String.fromCodePoint(first) + String.fromCodePoint(second)).normalize("NFC")][0]];
|
|
1958
|
-
return rest.length === 0 && single !== void 0 ? single.codePointAt(0) : void 0;
|
|
1970
|
+
return normalForms(/* @__PURE__ */ new Set([...characters, 9676]), hasGlyph, kept);
|
|
1959
1971
|
}
|
|
1960
1972
|
const letters = /* @__PURE__ */ new Map([
|
|
1961
1973
|
[X, "x"],
|
|
@@ -2349,7 +2361,11 @@ function indicShaper(font, script, features) {
|
|
|
2349
2361
|
if (infos[start].position === PRE_M && (start === 0 || !letterOrMark.test(String.fromCodePoint(infos[start - 1].codePoint)))) infos[start].mask |= initMask;
|
|
2350
2362
|
};
|
|
2351
2363
|
return (word) => {
|
|
2352
|
-
const codePoints =
|
|
2364
|
+
const codePoints = normalizeCodePoints(vowelConstraints([...word].map((character) => character.codePointAt(0))), {
|
|
2365
|
+
hasGlyph: (codePoint) => font.glyph(codePoint) !== 0,
|
|
2366
|
+
shortCircuit: false,
|
|
2367
|
+
kept
|
|
2368
|
+
});
|
|
2353
2369
|
const run = {
|
|
2354
2370
|
glyphs: codePoints.map((codePoint) => font.glyph(codePoint)),
|
|
2355
2371
|
infos: []
|
|
@@ -3502,7 +3518,7 @@ function build(parsed, requested, modes) {
|
|
|
3502
3518
|
const { tables, header, characters, glyphClass, axes } = parsed;
|
|
3503
3519
|
const { deltas } = modes;
|
|
3504
3520
|
const instance = Object.fromEntries(axes.map((axis) => [axis.tag, Math.min(axis.max, Math.max(axis.min, requested[axis.tag] ?? axis.default))]));
|
|
3505
|
-
const coordinates = normalize
|
|
3521
|
+
const coordinates = normalize(axes, tables.get("avar"), instance);
|
|
3506
3522
|
const variable = coordinates.some((value) => value !== 0);
|
|
3507
3523
|
const hvar = tables.get("HVAR");
|
|
3508
3524
|
const gvar = tables.get("gvar");
|
|
@@ -3645,9 +3661,18 @@ function shaperOf(font, options) {
|
|
|
3645
3661
|
stage,
|
|
3646
3662
|
lookups: font.substitutions(script, stage.features)
|
|
3647
3663
|
})) : [];
|
|
3664
|
+
const normalizes = script !== "hang";
|
|
3665
|
+
const rules = {
|
|
3666
|
+
hasGlyph: (codePoint) => font.glyph(codePoint) !== 0,
|
|
3667
|
+
shortCircuit: true
|
|
3668
|
+
};
|
|
3648
3669
|
const substitute = (word) => {
|
|
3649
|
-
|
|
3650
|
-
|
|
3670
|
+
let codePoints = [...word].map((character) => character.codePointAt(0));
|
|
3671
|
+
let wordGlyphs = codePoints.map((codePoint) => font.glyph(codePoint));
|
|
3672
|
+
if (normalizes && (hasMark(word) || wordGlyphs.includes(0))) {
|
|
3673
|
+
codePoints = normalizeCodePoints(codePoints, rules);
|
|
3674
|
+
wordGlyphs = codePoints.map((codePoint) => font.glyph(codePoint));
|
|
3675
|
+
}
|
|
3651
3676
|
for (const lookup of lookups) lookup.apply(wordGlyphs);
|
|
3652
3677
|
if (joins) {
|
|
3653
3678
|
const masks = joiningForms(codePoints).map((form) => 128 | (form === void 0 ? 0 : 1 << joiningFeatures.indexOf(form)));
|
|
@@ -3774,6 +3799,6 @@ function measureWidth(font, text, size, options = {}) {
|
|
|
3774
3799
|
for (const advance of advances) units += advance;
|
|
3775
3800
|
return units * size / font.unitsPerEm;
|
|
3776
3801
|
}
|
|
3777
|
-
export { shapingWords as a,
|
|
3802
|
+
export { shapingWords as a, joiningStages as c, normalForms as d, defaultFeatures as f, shapingOf as i, indicFeatures as l, measureWidth as n, canvasSegments as o, readTables as p, readFont as r, canvasWords as s, glyphAdvances as t, indicForms as u };
|
|
3778
3803
|
|
|
3779
3804
|
//# sourceMappingURL=font.js.map
|