Add !default to mixin variables
Is your feature request related to a problem? Please describe.
I wish to override default variables in the font mixin and cannot do so, at present. For example, a common case is to override $fontDir. At present, I have to use @fontFaceCustom and override the paths (I cannot use @fontFace since I want to modify Unicode ranges). I effectively end up writing my own mixin in the process.
Describe the solution you'd like
Add !default to default values of mixin variables, so that consumers can override them using with like so:
@use "path/to/font" as aFont with (
$fontDir: "modified/path",
$weight: 500, // set default weight as 500 unless modified per mixin invocation
)
Describe alternatives you've considered
You may also expose $fontDir in @fontFaceCustom. I can understand the reluctance to do so, since people may attempt to modify both $fontDir and $woffPath.
However, file paths may change in a future upgrade, but the API can hide this.
At this point, we're looking to completely redo our Sass implementation and prep it for our upcoming major release. There has been some work done for it in the past by the awesome @thasmo, but I think that stagnated. Although it is relatively done I think, we just need to get in touch with him again maybe 👀
We're looking for someone who's up to date and understands Sass to help contribute a new solution since nobody in our current team really uses Sass. Fontsource only uses this template file to generate all the mixins.
If we could tackle all the issues in one swoop, that would be great.
This is a very small and innocuous change all things considered. Would maintainers accept a pull request so we can get this out there? It was punted on in July.
This is a very small and innocuous change all things considered. Would maintainers accept a pull request so we can get this out there? It was punted on in July.
If it is a non-breaking change, then I'm happy to accept a PR.
Thanks @ayuhito. I'd be surprised if the change was breaking—but perhaps it might break implementations in the wild due to corner-cases arising so, while innocuous, maybe not so much for code that has baked. Also, after digging in deeper I cannot get the Sass mixins to work with SvelteKit + Playwright so I'm going to punt on my offer.
If there's still a rewrite going on, Sass modules looked interesting and someone has already created a POC: https://github.com/fontsource/fontsource/discussions/384
Thanks for the awesome project. It cannot be easy to make it work with so many different frameworks. Though it would be nice if it were easier to leverage those Sass mix-ins – perhaps by way of examples which doubled as integration tests.
@vhscom, the v5 release (#590) is pretty much ready which can push all sorts of breaking changes to the project. The only main blocker is the Sass rewrite, which is something I've sort of neglected because it's not my domain of expertise.
I don't have enough experience to comfortably work on the ideal templates so I won't even attempt a shot at it until #597 is done. If you may be interested in helping PR a new Sass template to be distributed in all packages, I would appreciate it a lot. That way I can look into finalising this major bump.
We've rewritten the Sass integration entirely for v5 🎉 Please let us know if you run into any issues!