subfont 6.12.0 → 6.12.2
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/CHANGELOG.md +10 -0
- package/lib/subsetFonts.js +33 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
### v6.12.2 (2022-11-02)
|
|
2
|
+
|
|
3
|
+
- [Be resilient when an insertion point cannot be found for subfont's preloads and stylesheets Fixes assetgraph\/assetgraph\#1251](https://github.com/Munter/subfont/commit/75beca70fb6cf696cf958326d8ea65b31d125b71) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com))
|
|
4
|
+
|
|
5
|
+
### v6.12.1 (2022-09-11)
|
|
6
|
+
|
|
7
|
+
- [Map font-style: oblique to font-variation-settings: slnt -14](https://github.com/Munter/subfont/commit/ea96284729e0d100fcb87d09c63979641439b169) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com))
|
|
8
|
+
- [Fix typo in test case](https://github.com/Munter/subfont/commit/b07273ff0daff38a23ef9b0ce77d5a114c4e2154) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com))
|
|
9
|
+
- [Improve slnt axis test case with a copy of the Extendomatic font Should be OK according to the license: https:\/\/djr.com\/license\/\#server https:\/\/twitter.com\/djrrb\/status\/1568539078416539654?s=20&t=P3w5SKI\_UHV3zzrBMj47lQ](https://github.com/Munter/subfont/commit/f6692fc3ad17a745bda13d1eb78ccd5fb340b369) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com))
|
|
10
|
+
|
|
1
11
|
### v6.12.0 (2022-09-07)
|
|
2
12
|
|
|
3
13
|
- [Refactor repeated code into helper function](https://github.com/Munter/subfont/commit/5335d931957cadc150fed1c5d548ee6b6e245636) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com))
|
package/lib/subsetFonts.js
CHANGED
|
@@ -829,8 +829,11 @@ function warnAboutUnusedVariationAxes(
|
|
|
829
829
|
if (fontStyles.has('oblique')) {
|
|
830
830
|
// https://www.w3.org/TR/css-fonts-4/#font-style-prop
|
|
831
831
|
// oblique <angle>?
|
|
832
|
-
//
|
|
833
|
-
|
|
832
|
+
// [...] The lack of an <angle> represents 14deg.
|
|
833
|
+
// And also:
|
|
834
|
+
// Note: the OpenType slnt axis is defined with a positive angle meaning a counter-clockwise slant, the opposite direction to CSS.
|
|
835
|
+
// sThe CSS implementation will take this into account when using variations to produce oblique faces.
|
|
836
|
+
noteUsedValue(fontUrl, 'slnt', -14);
|
|
834
837
|
}
|
|
835
838
|
// If any font-style value except oblique is seen (including normal or italic)
|
|
836
839
|
// we're also utilizing value 0:
|
|
@@ -1248,10 +1251,27 @@ async function subsetFonts(
|
|
|
1248
1251
|
fontUsages,
|
|
1249
1252
|
accumulatedFontFaceDeclarations,
|
|
1250
1253
|
} of htmlOrSvgAssetTextsWithProps) {
|
|
1251
|
-
|
|
1254
|
+
let insertionPoint = assetGraph.findRelations({
|
|
1252
1255
|
type: `${htmlOrSvgAsset.type}Style`,
|
|
1253
1256
|
from: htmlOrSvgAsset,
|
|
1254
1257
|
})[0];
|
|
1258
|
+
|
|
1259
|
+
// Hackingly deal with the original stylesheet being located inside <noscript>
|
|
1260
|
+
// https://github.com/assetgraph/assetgraph/issues/1251
|
|
1261
|
+
if (!insertionPoint && htmlOrSvgAsset.type === 'Html') {
|
|
1262
|
+
for (const htmlNoScript of assetGraph.findRelations({
|
|
1263
|
+
type: 'HtmlNoscript',
|
|
1264
|
+
from: htmlOrSvgAsset,
|
|
1265
|
+
})) {
|
|
1266
|
+
if (
|
|
1267
|
+
assetGraph.findRelations({ from: htmlNoScript.to, type: 'HtmlStyle' })
|
|
1268
|
+
.length > 0
|
|
1269
|
+
) {
|
|
1270
|
+
insertionPoint = htmlNoScript;
|
|
1271
|
+
break;
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1255
1275
|
const subsetFontUsages = fontUsages.filter(
|
|
1256
1276
|
(fontUsage) => fontUsage.subsets
|
|
1257
1277
|
);
|
|
@@ -1288,19 +1308,20 @@ async function subsetFonts(
|
|
|
1288
1308
|
|
|
1289
1309
|
if (unsubsettedFontUsagesToPreload.length > 0) {
|
|
1290
1310
|
// Insert <link rel="preload">
|
|
1291
|
-
|
|
1311
|
+
for (const fontUsage of unsubsettedFontUsagesToPreload) {
|
|
1292
1312
|
// Always preload unsubsetted font files, they might be any format, so can't be clever here
|
|
1293
|
-
|
|
1313
|
+
const preloadRelation = htmlOrSvgAsset.addRelation(
|
|
1294
1314
|
{
|
|
1295
1315
|
type: 'HtmlPreloadLink',
|
|
1296
1316
|
hrefType,
|
|
1297
1317
|
to: fontUsage.fontUrl,
|
|
1298
1318
|
as: 'font',
|
|
1299
1319
|
},
|
|
1300
|
-
'before',
|
|
1320
|
+
insertionPoint ? 'before' : 'firstInHead',
|
|
1301
1321
|
insertionPoint
|
|
1302
1322
|
);
|
|
1303
|
-
|
|
1323
|
+
insertionPoint = insertionPoint || preloadRelation;
|
|
1324
|
+
}
|
|
1304
1325
|
}
|
|
1305
1326
|
|
|
1306
1327
|
if (subsetFontUsages.length === 0) {
|
|
@@ -1430,16 +1451,17 @@ async function subsetFonts(
|
|
|
1430
1451
|
// - https://caniuse.com/#search=preload
|
|
1431
1452
|
|
|
1432
1453
|
if (htmlOrSvgAsset.type === 'Html') {
|
|
1433
|
-
htmlOrSvgAsset.addRelation(
|
|
1454
|
+
const htmlPreloadLink = htmlOrSvgAsset.addRelation(
|
|
1434
1455
|
{
|
|
1435
1456
|
type: 'HtmlPreloadLink',
|
|
1436
1457
|
hrefType,
|
|
1437
1458
|
to: fontAsset,
|
|
1438
1459
|
as: 'font',
|
|
1439
1460
|
},
|
|
1440
|
-
'before',
|
|
1461
|
+
insertionPoint ? 'before' : 'firstInHead',
|
|
1441
1462
|
insertionPoint
|
|
1442
1463
|
);
|
|
1464
|
+
insertionPoint = insertionPoint || htmlPreloadLink;
|
|
1443
1465
|
}
|
|
1444
1466
|
}
|
|
1445
1467
|
}
|
|
@@ -1450,9 +1472,10 @@ async function subsetFonts(
|
|
|
1450
1472
|
inlineCss || htmlOrSvgAsset.type === 'Svg' ? 'inline' : hrefType,
|
|
1451
1473
|
to: cssAsset,
|
|
1452
1474
|
},
|
|
1453
|
-
'before',
|
|
1475
|
+
insertionPoint ? 'before' : 'firstInHead',
|
|
1454
1476
|
insertionPoint
|
|
1455
1477
|
);
|
|
1478
|
+
insertionPoint = insertionPoint || cssRelation;
|
|
1456
1479
|
|
|
1457
1480
|
if (!omitFallbacks && inlineCss && unusedVariantsCss) {
|
|
1458
1481
|
// The fallback CSS for unused variants needs to go into its own stylesheet after the crude version of the JS-based preload "polyfill"
|