How to add new local font?

Is this article you can find the instructions to add a new local non google font to Tower theme. The same instructions are valid for Specular.

First things to do:

  • Connect via FTP to access the theme’s files (wp-content/themes/tower).
  • Downlaod hte font in these formats:

    Capture

  • 1. Copy the fonts at folder ‘tower/font’.
    2. Create a new css file and name it: fonts.css. Upload it at theme’s css directory: ‘tower/css‘.

    Edit that file and enter this:

    @font-face {
      font-family: 'MyWebFont';
      src: url('../font/webfont.eot'); /* IE9 Compat Modes */
      src: url('../font/webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
           url('../font/webfont.woff2') format('woff2'), /* Super Modern Browsers */
           url('../font/../font/webfont.woff') format('woff'), /* Pretty Modern Browsers */
           url('../font/webfont.ttf')  format('truetype'), /* Safari, Android, iOS */
           url('../font/webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
    }
    

    Where ‘MyWebFont’ is the font name. You can give it the name you want;
    ‘webfont.eot’, ‘webfont.ttf’, etc are the font file names (the fonts you added at the Fonts folder).

    3. Edit the file ‘tower/admin/inc/fields/typography/field_typography.php‘. Find the lines (line 19-40):

    if ( ! class_exists( 'ReduxFramework_typography' ) ) {
        class ReduxFramework_typography {
    
            private $std_fonts = array(
                "Arial, Helvetica, sans-serif"                         => "Arial, Helvetica, sans-serif",
                "'Arial Black', Gadget, sans-serif"                    => "'Arial Black', Gadget, sans-serif",
                "'Bookman Old Style', serif"                           => "'Bookman Old Style', serif",
                "'Comic Sans MS', cursive"                             => "'Comic Sans MS', cursive",
                "Courier, monospace"                                   => "Courier, monospace",
                "Garamond, serif"                                      => "Garamond, serif",
                "Georgia, serif"                                       => "Georgia, serif",
                "Impact, Charcoal, sans-serif"                         => "Impact, Charcoal, sans-serif",
                "'Lucida Console', Monaco, monospace"                  => "'Lucida Console', Monaco, monospace",
                "'Lucida Sans Unicode', 'Lucida Grande', sans-serif"   => "'Lucida Sans Unicode', 'Lucida Grande', sans-serif",
                "'MS Sans Serif', Geneva, sans-serif"                  => "'MS Sans Serif', Geneva, sans-serif",
                "'MS Serif', 'New York', sans-serif"                   => "'MS Serif', 'New York', sans-serif",
                "'Palatino Linotype', 'Book Antiqua', Palatino, serif" => "'Palatino Linotype', 'Book Antiqua', Palatino, serif",
                "Tahoma,Geneva, sans-serif"                            => "Tahoma, Geneva, sans-serif",
                "'Times New Roman', Times,serif"                       => "'Times New Roman', Times, serif",
                "'Trebuchet MS', Helvetica, sans-serif"                => "'Trebuchet MS', Helvetica, sans-serif",
                "Verdana, Geneva, sans-serif"                          => "Verdana, Geneva, sans-serif",
                

    after this, add this line:

    'MyWebFont'                                          => "MyWebFont";

    Screenshot: Capture3

    Find the lines:

    if ( isset( $this->field['ext-font-css'] ) && $this->field['ext-font-css'] != '' ) {
                    wp_register_style( 'redux-external-fonts', $this->field['ext-font-css'] );
                    wp_enqueue_style( 'redux-external-fonts' );
                }

    and add this line above it:

                $this->field['ext-font-css'] = CODELESS_BASE_URL.'css/fonts.css';
    

    Screenshot: Capture1

    Save the file.

    4. Edit file ‘tower/functions.php’ and add this line:

    wp_enqueue_style( 'redux-external-fonts' );

    at register global styles function.

    Screenshot:Capture4

    5. Edit file ‘tower/functions-tower.php’ and add this line:

    wp_register_style( 'redux-external-fonts', CODELESS_BASE_URL.'css/fonts.css');

    at register styles function.

    Screenshot:

    Capture5

    That’s it. Now the font will appear in fonts list at typography fields at Tower options

    Untitled1

    https://docs.reduxframework.com/core/advanced/enabling-typography-preview-for-local-fonts/

    Keep in mind to save a backup of the old theme’s files when updating the theme to not loose the changes.

    Comments

    comments

    Was this article helpful?

    Related Articles

    Leave A Comment?