Im new to SCSS and im trying to load a local font to my SCSS file.
This works perfectly fine in a CSS file but in a SCSS file it does not give anything, not even an error:
#font-face {
font-family: "Cairo";
font-weight: 400;
font-style: normal;
src: url(./assets/Fonts/Cairo/CairoBlock-Regular.ttf);
}
The css and scss files are both located in the same directory so the path should be same. What am I doing wrong?
If you want to have your fonts loaded properly, you need to have them linked to your page somehow at some point. Hence why putting your SCSS files into the css property is probably the way to go.
nuxt.config.js
export default {
// Global CSS: https://go.nuxtjs.dev/config-css
css: ['put-your-files-here']
}
Otherwise, here is how to load some fonts properly with Nuxt.
Related
I'm using the open-iconic library that comes with the default Blazor template in Visual Studio.
It's referenced in the css file #import url('open-iconic/font/css/open-iconic-bootstrap.min.css');
I added some custom ttf fonts to my root folder. When referencing them in the css file like this:
#font-face {
font-family: ALittlePot;
src: url('../fonts/ALittlePot.ttf') format('truetype');
}
then the open-iconic icons disappear. I even tried removing the content and just putting #font-face { } the same thing happened. It obviously has something to do with using #font-Face.
I tried adding my font using #import url('../fonts/ALittlePot.ttf'); but then the font didn't render.
Where am I going wrong?
My project contains the following :
A balloon JS widget with a hand-coded SCSS file common/balloon/luciad-balloon.scss :
...
.lcdClose {
...
background-image: url("close-icon-selected.png");
}
.lcdClose:hover {
...
background-image: url("close-icon.png");
}
An icon font with a generated CSS file resources/font/luciad/style.css :
#font-face {
font-family: 'LuciadRIA';
src:
url('fonts/LuciadRIA.ttf?25o3wd') format('truetype'),
url('fonts/LuciadRIA.woff?25o3wd') format('woff'),
url('fonts/LuciadRIA.svg?25o3wd#LuciadRIA') format('svg');
font-weight: normal;
font-style: normal;
}
...
I'm now creating a theme file template/css/sample-single.scss. This theme includes several components, including the two components I mentioned.
Unfortunatelty, I'm not able to do this :
#import "../../resources/font/luciad/style";
#import "../../common/balloon/luciad-balloon";
Considering a CSS import resolves the URL files relative to the file they are found in and SCSS does not adjust the URL after embedding it into sample-single.scss, the URL is still relative to the imported file and thus incorrect. This behavior is confusing, because I would expect SCSS imports to behave the same as CSS imports in this regard.
I could replace #import "../../resources/font/luciad/style" with #import "../../resources/font/luciad/style.css", considering this is a css file. Because the file is now referenced as an external file instead of embedded, this solves the issue for that particular file. However, I'd rather avoid external dependencies and prefer to embed everything in my sample-single.css.
And for #import "../../common/balloon/luciad-balloon", I do not have that option. Considering this is an SCSS file, I can not use this as an external reference. I suppose I could fix this issue by using absolute paths, but this reduces the reusability of this component. It prohibits using this component across different projects with different folder structures or server configs.
Is there a way I can include common/balloon/luciad-balloon.scss & resources/font/luciad/style.css into template/css/sample-single.scss without having to rewrite the URLs in their property values to absolute paths?
I have added a custom font to my project in the src/main/resources folder (RobotoMono.ttf). Then I try to load it from my css file like this:
#font-face {
font-family: 'RobotoMono';
src: url('RobotoMono.ttf');
}
but when I try to set this font to something it doesn't work:
.column-header-label {
-fx-label-padding: 0;
-fx-text-overrun: clip;
-fx-font-family: 'RobotoMono';
}
If I set the font to something which is present on my system I can see that the font changes but the one included by me does not work.
What am I doing wrong?
In your css, you have to specify a font-face with a url. Then, in your css element you have to use the name of the font from inside the ttf file, not the name of the font file itself. For instance, if you open the ttf file from Windows you see "Roboto Mono".
#font-face {
src: url('RobotoMono.ttf');
}
.column-header-label {
-fx-label-padding: 0;
-fx-text-overrun: clip;
-fx-font-family: 'Roboto Mono';
}
You declared where the font exists using the src property:
src: url('RobotoMono.ttf');
This is an instruction to look for RobotoMono.ttf in the same folder where the CSS file exists. If you created your JavaFX application using Maven, the style files should be in
src/main/resources/styles
So make sure the project's folder structure looks like:
just add the font to your java build path libraries
for example in eclipse you have to right click on the project->properties->java build path->add JARs and then add your ttf font.
after you have done this you need to just add the line below to your css
-fx-font-family: 'name of the font you have added to library without .tff';
make sure that your ttf font is inside the folder of your project
i want to change semantic-ui default font with #font-face but no matter...
i tried change in less file(site.variables) but I do not know how change it
i tried add my font with other custom css file but it not work
#font-face {
font-family: 'fontname';
src:url('themes/basic/assets/fonts/fontname.eot');
src:url('themes/basic/assets/fonts/fontname.eot?#') format('eot'),
url('themes/basic/assets/fonts/fontname.woff') format('woff');
}
body{
font-family: 'fontname';
}
I know two ways to change font-face, using google fonts or offline fonts:
Using google fonts:
We need to have the resources of Semantic UI, you can get here:
https://semantic-ui.com/introduction/getting-started.html
It is required to create the file site.variables in semantic/src/site/globals/
We search for the source that we like most at https://fonts.google.com/ and copy the name.
In the file site.variables we add the name of the font to the variable #fontName as follows:
/*******************************
User Global Variables
*******************************/
#fontName : 'Roboto';
Finally we execute the command glup build-css, the changes will be reflected in the file semantic /dist/semantic.css
Using offline fonts
We need to have the resources of Semantic UI, you can get here:
https://semantic-ui.com/introduction/getting-started.html
It is required to create the file site.variables in semantic/src/site/globals/
In the file site.variables we add the variable #importGoogleFonts with the value false;
/*******************************
User Global Variables
*******************************/
#importGoogleFonts : false;
#fontName : 'fontname';
It is required to create the file site.overrides in semantic/src/site/globals /
In the file site.overrides we add our font-face
/*******************************
Site Overrides
*******************************/
#font-face {
font-family: 'fontname';
src:url('themes/basic/assets/fonts/fontname.eot');
src:url('themes/basic/assets/fonts/fontname.eot?#') format('eot'),
url('themes/basic/assets/fonts/fontname.woff') format('woff');
}
Finally we execute the command gulp build-css, the changes will be reflected in the file semantic /dist/semantic.css
This video maked by #Aditya Giri explain how change font family from google fonts
https://www.youtube.com/watch?v=cSdKA-tZEbg
In the next issue #jlukic explain how use offline fonts
https://github.com/Semantic-Org/Semantic-UI/issues/1521
Regards
You can do the following:
Add the following to a .css file:
#font-face {
font-family: 'fontname';
src:url('themes/basic/assets/fonts/fontname.eot');
src:url('themes/basic/assets/fonts/fontname.eot?#') format('eot'),
url('themes/basic/assets/fonts/fontname.woff') format('woff');
}
Import the above code before semantic's site.min.css
Change the #fontName to 'fontname'
#importGoogleFonts should be false since you don't want to import any fonts from Google
By default the above will applied to body
It's an old question but I just wanted to add one thing.
Because all Semantic UI elements inherits the ui class you could do it like this:
.ui {
font-family: 'fontname' !important;
}
Not so elegant but it works.
This is the complicated solution https://stackoverflow.com/a/54208399/2374997 but if you want a simpler approach you could follow this example:
/*In your .css file, loaded after semantic.min.css*/
#import url('https://fonts.googleapis.com/css2?family=Montserrat&display=swap');
* {
font-family: 'Montserrat' !important;
}
You can use google Link:
Add to index.html google link. For example:
<linkhref="https://fonts.googleapis.com/css2?family=Rubik+Glitch&display=swap"rel="stylesheet"/>
Add Font in semantic.ui> site> globals > site.variables. For example:
/*******************************
User Global Variables
*******************************/
/*--FONTS--*/
#pageFont: Rubik Glitch;
I'm trying to add a custom font to my wordpress website, but i'm not sure of what I'm doing here so if you can help me !
For the moment in my theme directory I have a font directory in which I've put my font.otf
My style.css is in the theme directory :
Theme
------style.css
------font
----------Museo300-Regular.otf
I'm using the compass to generate font face like this :
#include font-face("Museo300", font-files("font/Museo300-Regular.otf"));
which output me this :
#font-face {
font-family: "Museo300";
src: url('fonts/font/Museo300-Regular.otf') format('opentype'); }
And when I try to use it :
#headerContainer header #menu li {
float: left;
font-family: "Museo300";
color: #FFF; }
But I the font doesn't get used !
So if someone know where I'm wront !
Thanks
You need to do it like this, depending on your server setup. Also, never used font-files before, or compass. I use src but I'm guessing its your server path. I.e. It thinks your font is elsewhere.
#include font-face("Museo300", src("../font/Museo300-Regular.otf"));
or
#font-face {
font-family: 'Museo300';
src: url('../font/Museo-Regular.otf');
font-weight: normal;
font-style: normal;
}
Your path is wrong - it is simply a case of correctly showing the "path" to the directory.
This is what to do: in your fonts directory I would put a new file fonts.css
Then in your style.css put a CSS #import (font/fonts.css) statement
to include that file. It helps keep things tidy and you can move your font file between sites easily Font Squirrel generator for your custom fonts like this - free site and very useful making the CSS !