@weasel-js/font 1.14.1 → 1.15.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/dist/{chunk-EQD3U7KB.js → chunk-SP6N5MJQ.js} +32 -62
- package/dist/chunk-SP6N5MJQ.js.map +1 -0
- package/dist/index.d.ts +60 -11
- package/dist/index.js +60 -9
- package/dist/index.js.map +1 -1
- package/dist/{test-seams-BZPEYFPZ.d.ts → test-seams-BIu4iq6A.d.ts} +7 -1
- package/dist/test-seams.d.ts +1 -1
- package/dist/test-seams.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-EQD3U7KB.js.map +0 -1
|
@@ -1357,6 +1357,23 @@ function variantKey(weight, style) {
|
|
|
1357
1357
|
}
|
|
1358
1358
|
return key;
|
|
1359
1359
|
}
|
|
1360
|
+
|
|
1361
|
+
// src/atlasResult.ts
|
|
1362
|
+
function atlasResult(entry, family, weight, style, bold, italic) {
|
|
1363
|
+
return { entry, resolved: { family, weight, style }, synthetic: { bold, italic }, source: "atlas" };
|
|
1364
|
+
}
|
|
1365
|
+
var exactResults = /* @__PURE__ */ new WeakMap();
|
|
1366
|
+
function sharedExactResult(entry, family, weight, style) {
|
|
1367
|
+
const hit = exactResults.get(entry);
|
|
1368
|
+
if (hit !== void 0 && hit.resolved.family === family && hit.resolved.weight === weight && hit.resolved.style === style) return hit;
|
|
1369
|
+
const r = atlasResult(entry, family, weight, style, false, false);
|
|
1370
|
+
Object.freeze(r.resolved);
|
|
1371
|
+
Object.freeze(r.synthetic);
|
|
1372
|
+
exactResults.set(entry, Object.freeze(r));
|
|
1373
|
+
return r;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
// src/registerFont.ts
|
|
1360
1377
|
var registry = createReflectable();
|
|
1361
1378
|
var fontRegistry = registry.reflection;
|
|
1362
1379
|
function normalizeVariant(v) {
|
|
@@ -1584,7 +1601,7 @@ function missResolveResult(family, weight, style, suppressWarn = false) {
|
|
|
1584
1601
|
const fallback = getDefaultFontFamily() ?? firstRegisteredFamily();
|
|
1585
1602
|
if (fallback !== null && fallback !== family) {
|
|
1586
1603
|
if (registry.has(fallback) || isCanvasFont(fallback) || atlasPending(fallback)) {
|
|
1587
|
-
const result = resolveFontVariantInternal(fallback, weight, style, true);
|
|
1604
|
+
const result = resolveFontVariantInternal(fallback, weight, style, true, false);
|
|
1588
1605
|
if (result.entry !== null || result.dynamicFace !== void 0) {
|
|
1589
1606
|
if (!suppressWarn) warnMissingFamilyOnce(family, weight, style, fallback);
|
|
1590
1607
|
return { ...result, substituted: { requested: family, resolved: fallback } };
|
|
@@ -1653,7 +1670,10 @@ function weightBucket(w) {
|
|
|
1653
1670
|
return w >= 600 ? "bold" : "regular";
|
|
1654
1671
|
}
|
|
1655
1672
|
function resolveFontVariant(family, weight, style) {
|
|
1656
|
-
return resolveFontVariantInternal(family, weight, style, false);
|
|
1673
|
+
return resolveFontVariantInternal(family, weight, style, false, false);
|
|
1674
|
+
}
|
|
1675
|
+
function cachedFontVariant(family, weight, style) {
|
|
1676
|
+
return resolveFontVariantInternal(family, weight, style, false, true);
|
|
1657
1677
|
}
|
|
1658
1678
|
function resolveGlyphFallback(family, weight, style) {
|
|
1659
1679
|
if (getFontFallbackPolicy() === "none") return null;
|
|
@@ -1671,7 +1691,7 @@ function resolveGlyphFallback(family, weight, style) {
|
|
|
1671
1691
|
return null;
|
|
1672
1692
|
}
|
|
1673
1693
|
}
|
|
1674
|
-
function resolveFontVariantInternal(family, weight, style, suppressWarn) {
|
|
1694
|
+
function resolveFontVariantInternal(family, weight, style, suppressWarn, shared) {
|
|
1675
1695
|
wakeDeclared(family, weight, style);
|
|
1676
1696
|
const exactKey = variantKey(weight, style);
|
|
1677
1697
|
if (loads.size > 0 && loads.has(`${family}|${exactKey}`) && !registry.get(family)?.has(exactKey)) {
|
|
@@ -1684,12 +1704,7 @@ function resolveFontVariantInternal(family, weight, style, suppressWarn) {
|
|
|
1684
1704
|
}
|
|
1685
1705
|
const exact = familyMap.get(exactKey);
|
|
1686
1706
|
if (exact) {
|
|
1687
|
-
return
|
|
1688
|
-
entry: exact,
|
|
1689
|
-
resolved: { family, weight, style },
|
|
1690
|
-
synthetic: { bold: false, italic: false },
|
|
1691
|
-
source: "atlas"
|
|
1692
|
-
};
|
|
1707
|
+
return shared ? sharedExactResult(exact, family, weight, style) : atlasResult(exact, family, weight, style, false, false);
|
|
1693
1708
|
}
|
|
1694
1709
|
const requestedBucket = weightBucket(weight);
|
|
1695
1710
|
let bestSameStyle = null;
|
|
@@ -1703,38 +1718,11 @@ function resolveFontVariantInternal(family, weight, style, suppressWarn) {
|
|
|
1703
1718
|
bestSameStyle = { entry, weight: w, distance };
|
|
1704
1719
|
}
|
|
1705
1720
|
}
|
|
1706
|
-
if (bestSameStyle)
|
|
1707
|
-
return {
|
|
1708
|
-
entry: bestSameStyle.entry,
|
|
1709
|
-
resolved: { family, weight: bestSameStyle.weight, style },
|
|
1710
|
-
synthetic: { bold: false, italic: false },
|
|
1711
|
-
source: "atlas"
|
|
1712
|
-
};
|
|
1713
|
-
}
|
|
1721
|
+
if (bestSameStyle) return atlasResult(bestSameStyle.entry, family, bestSameStyle.weight, style, false, false);
|
|
1714
1722
|
const sameStyleRegular = familyMap.get(variantKey(400, style));
|
|
1715
|
-
if (sameStyleRegular)
|
|
1716
|
-
return {
|
|
1717
|
-
entry: sameStyleRegular,
|
|
1718
|
-
resolved: { family, weight: 400, style },
|
|
1719
|
-
synthetic: {
|
|
1720
|
-
bold: weight >= 600,
|
|
1721
|
-
italic: false
|
|
1722
|
-
},
|
|
1723
|
-
source: "atlas"
|
|
1724
|
-
};
|
|
1725
|
-
}
|
|
1723
|
+
if (sameStyleRegular) return atlasResult(sameStyleRegular, family, 400, style, weight >= 600, false);
|
|
1726
1724
|
const sameWeightNormal = familyMap.get(variantKey(weight, "normal"));
|
|
1727
|
-
if (sameWeightNormal)
|
|
1728
|
-
return {
|
|
1729
|
-
entry: sameWeightNormal,
|
|
1730
|
-
resolved: { family, weight, style: "normal" },
|
|
1731
|
-
synthetic: {
|
|
1732
|
-
bold: false,
|
|
1733
|
-
italic: style === "italic"
|
|
1734
|
-
},
|
|
1735
|
-
source: "atlas"
|
|
1736
|
-
};
|
|
1737
|
-
}
|
|
1725
|
+
if (sameWeightNormal) return atlasResult(sameWeightNormal, family, weight, "normal", false, style === "italic");
|
|
1738
1726
|
let bestNormal = null;
|
|
1739
1727
|
for (const [key, entry] of familyMap) {
|
|
1740
1728
|
const [wStr, s] = key.split("|");
|
|
@@ -1747,28 +1735,10 @@ function resolveFontVariantInternal(family, weight, style, suppressWarn) {
|
|
|
1747
1735
|
}
|
|
1748
1736
|
}
|
|
1749
1737
|
if (bestNormal) {
|
|
1750
|
-
return
|
|
1751
|
-
entry: bestNormal.entry,
|
|
1752
|
-
resolved: { family, weight: bestNormal.weight, style: "normal" },
|
|
1753
|
-
synthetic: {
|
|
1754
|
-
bold: false,
|
|
1755
|
-
italic: style === "italic"
|
|
1756
|
-
},
|
|
1757
|
-
source: "atlas"
|
|
1758
|
-
};
|
|
1738
|
+
return atlasResult(bestNormal.entry, family, bestNormal.weight, "normal", false, style === "italic");
|
|
1759
1739
|
}
|
|
1760
1740
|
const regular = familyMap.get(variantKey(400, "normal"));
|
|
1761
|
-
if (regular)
|
|
1762
|
-
return {
|
|
1763
|
-
entry: regular,
|
|
1764
|
-
resolved: { family, weight: 400, style: "normal" },
|
|
1765
|
-
synthetic: {
|
|
1766
|
-
bold: weight >= 600,
|
|
1767
|
-
italic: style === "italic"
|
|
1768
|
-
},
|
|
1769
|
-
source: "atlas"
|
|
1770
|
-
};
|
|
1771
|
-
}
|
|
1741
|
+
if (regular) return atlasResult(regular, family, 400, "normal", weight >= 600, style === "italic");
|
|
1772
1742
|
return missResolveResult(family, weight, style, suppressWarn);
|
|
1773
1743
|
}
|
|
1774
1744
|
|
|
@@ -1873,6 +1843,6 @@ function _resetDomFacesForTests() {
|
|
|
1873
1843
|
warned3.clear();
|
|
1874
1844
|
}
|
|
1875
1845
|
|
|
1876
|
-
export { BAKE_SIZE, DEFAULT_BAKE_BUDGET, MAX_SHARP_LEVEL, PAGE_SIZE, SDF_RADIUS, __setGlyphRasterizerForTests, _getPagesForTests, _resetDomFacesForTests, _resetDynamicFontsForTests, _resetFallbackForTests, _resetFontOutlinesForTests, _resetFontRegistryForTests, claimFallbackWarning, colorPageTextureId, createOpenTypeParser, cssFontFamily, cssFontFamilyLoading, dynamicPageTextureId, ensureFontTexture, faceGeneration, faceMetricsFor, fallbackWarningClaimed, fontOutlineRegistry, fontPending, fontRegistry, getDefaultFontFamily, getFont, getFontFallbackPolicy, glyphGeneration, glyphOutline, hasFontOutlines, isCanvasFont, listCanvasFonts, listFontOutlines, listFontWeights, listFonts, loadFontOutlines, markAllFontsNotUploaded, outlineMetrics, outlineStatus, refreshCanvasFont, registerCanvasFont, registerFont, registerFontOutlines, resetBakeBudget, resolveFontVariant, resolveGlyphFallback, setDefaultFontFamily, setFontFallbackPolicy, sharpColorPageTextureId, sharperColorGlyph, subscribeGlyphReady, syncColorPageTexture, syncDynamicPageTexture, syncSharpColorPageTexture, textureCacheKey, unregisterCanvasFont, unregisterFontOutlines, warmFonts };
|
|
1877
|
-
//# sourceMappingURL=chunk-
|
|
1878
|
-
//# sourceMappingURL=chunk-
|
|
1846
|
+
export { BAKE_SIZE, DEFAULT_BAKE_BUDGET, MAX_SHARP_LEVEL, PAGE_SIZE, SDF_RADIUS, __setGlyphRasterizerForTests, _getPagesForTests, _resetDomFacesForTests, _resetDynamicFontsForTests, _resetFallbackForTests, _resetFontOutlinesForTests, _resetFontRegistryForTests, cachedFontVariant, claimFallbackWarning, colorPageTextureId, createOpenTypeParser, cssFontFamily, cssFontFamilyLoading, dynamicPageTextureId, ensureFontTexture, faceGeneration, faceMetricsFor, fallbackWarningClaimed, fontOutlineRegistry, fontPending, fontRegistry, getDefaultFontFamily, getFont, getFontFallbackPolicy, glyphGeneration, glyphOutline, hasFontOutlines, isCanvasFont, listCanvasFonts, listFontOutlines, listFontWeights, listFonts, loadFontOutlines, markAllFontsNotUploaded, outlineMetrics, outlineStatus, refreshCanvasFont, registerCanvasFont, registerFont, registerFontOutlines, resetBakeBudget, resolveFontVariant, resolveGlyphFallback, setDefaultFontFamily, setFontFallbackPolicy, sharpColorPageTextureId, sharperColorGlyph, subscribeGlyphReady, syncColorPageTexture, syncDynamicPageTexture, syncSharpColorPageTexture, textureCacheKey, unregisterCanvasFont, unregisterFontOutlines, warmFonts };
|
|
1847
|
+
//# sourceMappingURL=chunk-SP6N5MJQ.js.map
|
|
1848
|
+
//# sourceMappingURL=chunk-SP6N5MJQ.js.map
|