- This topic has 15 replies, 3 voices, and was last updated 3 years, 3 months ago by
David.
-
AuthorPosts
-
January 19, 2023 at 4:50 am #2501360
Luke
Hi,
I am trying to download local fonts and am following the instructions in your video. When I copy the CSS into the snippits plugin it displays a “syntax error, unexpected token “:”
The code is exactly the same and I have tried multiple different fonts and still the same result, any ideas?Luke
January 19, 2023 at 5:31 am #2501400David
StaffCustomer SupportHi there,
can you paste your code here.
Before submitting the reply, highlight the CSS and clickCODEbutton in the toolbar. This will preserve its formatting.January 19, 2023 at 6:07 am #2501432Luke
/* nunito-regular - latin */ @font-face { font-family: 'Nunito'; font-style: normal; font-weight: 400; src: url('../fonts/nunito-v25-latin-regular.eot'); /* IE9 Compat Modes */ src: local(''), url('../fonts/nunito-v25-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ url('../fonts/nunito-v25-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */ url('../fonts/nunito-v25-latin-regular.woff') format('woff'), /* Modern Browsers */ url('../fonts/nunito-v25-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */ url('../fonts/nunito-v25-latin-regular.svg#Nunito') format('svg'); /* Legacy iOS */ }January 19, 2023 at 6:35 am #2501455David
StaffCustomer SupportI can’t see any issue with that code.
In the snippets plugin you’re using does that have an option to set the snippet toCSS– as i get the impression its expecting some other code eg.PHP?I would also recommend you use the Full URL including the domain in the
urlJanuary 19, 2023 at 7:53 am #2501710Luke
It appears the code options Code Snippet allows are;
PHP
HTML
JS – Paid version only
CSS – Paid version onlyAs I havent paid for this the only options I have are PHP and HTML…..
On the video tutorial the guy enters in PHP which is what I am doing?
Very odd, cant believe its this difficult to download a font locally, is there an easier way?January 19, 2023 at 8:26 am #2501768David
StaffCustomer SupportGo to Customizer > Additional CSS and paste the CSS in there.
January 19, 2023 at 9:02 am #2501816Luke
Ok theres no error message and the CSS is in there but when I go to upload the font files into Media it doesnt see any files in the folders. Sorry about this, I even did a full WP reset before talking with you but still nothing.
January 19, 2023 at 9:18 am #2501855David
StaffCustomer SupportDid you add this to your PHP Snippets?
add_filter( 'upload_mimes', function( $mimes ) { $mimes['woff'] = 'application/x-font-woff'; $mimes['woff2'] = 'application/x-font-woff2'; $mimes['ttf'] = 'application/x-font-ttf'; $mimes['svg'] = 'image/svg+xml'; $mimes['eot'] = 'application/vnd.ms-fontobject'; return $mimes; } );January 19, 2023 at 1:04 pm #2502078Luke
I have copy pasted the code in my second message into Customizer > Additional CSS
Snippets will not let me post this without the error
Are you suggesting I copy paste the code in your last message into Snippets?January 19, 2023 at 7:03 pm #2502251Fernando Customer Support
This code is a PHP snippet that should be added through functions.php if you’re using the Child theme or Code Snippets if not: https://generatepress.com/forums/topic/syntax-error-unexpected-token/#post-2501855
Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
This code on the other hand can be added through Appearance > Customize > Additional CSS: https://generatepress.com/forums/topic/syntax-error-unexpected-token/#post-2501432
To clarify, yes, you need this snippet: https://generatepress.com/forums/topic/syntax-error-unexpected-token/#post-2501855 to upload such font files in your site.
January 20, 2023 at 1:25 pm #2503416Luke
Hi, thank you for your patience,
Ok so I added your code to Snippet plugin and added the font PHP to appearance-customize-additional CSS, this allowed me to get one font to work YIPPEE. But whenever I select the other font and switch off “use google fonts API” the font changes back to the default font.
Any ideas why its works on one and not the other? I have repeated the same process, even deleted and re-uploaded several times.
Very frustrating, again I appreciate your patience on this.
Luke
January 21, 2023 at 2:41 am #2503700David
StaffCustomer SupportSo this CSS code:
/* nunito-regular - latin */ @font-face { font-family: 'Nunito'; font-style: normal; font-weight: 400; src: url('../fonts/nunito-v25-latin-regular.eot'); /* IE9 Compat Modes */ src: local(''), url('../fonts/nunito-v25-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ url('../fonts/nunito-v25-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */ url('../fonts/nunito-v25-latin-regular.woff') format('woff'), /* Modern Browsers */ url('../fonts/nunito-v25-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */ url('../fonts/nunito-v25-latin-regular.svg#Nunito') format('svg'); /* Legacy iOS */ }Take one of the URLs for example:
url('../fonts/nunito-v25-latin-regular.woff2') format('woff2'),That needs to have the full URL.
Did you upload the fonts to the Media Library?
If so, select one of the fonts and in the sidepanel it will give you the full url.January 21, 2023 at 9:46 am #2504153Luke
Hi I attempted inserting the full URLs but had no joy, I have also looked into thirdparty plugin for hosting google fonts locally and it seems they struggle to work too. I’m defeated and will go forward using the default fonts available as I have little CSS experience and have wasted too much time on this. I appreciate your patience with me.
Thank youLuke
January 22, 2023 at 6:12 am #2504678David
StaffCustomer SupportOk, let us know if you ever want to revisit this.
January 22, 2023 at 6:15 am #2504681Luke
Will do thank you
Luke
-
AuthorPosts
- You must be logged in to reply to this topic.