Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How do I change the font? #1981

Answered by rjzupkoii
mohsin651 asked this question in Q&A
Discussion options

How can I globally change the font on a website, including the footer, navbar, and sidebar?

You must be logged in to vote

The master location for fonts is in _sass/_variables and the lines that govern the fonts look like this:

$global-font-family : $sans-serif;
$header-font-family : $sans-serif;
$caption-font-family : $serif;

By default the $sans-serif variable is used which uses the following default and fail overs:

$sans-serif : -apple-system, ".SFNSText-Regular", "San Francisco", "Roboto", "Segoe UI", "Helvetica Neue", "Lucida Grande", Arial, sans-serif;

If you are going to change the template font is recommended that you define a new font variable that includes fail overs like the $sans-serif variable and then assign that variable to the primary variables listed above.

Replies: 2 comments 3 replies

Comment options

The master location for fonts is in _sass/_variables and the lines that govern the fonts look like this:

$global-font-family : $sans-serif;
$header-font-family : $sans-serif;
$caption-font-family : $serif;

By default the $sans-serif variable is used which uses the following default and fail overs:

$sans-serif : -apple-system, ".SFNSText-Regular", "San Francisco", "Roboto", "Segoe UI", "Helvetica Neue", "Lucida Grande", Arial, sans-serif;

If you are going to change the template font is recommended that you define a new font variable that includes fail overs like the $sans-serif variable and then assign that variable to the primary variables listed above.

You must be logged in to vote
0 replies
Answer selected by rjzupkoii
Comment options

How to use external font, I installed "Lucida Sans" on my system, and replace in the place of "-apple-system", it worked locally, but not on deployment, why so?

You must be logged in to vote
3 replies
Comment options

How your web browser goes about resolving fonts can be a bit tricky, but the short answer is that unless you serve a font as part of website (which has technical as well as licensing issues) there's no real guarantee that users will be able to see the font. Hence why there is a failover string on the template - to give the web browser more options to gracefully resolve the font.

Comment options

@rjzupkoii Any pointers on how to use a font like that? For example, if I add the font to my repository (which I have), how can I get it to work?

Comment options

Okay, I think I've figured out how to do it. Not sure if it's the appropriate way to go about doing this. What I did was:

  • I uploaded the desired font family somewhere in the repository (I went for assets/fonts).
  • I added a .css file for the font family at assets/css and modified its src tags (?) to point to the right location for the fonts.
  • I edited custom.html under _includes/head to include the new .css file for the desired font (just by copying the line for the academicons font and modifying the new line).
  • I edited themes.scss and added the right font names to the $serif, $sans-serif and other required variables.

After all of this was done and the changes were pushed, it started to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
faq Frequently Asked Questions
Converted from issue

This discussion was converted from issue #1959 on March 12, 2024 02:18.

AltStyle によって変換されたページ (->オリジナル) /