• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

,Change Fonts

Scheduled Pinned Locked Moved Custom CSS
fontraspberry pi 3csscustom
10 Posts 5 Posters 7.6k Views 5 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    Lorenzo_Zappa
    last edited by Lorenzo_Zappa Sep 16, 2018, 7:44 PM Sep 16, 2018, 6:19 PM

    Hello everyone,
    I know this is a basic question but I wasn’t able to make it :(
    Basically I want to change font in some (or all) modules, so far this is what I have done in my custom.css file:

    @font-face {
            font-family: SF;
            src: url("/home/pi/.fonts/SFProDisplay-Medium.ttf") format("ttf");
            font-weight: normal;
            font-style: medium;
    }
    
    .newsfeed {
            font-family: SF;
    }
    
    .compliments {
            font-family: SF;
    }
    
    .calendar {
            font-family: SF;
    }
    

    And this is my font permissions in my ~/.fonts folder:

    -rw-r--r-- 1 pi pi 499572 Sep 16 19:29 SFProDisplay-Medium.ttf
    

    The issue is that whatever font I try it doesn’t work (even standard, already installed, fonts), but instead a default module is loaded…
    Any help?
    Lorenzo

    1 Reply Last reply Reply Quote 0
    • P Offline
      PhilReis
      last edited by PhilReis Sep 16, 2018, 6:47 PM Sep 16, 2018, 6:46 PM

      Try this:

      @font-face {
        font-family: "MyFont";
        font-style: normal;
        font-weight: 100;
        src:
          local("SF-Pro-Display-Light"),
          url("/fonts/SF-Pro-Display-Light.otf") format("truetype");
      }
      

      and i have change this too:

      .thin {
        font-family: "MyFont";
        font-weight: 100;
      }
      
      .light {
        font-family: "MyFont";
        font-weight: 300;
      }
      
      .regular {
        font-family: "MyFont";
        font-weight: 400;
      }
      
      .bold {
        font-family: "MyFont";
        font-weight: 700;
      }
      
      

      hope it helps.

      1 Reply Last reply Reply Quote 0
      • L Offline
        Lorenzo_Zappa
        last edited by Lorenzo_Zappa Sep 16, 2018, 7:32 PM Sep 16, 2018, 7:31 PM

        @philreis unfortunately nothing changes…
        Still not working

        1 Reply Last reply Reply Quote 0
        • P Offline
          PhilReis
          last edited by Sep 17, 2018, 5:44 AM

          Try to put your fonts directory in the Magic Mirror directory.

          1 Reply Last reply Reply Quote 0
          • L Offline
            lavolp3 Module Developer
            last edited by Sep 17, 2018, 7:03 AM

            Better use an absolute path (as you did oiginally) instead of the relative one philreis suggested

            @font-face {
              font-family: "MyFont";
              font-style: normal;
              font-weight: 100;
              src:
                local("SF-Pro-Display-Light"),
                url("/home/pi/.fonts/SF-Pro-Display-Light.otf") format("truetype");
            }
            

            The path philreis suggested cannot work as it is.

            How to troubleshoot modules
            MMM-soccer v2, MMM-AVStock

            P 1 Reply Last reply Sep 17, 2018, 11:06 AM Reply Quote 0
            • L Offline
              Lorenzo_Zappa
              last edited by Sep 17, 2018, 7:41 AM

              Ok, I have found a way to make it work, but I don’t like it very much…
              Basically I have to add my lines of code in this file:

              /home/pi/MagicMirror/fonts/roboto.css
              

              Like this:

              @font-face {
                font-family: SF;
                font-style: normal;
                font-weight: 100;
                src:
                  local("SF"),
                  url("SF/SFProDisplay-LightItalic.ttf") format("truetype");
              }
              
              @font-face {
                font-family: Roboto;
                font-style: normal;
                font-weight: 100;
                src:
                  local("Roboto Thin"),
                  local("Roboto-Thin"),
                  url("node_modules/roboto-fontface/fonts/roboto/Roboto-Thin.woff2") format("woff2"),
                  url("node_modules/roboto-fontface/fonts/roboto/Roboto-Thin.woff") format("woff"),
                  url("node_modules/roboto-fontface/fonts/roboto/Roboto-Thin.ttf") format("truetype");
              }
              

              And then everything works.
              Any solution without using this work around? I don’t like it very much, and it is not so clean.
              Thank you

              1 Reply Last reply Reply Quote 0
              • L Offline
                Lorenzo_Zappa
                last edited by Sep 17, 2018, 7:49 AM

                I finally did it :)
                I don’t know why but if I want to declare my font-face in my custom.css file the fonts folder containing all my fonts must be in the same directory or in a sub-directory.
                Now everything works
                Thank you all guys

                1 Reply Last reply Reply Quote 0
                • P Offline
                  PhilReis @lavolp3
                  last edited by Sep 17, 2018, 11:06 AM

                  @lavolp3 my solution works.
                  For the web server is the Magic Mirror directory the “root” directory. So you have to create the fonts directory in the Magic Mirror directory.

                  1 Reply Last reply Reply Quote 0
                  • S sdetweil referenced this topic on Apr 28, 2022, 8:13 PM
                  • T Offline
                    TazDev
                    last edited by May 29, 2022, 7:23 PM

                    what I inserted in my custom.css

                    :root {
                            --font-primary: "SF-Compact";
                            --font-secondary: "SF-Pro";
                    }
                    
                    @font-face {
                      font-family: "SF-Compact";
                      font-style: normal;
                      src:
                        local("SF-Compact"),
                        url("/fonts/SF-Compact.ttf") format("truetype");
                    }
                    
                    @font-face {
                      font-family: "SF-Pro";
                      font-style: normal;
                      src:
                        local("SF-Pro"),
                        url("/fonts/SF-Pro.ttf") format("truetype");
                    }
                    

                    both files I extracted from my Mac and copied it to ~/MagicMirror/fonts

                    D 1 Reply Last reply Jun 3, 2024, 4:58 PM Reply Quote 0
                    • D Offline
                      davidgagne @TazDev
                      last edited by Jun 3, 2024, 4:58 PM

                      @TazDev Thanks! This is exactly what I needed to change my MagicMirror so it displays Aurabesh for some of the data.

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      • First post
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy