-
Notifications
You must be signed in to change notification settings - Fork 115
chore: implement self-hosted fonts for improved privacy and performance #418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,3 +4,179 @@ Add styles or override variables from the theme here. | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| */ | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Self-hosted font declarations | ||||||||||||||||||||||
| // Open Sans font family | ||||||||||||||||||||||
| @font-face { | ||||||||||||||||||||||
| font-family: 'Open Sans'; | ||||||||||||||||||||||
| font-style: normal; | ||||||||||||||||||||||
| font-weight: 300; | ||||||||||||||||||||||
| font-display: swap; | ||||||||||||||||||||||
| src: url('/assets/fonts/OpenSans-Light.woff2') format('woff2'), | ||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should Fix: Path consistency issue with font URLs The font paths use absolute URLs (
Suggested change
This applies to all 38 @font-face declarations. Using relative paths would ensure the fonts load correctly regardless of the deployment path.
imbajin marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||
| url('/assets/fonts/OpenSans-Light.woff') format('woff'); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @font-face { | ||||||||||||||||||||||
| font-family: 'Open Sans'; | ||||||||||||||||||||||
| font-style: italic; | ||||||||||||||||||||||
| font-weight: 300; | ||||||||||||||||||||||
| font-display: swap; | ||||||||||||||||||||||
| src: url('/assets/fonts/OpenSans-LightItalic.woff2') format('woff2'), | ||||||||||||||||||||||
| url('/assets/fonts/OpenSans-LightItalic.woff') format('woff'); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @font-face { | ||||||||||||||||||||||
| font-family: 'Open Sans'; | ||||||||||||||||||||||
| font-style: normal; | ||||||||||||||||||||||
| font-weight: 400; | ||||||||||||||||||||||
| font-display: swap; | ||||||||||||||||||||||
| src: url('/assets/fonts/OpenSans-Regular.woff2') format('woff2'), | ||||||||||||||||||||||
| url('/assets/fonts/OpenSans-Regular.woff') format('woff'); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @font-face { | ||||||||||||||||||||||
| font-family: 'Open Sans'; | ||||||||||||||||||||||
| font-style: italic; | ||||||||||||||||||||||
| font-weight: 400; | ||||||||||||||||||||||
| font-display: swap; | ||||||||||||||||||||||
| src: url('/assets/fonts/OpenSans-Italic.woff2') format('woff2'), | ||||||||||||||||||||||
| url('/assets/fonts/OpenSans-Italic.woff') format('woff'); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @font-face { | ||||||||||||||||||||||
| font-family: 'Open Sans'; | ||||||||||||||||||||||
| font-style: normal; | ||||||||||||||||||||||
| font-weight: 700; | ||||||||||||||||||||||
| font-display: swap; | ||||||||||||||||||||||
| src: url('/assets/fonts/OpenSans-Bold.woff2') format('woff2'), | ||||||||||||||||||||||
| url('/assets/fonts/OpenSans-Bold.woff') format('woff'); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @font-face { | ||||||||||||||||||||||
| font-family: 'Open Sans'; | ||||||||||||||||||||||
| font-style: italic; | ||||||||||||||||||||||
| font-weight: 700; | ||||||||||||||||||||||
| font-display: swap; | ||||||||||||||||||||||
| src: url('/assets/fonts/OpenSans-BoldItalic.woff2') format('woff2'), | ||||||||||||||||||||||
| url('/assets/fonts/OpenSans-BoldItalic.woff') format('woff'); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice to Have: Consider font subsetting for performance optimization For the multilingual fonts (Arabic, Persian, Hebrew), consider using Unicode range subsetting to reduce file sizes for users who don't need these character sets:
Suggested change
This would improve loading performance for users who don't need these specific language characters. |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Rubik font family (Hebrew) | ||||||||||||||||||||||
| @font-face { | ||||||||||||||||||||||
| font-family: 'Rubik'; | ||||||||||||||||||||||
| font-style: normal; | ||||||||||||||||||||||
| font-weight: 300; | ||||||||||||||||||||||
| font-display: swap; | ||||||||||||||||||||||
| src: url('/assets/fonts/Rubik-Light.woff2') format('woff2'), | ||||||||||||||||||||||
| url('/assets/fonts/Rubik-Light.woff') format('woff'); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @font-face { | ||||||||||||||||||||||
| font-family: 'Rubik'; | ||||||||||||||||||||||
| font-style: normal; | ||||||||||||||||||||||
| font-weight: 400; | ||||||||||||||||||||||
| font-display: swap; | ||||||||||||||||||||||
| src: url('/assets/fonts/Rubik-Regular.woff2') format('woff2'), | ||||||||||||||||||||||
| url('/assets/fonts/Rubik-Regular.woff') format('woff'); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @font-face { | ||||||||||||||||||||||
| font-family: 'Rubik'; | ||||||||||||||||||||||
| font-style: normal; | ||||||||||||||||||||||
| font-weight: 500; | ||||||||||||||||||||||
| font-display: swap; | ||||||||||||||||||||||
| src: url('/assets/fonts/Rubik-Medium.woff2') format('woff2'), | ||||||||||||||||||||||
| url('/assets/fonts/Rubik-Medium.woff') format('woff'); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @font-face { | ||||||||||||||||||||||
| font-family: 'Rubik'; | ||||||||||||||||||||||
| font-style: normal; | ||||||||||||||||||||||
| font-weight: 600; | ||||||||||||||||||||||
| font-display: swap; | ||||||||||||||||||||||
| src: url('/assets/fonts/Rubik-SemiBold.woff2') format('woff2'), | ||||||||||||||||||||||
| url('/assets/fonts/Rubik-SemiBold.woff') format('woff'); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @font-face { | ||||||||||||||||||||||
| font-family: 'Rubik'; | ||||||||||||||||||||||
| font-style: normal; | ||||||||||||||||||||||
| font-weight: 700; | ||||||||||||||||||||||
| font-display: swap; | ||||||||||||||||||||||
| src: url('/assets/fonts/Rubik-Bold.woff2') format('woff2'), | ||||||||||||||||||||||
| url('/assets/fonts/Rubik-Bold.woff') format('woff'); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Tajawal font family (Arabic) | ||||||||||||||||||||||
| @font-face { | ||||||||||||||||||||||
| font-family: 'Tajawal'; | ||||||||||||||||||||||
| font-style: normal; | ||||||||||||||||||||||
| font-weight: 300; | ||||||||||||||||||||||
| font-display: swap; | ||||||||||||||||||||||
| src: url('/assets/fonts/Tajawal-Light.woff2') format('woff2'), | ||||||||||||||||||||||
| url('/assets/fonts/Tajawal-Light.woff') format('woff'); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @font-face { | ||||||||||||||||||||||
| font-family: 'Tajawal'; | ||||||||||||||||||||||
| font-style: normal; | ||||||||||||||||||||||
| font-weight: 400; | ||||||||||||||||||||||
| font-display: swap; | ||||||||||||||||||||||
| src: url('/assets/fonts/Tajawal-Regular.woff2') format('woff2'), | ||||||||||||||||||||||
| url('/assets/fonts/Tajawal-Regular.woff') format('woff'); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @font-face { | ||||||||||||||||||||||
| font-family: 'Tajawal'; | ||||||||||||||||||||||
| font-style: normal; | ||||||||||||||||||||||
| font-weight: 500; | ||||||||||||||||||||||
| font-display: swap; | ||||||||||||||||||||||
| src: url('/assets/fonts/Tajawal-Medium.woff2') format('woff2'), | ||||||||||||||||||||||
| url('/assets/fonts/Tajawal-Medium.woff') format('woff'); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @font-face { | ||||||||||||||||||||||
| font-family: 'Tajawal'; | ||||||||||||||||||||||
| font-style: normal; | ||||||||||||||||||||||
| font-weight: 700; | ||||||||||||||||||||||
| font-display: swap; | ||||||||||||||||||||||
| src: url('/assets/fonts/Tajawal-Bold.woff2') format('woff2'), | ||||||||||||||||||||||
| url('/assets/fonts/Tajawal-Bold.woff') format('woff'); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Vazir font family (Persian/Farsi) | ||||||||||||||||||||||
| @font-face { | ||||||||||||||||||||||
| font-family: 'Vazir'; | ||||||||||||||||||||||
| font-style: normal; | ||||||||||||||||||||||
| font-weight: 300; | ||||||||||||||||||||||
| font-display: swap; | ||||||||||||||||||||||
| src: url('/assets/fonts/Vazir-Light.woff2') format('woff2'), | ||||||||||||||||||||||
| url('/assets/fonts/Vazir-Light.woff') format('woff'); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @font-face { | ||||||||||||||||||||||
| font-family: 'Vazir'; | ||||||||||||||||||||||
| font-style: normal; | ||||||||||||||||||||||
| font-weight: 400; | ||||||||||||||||||||||
| font-display: swap; | ||||||||||||||||||||||
| src: url('/assets/fonts/Vazir-Regular.woff2') format('woff2'), | ||||||||||||||||||||||
| url('/assets/fonts/Vazir-Regular.woff') format('woff'); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @font-face { | ||||||||||||||||||||||
| font-family: 'Vazir'; | ||||||||||||||||||||||
| font-style: normal; | ||||||||||||||||||||||
| font-weight: 500; | ||||||||||||||||||||||
| font-display: swap; | ||||||||||||||||||||||
| src: url('/assets/fonts/Vazir-Medium.woff2') format('woff2'), | ||||||||||||||||||||||
| url('/assets/fonts/Vazir-Medium.woff') format('woff'); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @font-face { | ||||||||||||||||||||||
| font-family: 'Vazir'; | ||||||||||||||||||||||
| font-style: normal; | ||||||||||||||||||||||
| font-weight: 700; | ||||||||||||||||||||||
| font-display: swap; | ||||||||||||||||||||||
| src: url('/assets/fonts/Vazir-Bold.woff2') format('woff2'), | ||||||||||||||||||||||
| url('/assets/fonts/Vazir-Bold.woff') format('woff'); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -13,7 +13,7 @@ $enable-shadows: true !default; | |||||
|
|
||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Avoid editing files under themes/. Set $td-enable-google-fonts: false in project override (assets/scss/_variables_project.scss) to prevent breakage on theme upgrades. Revert this change here and keep theme files pristine. |
||||||
| // Theme flags. | ||||||
|
|
||||||
| $td-enable-google-fonts: true !default; | ||||||
| $td-enable-google-fonts: false !default; | ||||||
|
|
||||||
| // Theme colors | ||||||
|
|
||||||
|
|
@@ -66,7 +66,7 @@ $link-hover-decoration: none !default; | |||||
|
|
||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not necessary to comment out $web-font-path here if $td-enable-google-fonts: false is set via project override. Prefer keeping the theme file untouched and place overrides in assets/scss/_variables_project.scss. |
||||||
| $google_font_name: "Open Sans" !default; | ||||||
| $google_font_family: "Open+Sans:300,300i,400,400i,700,700i" !default; | ||||||
| $web-font-path: "https://fonts.googleapis.com/css?family=#{$google_font_family}&display=swap"; | ||||||
| // $web-font-path: "https://fonts.googleapis.com/css?family=#{$google_font_family}&display=swap"; // Disabled for self-hosted fonts | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should Fix: Commented code should be removed instead of disabled Rather than commenting out the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commented-out code should be removed rather than left as a comment. Consider cleaner removal:
Suggested change
This improves maintainability by avoiding commented-out code. |
||||||
|
|
||||||
| $td-fonts-serif: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to Have: Add documentation for font configuration
Consider adding a comment block at the top of this file documenting:
This would help future maintainers understand the font hosting setup and make informed decisions about modifications.