Skip to content

Conversation

@HarshankPatel9038
Copy link

  • Added checkboxes to enable custom heading and custom body fonts independently.
  • Updated settings_schema.json with font URL and family fields for both heading and body.
  • Improved font loader logic to handle all common font variants (100–900, normal & italic).
  • Supports both local .woff2 fonts and Google Fonts URLs.
  • This makes theme font customization more flexible, maintainable, and clear for merchants.

@HarshankPatel9038
Copy link
Author

Update ThemeThis PR introduces a reusable and unified custom font loading system for both heading and body fonts. Merchants can now enable custom fonts independently for headings and body text, using either local .woff2 files (with auto-generated weight/style variants) or external Google Fonts links.

Updated with some italic variants
The existing custom font implementation in Dawn only supported a single WOFF2 file or a small subset of naming conventions. Merchants who uploaded full font families—including italic styles—were often unable to use italic emphasis in typography throughout the storefront. Even when italic font files existed in /assets, the theme failed to detect and register them because the filename-matching logic only supported a narrow pattern.

This PR introduces support for a much broader set of font naming conventions that are commonly used by font vendors. The logic now attempts to map multiple combinations of font weight and style by cycling through several filename candidates for each expected variant. This includes common patterns such as:
FontFamily-Regular.woff2
FontFamily-RegularItalic.woff2
FontFamily-Regular-Italic.woff2
FontFamily-Italic.woff2
FontFamily-BoldItalic.woff2
FontFamily-Bold-Italic.woff2
etc.

The theme loops through all supported font weights (100–900) and both normal and italic styles, automatically generating multiple @font-face definitions conditioned on whether the relevant file exists. This means:
No manual configuration is required from merchants.
No assumptions are made about naming convention of font files.
If a variant file does not exist, it is simply skipped — no 404 requests are generated.

With this enhancement, merchants benefit from:
Correct typography rendering when emphasizing text with italic styles.
Greater flexibility to upload complete font families.
More professional-looking results for stores with brand typography requirements.

This change maintains backward compatibility and does not affect merchants who do not upload custom fonts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant