Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to overwrite the font? #52

Open
AntoniosBarotsis opened this issue Aug 2, 2023 · 5 comments
Open

Is it possible to overwrite the font? #52

AntoniosBarotsis opened this issue Aug 2, 2023 · 5 comments

Comments

@AntoniosBarotsis
Copy link
Contributor

AntoniosBarotsis commented Aug 2, 2023

I have currently added the following in my own scss file:

* {
  font-family: '...' !important;
}

Which works fine, but, the hack font is still downloaded, wasting some amount of time on the initial page load. Is that something I could change without making changes to the theme's code itself?

Edit: I realize that this might be more of a zola question than a theme question but I couldn't find anything in the docs so I'm just asking here for now.

@marcospb19
Copy link

marcospb19 commented Oct 19, 2023

I believe you have to change the theme code itself, yes.

@pawroman
Copy link
Owner

pawroman commented Dec 18, 2023

It's not that hard to change this, the theme would have to basically expose an extra switch.

I would be glad to accept this as a contribution, e.g. a true by default switch to enable the Hack font (e.g. config.extra.use_hack_font).

See https://github.com/pawroman/zola-theme-terminimal/blob/master/templates/macros/head.html#L22-L26

Or, an alternative approach -- wrap all the font styles in a named block which could be overridden by theme users. But there, I'm not sure how it would interact with the macros. Would have to test this approach, and if it works -- could introduce named blocks for all elements of the headers.

@AntoniosBarotsis
Copy link
Contributor Author

So I tried commenting out lines 22-26 completely but running zola build still puts all the fonts in my newly created public folder. That shouldn't be happening right 🤔

@AntoniosBarotsis
Copy link
Contributor Author

AntoniosBarotsis commented Dec 22, 2023

This would probably work fine if we completely removed the fonts from the static folder and imported them like I do here (in retrospect, I am not even sure if this is even needed, anything UI related is not my strongest area 😅) and add the remote urls in a scss file (like here) instead of pointing them to the fonts/ folder.

The scss file would work the same way you are now choosing between the hack font subset or opting in to the full one here.

It could look something like this:

{%- if config.extra.use_full_hack_font %}
    <link rel="stylesheet" href="{{ get_url(path="font-hack.css", trailing_slash=false) | safe }}">
{% else if config.extra.remove_hack_font %}
  <!-- if remove_hack_font -> include no css file -->
{% else %}
    <link rel="stylesheet" href="{{ get_url(path="font-hack-subset.css", trailing_slash=false) | safe }}">
{% endif -%}

I think having the hack font be opt-out is better so as to not break everyone's blogs with the new update; you would have to change your config only to remove the font, otherwise everything should stay the same, hence the remove_hack_font.

Let me know your thoughts!

Edit: As a clarification, my github pages fonts folder does indeed not include my chosen font (FiraCode) as it is being loaded from a CDN instead.

@AntoniosBarotsis
Copy link
Contributor Author

AntoniosBarotsis commented Dec 23, 2023

An update on this, I made the changes in my fork here and used it in my blog.

Without changing anything:

  1. The static/fonts folder was no longer there
  2. font-hack-subset.css was included (checked this via the browser sources tab

Setting remove_hack_font = true in my blog's config.toml removes the font-hack-subset.css file.

Is this something that would work for you as well? Maybe it's a good idea to check manually this time 😅, I've modified a bunch of files on my blog and there's some inconsistencies sometimes with the original.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants