Adding custom fonts (local) to WordPress?

I have this code: @font-face { font-family: 'Miller Banner Light'; src: url('fonts/Miller-Banner-Light-01.eot'); /* IE9 Compat Modes */ src: url('fonts/Miller-Banner-Light-01.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ url('fonts/Miller-Banner-Light-01.woff') format('woff'), /* Pretty Modern Browsers */ url('fonts/Miller-Banner-Light-01.ttf') format('truetype') /* Safari, Android, iOS */ } Which in theory allows to add these fonts to my theme, unfortunately, simply creating the fonts folder and putting in the files doesn't work. I read about having to create a child-theme but is that the only way?
Category: Web

Adding google fonts to WordPress theme

I am trying to add google fonts to a custom WordPress theme. Therefore I tried to enqueue selected three font faces at once to make it fast loading. So, I use the below codes to register and enqueue the same. wp_register_style('googlFonts', '//fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&family=DM+Serif+Display&family=La+Belle+Aurore&display=swap'); wp_enqueue_style('googlFonts'); When I search via source code I can only see the last font. Other fonts are not loading. Even I can't see the same complete URL in the source code. Below is what I saw from the …
Category: Web

Why my wordpress website does not display urdu text fully while searching for any thing on its search bars?

Hell0, I have a WordPress website which I have edited for urdu website. When opening this website on a computer it works well and there is no problem. But when you open this website through an android mobile and go to search bars and enter urdu words there, the words does not look clearly to us. This is the main problem which should be fixed. Check the website now for this issue at http://www.madaklasht-today.com. I also used paddings, padding top, …
Category: Web

How can I set Cache TTL for woff and woff2 font files with htaccess?

My WordPress site htaccess file currently has these entries to set cache expiry for woff and woff2 font files: <IfModule mod_expires.c> # Content type AddType application/font-woff .woff AddType application/font-woff2 .woff2 ExpiresActive on # Web fonts ExpiresByType application/font-woff "access plus 1 year" ExpiresByType application/font-woff2 "access plus 1 year" </IfModule> But I'm still getting suggestions to set cache TTL for these files in speed testing tools. Here's one example with a cache efficiency problem: https://gtmetrix.com/reports/bydik.com/ad8hZTzh/ Is there anything wrong with my htaccess …
Category: Web

I have a wordpress website which uses a really weird font on Opera. What do I need to do to fix it?

I have a website which gets this font: when shown in Opera. Other websites work just fine and that very website works just fine in Firefox and Chrome. Is there something improperly setup in my Wordpress website? Notes: I'm using the default Twenty Twenty-One theme with small tweaks, but not in link with the fonts at first; Now I force "sans-serif", but I still see the issue with Opera...
Category: Web

Google Fonts some font-weights not rendering properly

I've imported Josefin Sans from Google Fonts by adding it to wp-includes/functions.php: function load_google_fonts() { wp_register_style('googleFonts', 'https://fonts.googleapis.com/css2?family=Josefin+Sans:wght@100;200;300;400;500;600;700&display=swap'); wp_enqueue_style( 'googleFonts'); } add_action('wp_print_styles', 'load_google_fonts'); and assigning it to a selector in the customizer: * { font-family: 'Josefin Sans'; font-weight: 600; } font-weight values of 400 and above are displayed correctly but values of 300 and below seem to be displayed as 100. See font-weights from 600 to 100: Anything I can do about it?
Category: Web

What's the most efficient way to preload multiple font types using links and enqueue?

I added some code to my theme to preload my self-hosted enqueued fonts that are coming in via @font-face. I then added a filter to set the attributes. Seems to work and the pages load a bit faster too. I'm not sure how to handle the various font types—eot ttf woff woff2—in the most efficient way so the browser doesn't load them all for no reason, and to keep the code as minimal as possible. Not sure if there is …
Category: Web

How to remove font awesome from loading in wp theme

Question: How to remove font awesome from loading in theme and replace social icons with images? Theme Hueman - WP Multisite install What I did: In the functions.php of a child theme from Hueman Theme, I add the following code: add_action( 'wp_print_styles', 'tn_dequeue_font_awesome_style' ); function tn_dequeue_font_awesome_style() { wp_dequeue_style( 'fontawesome' ); wp_deregister_style( 'fontawesome' ); } In the customizer > Advanced options> Adicional CSS I insert the following: .fa-facebook::before { content: url("https://example.com/wp-content/uploads/sites/3/2021/11/facebook-30.png"); width: 14px; height: auto; !important; } .fa-twitter::before { content: url("https://example.com/wp-content/uploads/sites/3/2021/11/twitter-30.png"); …
Category: Web

How to host Google fonts in WordPress theme locally?

I'm using a theme for my WordPress which uses 'Raleway' and it requests (13 requests in gtmetrix waterfall) it from Google fonts API. I want to keep using the font. However, I'm trying to reduce the number of requests and the size of my page. Can I include/integrate the fonts on my website so the browser won't have to execute any external requests? many thanks
Category: Web

How find what plugins load google Font and block it

I'm currently using Zeen theme and a couple of other plugins. I've checked all the settings of the plugins and I've disabled all the voices about Google Font. Now, my theme loads a font via CSS but, checking my GTMetrix the site load more than 10 .woff fonts from fonts.gstatic.com . At the moment I'm delaying the load of the fonts via this JS script <script type="text/javascript"> WebFontConfig = { google: { families: [ 'Playfair+Display:700,italic,400|Open+Sans:400,700|Montserrat:400,700' ] } }; (function() { …
Category: Web

How to manually remove preload fonts settings in Wordpress?

We had some plugin installed that preloads fonts. We do no use the plug in anymore but in the console we have errors like this (see also the screenshot): GET ../wp-content/themes/fonts/libre-franklin-v7-latin-800.woff2 net::ERR_ABORTED 404 This is probably caused by the preload plugin. We do not remember the name of the plugin since we have tried out several. Question is: how can we manually remove traces of this plugin (and others)?
Category: Web

How can I allow upload of ttf or otf font files when hooking `upload_mimes` doesn't work

I tried hooking the upload_mimes hook in order to add support for ttf files to be uploaded, however this didn't immediately work (.ttf files were still blocked). The reason isn't entirely clear to me but I assume Wordpress's calculated MIME type for the file I'm trying to upload and the MIME type I'm adding to the upload_files hook don't match.
Category: Web

Google Font wont dequeue

I'm having an issue getting one of the google fonts to dequeue on my site https://subscriptionboxes.co.nz I've done all the reading, and I can see it needs to be dequeued after its been called, but before its been printed, but I cant figure out how to find that info? I also cant work out which plugin is making the call? This is the code I have put in my child functions.php function remove_google_fonts_stylesheet() { wp_dequeue_style( 'googleFontsOpenSans' ); wp_dequeue_style( 'google-fonts-1' ); …
Category: Web

Font awesome icons not showing: 'access-control-allow-origin

I recently switched to a multisite, but since then the font awesome icons don't show up anymore on one subsite of the multisite. The icons do show up on my other subsite. On my staging site, also a multisite, the icons show up on both sites. Access to font at 'https://secureservercdn.net/blabla.com/wp- content/themes/ave/assets/vendors/font-awesome/fonts/fontawesome-webfont.ttf?v=4.7.0' from origin 'https://example.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. What could be the problem? edit: investigating further reveals that …
Category: Web

Default font in 2012?

I have no idea if I'm using 'gutenberg' or whatever. I'm simply trying to set a default fond in 2012 classic editor so I don't have to change every paragraph I type in which is ridiculous. I see no easy/obvious way to do this. thx.
Category: Web

Is there a way to ensure local fonts load from CDN when CDN is enabled?

I've set up a WordPress site with one local font. It is stored in the a fonts folder in the child theme. It is loaded with the following in the child theme style.css @font-face { font-family: 'Last Paradise'; src: url('fonts/LastParadise.eot'); src: url('fonts/LastParadise.eot?#iefix') format('embedded-opentype'), url('fonts/LastParadise.woff2') format('woff2'), url('fonts/LastParadise.woff') format('woff'), url('fonts/LastParadise.ttf') format('truetype'), url('fonts/LastParadise.svg#LastParadise') format('svg'); font-weight: normal; font-style: normal; } The site has a CDN, which is currently activated by the bunny.net CDN plug-in. Although I've tried various other options, such as the CDN …
Category: Web

Can I share predefined fonts from theme_support with a gutenberg component?

I have a few fonts defined in my functions.php: add_theme_support('editor-font-sizes', array( array( 'name' => esc_attr__('Small', 'moderna'), 'size' => 13, 'slug' => 'small' ), ...... array( 'name' => esc_attr__('Headline', 'moderna'), 'size' => 40, 'slug' => 'headline' ) )); I want to use these defined fonts now in a FontSizePicker Component from Gutenberg. However I do not want to define these two times. Is there any way to get these fonts from php to the wordpress block? <InspectorControls> <FontSizePicker fontSizes={GET_FONTS_FROM_THEME_SUPPORT()} value={26} fallbackFontSize={12} …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.