Skip to content

Fix font variant detection in Google Fonts downloader - #3

Merged
Ariel-Gal merged 3 commits into
Developmentfrom
copilot/sub-pr-1-again
Jan 19, 2026
Merged

Fix font variant detection in Google Fonts downloader#3
Ariel-Gal merged 3 commits into
Developmentfrom
copilot/sub-pr-1-again

Conversation

Copilot AI commented Jan 18, 2026

Copy link
Copy Markdown
Contributor

The install_google_font() function hardcoded filenames as {font_name}-Regular.ttf, causing mismatches when Google Fonts serves Bold, Italic, or other variants.

Changes:

  • Parse URL to extract variant: Detect Bold, Italic, Light, BoldItalic from the font URL returned by Google Fonts CSS
  • Dynamic filename: Save fonts using the detected variant instead of hardcoded 'Regular'
  • Case-insensitive matching: Normalize font names for reliable comparison across different naming conventions
  • Compound variant precedence: Check 'bolditalic' before 'bold' or 'italic' to avoid incorrect detection
  • Variant-aware existence check: Look for any existing variant to skip re-downloads

Example:

# Before: Always saved as "Roboto-Regular.ttf" even if URL pointed to Bold
# After: Parses URL and saves as "Roboto-Bold.ttf" if URL contains Bold variant

# URL: https://fonts.gstatic.com/.../Roboto-Bold.ttf
font_path = install_google_font("Roboto")  
# Saves as: assets/fonts/Roboto-Bold.ttf (matches actual variant)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 18, 2026 21:07
Co-authored-by: Ariel-Gal <82096633+Ariel-Gal@users.noreply.github.com>
Co-authored-by: Ariel-Gal <82096633+Ariel-Gal@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on Google Fonts integration Fix font variant detection in Google Fonts downloader Jan 18, 2026
Copilot AI requested a review from Ariel-Gal January 18, 2026 21:11
@Ariel-Gal
Ariel-Gal marked this pull request as ready for review January 19, 2026 10:28
@Ariel-Gal
Ariel-Gal merged commit d73f490 into Development Jan 19, 2026
@Ariel-Gal
Ariel-Gal deleted the copilot/sub-pr-1-again branch January 19, 2026 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants