fontdue-js 2.25.0 → 2.26.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/CHANGELOG.md +9 -0
- package/dist/__generated__/CartOrderCompleteOrderMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CartOrderCompleteOrderMutation.graphql.js +9 -3
- package/dist/__generated__/CartOrderRemoveDiscountMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CartOrderRemoveDiscountMutation.graphql.js +9 -3
- package/dist/__generated__/CartOrderUpdateMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CartOrderUpdateMutation.graphql.js +9 -3
- package/dist/__generated__/CartQuery.graphql.d.ts +1 -1
- package/dist/__generated__/CartQuery.graphql.js +10 -4
- package/dist/__generated__/CartStateUpdateMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CartStateUpdateMutation.graphql.js +9 -3
- package/dist/__generated__/CharacterViewerIDQuery.graphql.d.ts +1 -1
- package/dist/__generated__/CharacterViewerIDQuery.graphql.js +9 -3
- package/dist/__generated__/CharacterViewerSlugQuery.graphql.d.ts +1 -1
- package/dist/__generated__/CharacterViewerSlugQuery.graphql.js +9 -3
- package/dist/__generated__/CharacterViewerStyleRefetchQuery.graphql.d.ts +1 -1
- package/dist/__generated__/CharacterViewerStyleRefetchQuery.graphql.js +9 -3
- package/dist/__generated__/CheckoutUpdateCustomerMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CheckoutUpdateCustomerMutation.graphql.js +9 -3
- package/dist/__generated__/CheckoutUpdateOrderMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CheckoutUpdateOrderMutation.graphql.js +9 -3
- package/dist/__generated__/CollectionAa_Query.graphql.d.ts +1 -1
- package/dist/__generated__/CollectionAa_Query.graphql.js +9 -3
- package/dist/__generated__/FontFamiliesQuery.graphql.d.ts +1 -1
- package/dist/__generated__/FontFamiliesQuery.graphql.js +9 -3
- package/dist/__generated__/PrecartAddToCartMutation.graphql.d.ts +1 -1
- package/dist/__generated__/PrecartAddToCartMutation.graphql.js +9 -3
- package/dist/__generated__/StoreModalCartQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalCartQuery.graphql.js +10 -4
- package/dist/__generated__/StoreModalContainerQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalContainerQuery.graphql.js +9 -3
- package/dist/__generated__/StoreModalIndexQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalIndexQuery.graphql.js +9 -3
- package/dist/__generated__/StoreModalProductQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalProductQuery.graphql.js +9 -3
- package/dist/__generated__/StoreModalProductRefetchQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalProductRefetchQuery.graphql.js +9 -3
- package/dist/__generated__/TestFontsFormUpdateCustomerMutation.graphql.d.ts +1 -1
- package/dist/__generated__/TestFontsFormUpdateCustomerMutation.graphql.js +9 -3
- package/dist/__generated__/TypeTesterStandaloneChangedStylesQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTesterStandaloneChangedStylesQuery.graphql.js +9 -3
- package/dist/__generated__/TypeTesterStandaloneQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTesterStandaloneQuery.graphql.js +9 -3
- package/dist/__generated__/TypeTestersChangedStylesQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersChangedStylesQuery.graphql.js +9 -3
- package/dist/__generated__/TypeTestersIDQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersIDQuery.graphql.js +9 -3
- package/dist/__generated__/TypeTestersRefetchQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersRefetchQuery.graphql.js +9 -3
- package/dist/__generated__/TypeTestersSlugQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersSlugQuery.graphql.js +9 -3
- package/dist/__generated__/useFontStyle_fontStyle.graphql.d.ts +2 -1
- package/dist/__generated__/useFontStyle_fontStyle.graphql.js +8 -2
- package/dist/__tests__/fontLoader.test.js +108 -0
- package/dist/components/Icons/Checkbox.js +10 -8
- package/dist/components/Icons/CheckboxChecked.js +4 -5
- package/dist/components/TypeTester/TypeTesterStyleSelectData.js +1 -1
- package/dist/components/useFont.d.ts +1 -4
- package/dist/components/useFontStyle.js +1 -1
- package/dist/fontLoader.d.ts +21 -1
- package/dist/fontLoader.js +37 -2
- package/dist/fontdue.css +28 -15
- package/package.json +1 -1
package/dist/fontLoader.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.isFontLoaded = isFontLoaded;
|
|
7
7
|
exports.loadFont = loadFont;
|
|
8
|
+
exports.selectFontSource = selectFontSource;
|
|
8
9
|
const cache = new Map();
|
|
9
10
|
const loaded = new Set();
|
|
10
11
|
function isFontLoaded(fontFamily) {
|
|
@@ -22,9 +23,43 @@ async function loadFont(fontFamily, sources, verticalMetrics) {
|
|
|
22
23
|
});
|
|
23
24
|
return promise;
|
|
24
25
|
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Pick the best `FontSource` for the current browser from a list emitted by
|
|
29
|
+
* the backend's `webfontSources` field.
|
|
30
|
+
*
|
|
31
|
+
* The backend already returns sources in CSS `src:` priority order
|
|
32
|
+
* (dedicated COLRv1 → COLRv0 → SVG → sbix → bundled → outline-fallback,
|
|
33
|
+
* within format). The job here is to drop entries whose color tech the
|
|
34
|
+
* browser can't render — without this, fetching e.g. an SVG-in-OpenType
|
|
35
|
+
* file in Chrome pins a face Chrome can only render as outline.
|
|
36
|
+
*
|
|
37
|
+
* Sources with no `tech` tag are kept unconditionally (outline / universal).
|
|
38
|
+
* If every tech-tagged source is filtered out, falls back to the unfiltered
|
|
39
|
+
* list — the browser will at least try to render something rather than the
|
|
40
|
+
* fallback font.
|
|
41
|
+
*
|
|
42
|
+
* `techSupportCheck` is injectable for tests; defaults to
|
|
43
|
+
* `CSS.supports("font-tech(color-<tech>)")`.
|
|
44
|
+
*/
|
|
45
|
+
function selectFontSource(sources) {
|
|
46
|
+
let techSupportCheck = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultTechSupport;
|
|
47
|
+
const valid = sources.filter(s => s != null && s.url != null);
|
|
48
|
+
const supported = valid.filter(s => !s.tech || techSupportCheck(s.tech));
|
|
49
|
+
const candidates = supported.length > 0 ? supported : valid;
|
|
50
|
+
return candidates.find(s => s.format === 'woff2') ?? candidates[0] ?? null;
|
|
51
|
+
}
|
|
52
|
+
function defaultTechSupport(tech) {
|
|
53
|
+
// SSR or very old browsers without CSS.supports: be optimistic, don't drop
|
|
54
|
+
// tech-tagged sources. Filtering exists to *prevent* loading a file the
|
|
55
|
+
// browser can't render, not to forbid sources we're unsure about.
|
|
56
|
+
if (typeof CSS === 'undefined' || typeof CSS.supports !== 'function') {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
return CSS.supports(`font-tech(color-${tech})`);
|
|
60
|
+
}
|
|
25
61
|
async function doLoadFont(fontFamily, sources, verticalMetrics) {
|
|
26
|
-
const
|
|
27
|
-
const source = validSources.find(s => s.format === 'woff2') ?? validSources[0];
|
|
62
|
+
const source = selectFontSource(sources);
|
|
28
63
|
if (!source || !source.url) throw new Error(`No font sources for ${fontFamily}`);
|
|
29
64
|
const response = await fetch(source.url);
|
|
30
65
|
if (!response.ok) throw new Error(`Failed to fetch font: ${response.status}`);
|
package/dist/fontdue.css
CHANGED
|
@@ -2547,27 +2547,37 @@ body[data-fontdue-store-modal=open] {
|
|
|
2547
2547
|
}
|
|
2548
2548
|
.cart-item + .cart-item {
|
|
2549
2549
|
border-top: 1px solid var(--horizontal_rule_color);
|
|
2550
|
-
padding-top: 40px;
|
|
2551
2550
|
}
|
|
2552
|
-
@media (max-width:
|
|
2551
|
+
@media (max-width: 1199px) {
|
|
2553
2552
|
.cart-item {
|
|
2554
2553
|
display: grid;
|
|
2555
2554
|
grid-template-columns: 1fr auto;
|
|
2556
2555
|
column-gap: 20px;
|
|
2556
|
+
row-gap: 20px;
|
|
2557
2557
|
align-items: baseline;
|
|
2558
2558
|
}
|
|
2559
2559
|
}
|
|
2560
|
-
@media (max-width:
|
|
2561
|
-
> div:has(> .cart-item__licenses) {
|
|
2560
|
+
@media (max-width: 1199px) {
|
|
2561
|
+
.cart-item > div:has(> .cart-item__licenses) {
|
|
2562
2562
|
grid-column: 1/-1;
|
|
2563
2563
|
}
|
|
2564
2564
|
}
|
|
2565
|
+
@media (min-width: 1200px) {
|
|
2566
|
+
.cart-item > div:has(> .cart-item__licenses) {
|
|
2567
|
+
grid-column: name/end;
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2565
2570
|
@media (min-width: 900px) {
|
|
2571
|
+
.cart-item {
|
|
2572
|
+
grid-column: 1/-1;
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
@media (min-width: 1200px) {
|
|
2566
2576
|
.cart-item {
|
|
2567
2577
|
display: grid;
|
|
2568
2578
|
align-items: baseline;
|
|
2569
2579
|
grid-template-columns: subgrid;
|
|
2570
|
-
|
|
2580
|
+
row-gap: 20px;
|
|
2571
2581
|
padding-bottom: 30px;
|
|
2572
2582
|
margin-bottom: 0;
|
|
2573
2583
|
}
|
|
@@ -2590,12 +2600,17 @@ body[data-fontdue-store-modal=open] {
|
|
|
2590
2600
|
.cart-item__label {
|
|
2591
2601
|
color: var(--styles-count-color, var(--secondary_text_color));
|
|
2592
2602
|
}
|
|
2593
|
-
@media (max-width:
|
|
2603
|
+
@media (max-width: 1199px) {
|
|
2594
2604
|
.cart-item__product {
|
|
2595
2605
|
grid-column: 1;
|
|
2596
2606
|
margin-bottom: 20px;
|
|
2597
2607
|
}
|
|
2598
2608
|
}
|
|
2609
|
+
@media (min-width: 1200px) {
|
|
2610
|
+
.cart-item__product {
|
|
2611
|
+
grid-column: name/price;
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2599
2614
|
.cart-item__name {
|
|
2600
2615
|
font-size: 1em;
|
|
2601
2616
|
margin-top: 30px; /* line up to the baseline of next column */
|
|
@@ -2616,9 +2631,8 @@ body[data-fontdue-store-modal=open] {
|
|
|
2616
2631
|
align-items: flex-start;
|
|
2617
2632
|
gap: 20px;
|
|
2618
2633
|
padding-top: 20px;
|
|
2619
|
-
padding-bottom: 20px;
|
|
2620
2634
|
}
|
|
2621
|
-
.cart-
|
|
2635
|
+
.cart-item__license:first-child {
|
|
2622
2636
|
padding-top: 0;
|
|
2623
2637
|
}
|
|
2624
2638
|
@media (pointer: fine) {
|
|
@@ -2650,9 +2664,6 @@ body[data-fontdue-store-modal=open] {
|
|
|
2650
2664
|
.cart-item__license__delete-button .icon {
|
|
2651
2665
|
font-size: 16px;
|
|
2652
2666
|
}
|
|
2653
|
-
.cart-item__license + .cart-item__license {
|
|
2654
|
-
border-top: 1px solid var(--horizontal_rule_color);
|
|
2655
|
-
}
|
|
2656
2667
|
.cart-item__license-wrapper {
|
|
2657
2668
|
flex: 1;
|
|
2658
2669
|
}
|
|
@@ -2759,15 +2770,17 @@ body[data-fontdue-store-modal=open] {
|
|
|
2759
2770
|
.cart-item__license-variable__loading {
|
|
2760
2771
|
padding: 10px;
|
|
2761
2772
|
}
|
|
2762
|
-
@media (max-width:
|
|
2773
|
+
@media (max-width: 1199px) {
|
|
2763
2774
|
.cart-item__price {
|
|
2764
2775
|
grid-column: 2;
|
|
2765
2776
|
grid-row: 1;
|
|
2766
2777
|
text-align: right;
|
|
2767
2778
|
}
|
|
2768
2779
|
}
|
|
2769
|
-
@media (min-width:
|
|
2780
|
+
@media (min-width: 1200px) {
|
|
2770
2781
|
.cart-item__price {
|
|
2782
|
+
grid-column: price/end;
|
|
2783
|
+
grid-row: 1;
|
|
2771
2784
|
display: initial;
|
|
2772
2785
|
margin-top: 30px;
|
|
2773
2786
|
text-align: right;
|
|
@@ -2780,9 +2793,9 @@ body[data-fontdue-store-modal=open] {
|
|
|
2780
2793
|
padding-top: 16px;
|
|
2781
2794
|
color: var(--additional-license-color, var(--secondary_text_color));
|
|
2782
2795
|
}
|
|
2783
|
-
@media (min-width:
|
|
2796
|
+
@media (min-width: 1200px) {
|
|
2784
2797
|
.cart-item__additional-licenses {
|
|
2785
|
-
grid-column
|
|
2798
|
+
grid-column: name/end;
|
|
2786
2799
|
padding-top: 10px;
|
|
2787
2800
|
padding-bottom: 5px;
|
|
2788
2801
|
}
|