Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add custom local font to Jekyll site?

I have a custom icon font exported from Icomoon, and I'm trying to figure out how to incorporate it into my Jekyll site (I'm a bit new to Jekyll!) I've added the directory exported from Icomoon in my assets folder, and I've included the line:

@include embed-font ("Icomoon", "../assets/fonts/font/icomoon.ttf");

in my CSS, and added in my config file:

assets:
   sources:
       -_assets/fonts

but I get an error message saying: "undefined mixin 'embed-font' on line 2 of my CSS.

Does anyone know the steps I can take to integrate this correctly? Or have any resources/tutorials for this?? I feel really lost.

like image 914
tx291 Avatar asked Aug 19 '16 16:08

tx291


People also ask

How do I change the font on my Jekyll theme?

To change the default font definition you need to reset the value of $base-font-family variable, e.g.: $base-font-family: "PT Serif", serif; You will also need to remove the ! default; suffix at the end of this setting.

How do I add fonts to Ruby on Rails?

Importing it into my Rails app was pretty easy. First, you create a folder called 'fonts' in your 'assets' folder. After that, you go shopping for fonts! After downloading one that catches your eye, simply drag it to your fonts folder.


2 Answers

  1. Download the custom set of icons (icomoon.zip) and extract to some relative location.
  2. Copy 'icomoon/fonts/*' files to 'your-project-name/assets/fonts/*'.
  3. Move 'icomoon/style.css' to 'your-project-name/_sass/custom-icons.scss'; note the .scss extension.
  4. Open the '_sass/custom-icons.scss' file.
  5. Change all the url paths by prepending ../font before the font/icomoon.* The - * represents all extension names here.

    Example
    • url('fonts/icomoon.eot?fscaxe');
    • url('../fonts/icomoon.eot?fscaxe');
  6. Add the relative @import 'custom-icons'; to the main .scss file(s) to include the icons.

  7. Remember the semi-colon at end of the @import 'custom-icons'; statement.
like image 171
Skull0inc Avatar answered Oct 10 '22 11:10

Skull0inc


Instead of using @include, try @font-face instead like this:

@font-face {
  font-family: "Icomoon";
  src: url("../assets/fonts/font/icomoon.tff");
}

Reference: https://developer.mozilla.org/en-US/docs/Learn/CSS/Styling_text/Web_fonts

like image 33
theJoi Avatar answered Oct 10 '22 12:10

theJoi