Last active
December 11, 2024 08:32
-
-
Save thomasloven/97c2a441abff7e735b77bc4aff5f7c5e to your computer and use it in GitHub Desktop.
Use custom fonts in Home Assistant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /config/configuration.yaml | |
... | |
lovelace: | |
mode: yaml | |
resources: | |
- url: /local/myfont.css | |
type: css | |
... | |
frontend: | |
themes: | |
change_font: | |
paper-font-body1_-_font-family: myfont |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
/config/www/myfont.css | |
Also need /config/www/myfont.ttf | |
or whatever file format it is, could be several. | |
src: may need to be adjusted with a format() function or so - check the font docs. | |
--> | |
@font-face { | |
font-family: "myfont"; | |
src: url("/local/myfont.ttf"); | |
} |
Commenting as I did not understood this myself in the beginning (HA rookie here). Remember that if you are using HACS, you should not define this part in your configuration.yaml:
lovelace:
mode: yaml
resources:
- url: /local/myfont.css
type: css
But rather add the resource in hacs (three dots in top right corner).
Then you can overwrite the html variable in your theme as this:
# /config/configuration.yaml
frontend:
themes:
my_custom_theme:
# Font
primary-font-family: "Newly imported font-family name"
paper-font-common-base_-_font-family: "var(--primary-font-family)"
Note that I used common-base instead of body1 as OP did
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How is this not in the UI yet?