PluginProbe
EasyFonts – Host Google Fonts Locally, Fast & Auto-Optimize, GDPR Compliant / 2.0.4
EasyFonts – Host Google Fonts Locally, Fast & Auto-Optimize, GDPR Compliant v2.0.4
2.0.4 2.0.3 2.0.2 2.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2 1.3 2.0.0
← All changes | src/Fonts/Registry.php +7 -3 2.0.3 → 2.0.4 View file →
@@ -525,17 +525,19 @@
525 525 * weight/style, which often differs from the hosted variant (e.g. a
526 526 * single-weight family rendered bold reports weight 700, but only 400 is
527 527 * hosted). An exact lookup would then return nothing and the font would
528 528 * never preload. So we prefer an exact match, then the same style, then the
529 - * latin subset, then the closest available weight — always returning a real
530 - * file when the (enabled) family is hosted at all.
529 + * page's subset (2.0.4; e.g. cyrillic on a Russian site), then latin, then
530 + * the closest available weight — always returning a real file when the
531 + * (enabled) family is hosted at all.
531 532 *
532 533 * @param string $family Family.
533 534 * @param string $weight Desired weight.
534 535 * @param string $style Desired style.
536 + * @param string $subset Preferred subset.
535 537 * @return string|null
536 538 */
537 - public function resolve_preload_file( string $family, string $weight, string $style ): ?string {
539 + public function resolve_preload_file( string $family, string $weight, string $style, string $subset = 'latin' ): ?string {
538 540 global $wpdb;
539 541
540 542 $target = (int) preg_replace( '/\D+/', '', $weight );
541 543 $target = $target > 0 ? $target : 400;
@@ -547,8 +549,9 @@
547 549 WHERE family = %s AND is_enabled = 1 AND font_file <> ''
548 550 ORDER BY
549 551 ( weight = %s AND style = %s ) DESC,
550 552 ( style = %s ) DESC,
553 + ( subset = %s ) DESC,
551 554 ( subset = 'latin' ) DESC,
552 555 ABS( CAST( COALESCE( NULLIF(weight,''), '400' ) AS SIGNED ) - %d ) ASC,
553 556 id ASC
554 557 LIMIT 1",
@@ -555,8 +558,9 @@
555 558 $family,
556 559 $weight,
557 560 $style,
558 561 $style,
562 + $subset,
559 563 $target
560 564 )
561 565 );
562 566