I have a scss file with font import implemented this way:
@import url(https://fonts.googleapis.com/css?family=PT+Sans+Caption:400,700&subset=latin-ext,cyrillic);
I understand that using CDN gives advantages in caching for user but this is internal site and it could be used on server without access to the wide web
. And I'm not sure that user machine will have access to the Internet too. So I want to serve fronts with other pages static files.
Is there a way in SCSS to import fonts from the some directory on server? Something like:
@import dir(/path/to/fonts/file)
Or SCSS has not this feature?
@import "https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600;700&display=swap"; give the same, exact result compiled from Sass to CSS. Then, if you add one of these in a . scss file, you don't have to worry at all.
scss files, Sass can import plain old . css files. The only rule is that the import must not explicitly include the . css extension, because that's used to indicate a plain CSS @import .
SASS (Syntactically Awesome Style Sheets) is a pre-processor scripting language that will be compiled or interpreted into CSS. SassScript is itself a scripting language whereas SCSS is the main syntax for the SASS which builds on top of the existing CSS syntax.
As far as I know you can't import fonts using @import
in SCSS. You can include fonts using @font-face
. For example:
@font-face { font-family: 'Open Sans'; src: url(path/to/file) format(Example: 'truetype' or 'opentype' depending on the file extension of your font); } // USAGE body { font-family: 'Open Sans', sans-serif; }
Usually it's used to import CSS fragments or files and not fonts. Try this workaround if you are using Ruby SASS/SCSS and try without brackets.
@import "https://fonts.googleapis.com/css?family=PT+Sans+Caption:400,700&subset=latin-ext,cyrillic.css";
I put a .css
behind it. Works for me with Ruby SASS/SCSS but not with LibSass though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With