- This topic has 29 replies, 4 voices, and was last updated 3 years, 1 month ago by
Ying.
-
AuthorPosts
-
January 10, 2023 at 4:36 am #2489970
Bart
Hi
I am trying to add custom fonts to the generatepress, I add PHP function trough snippet and save and activate it however still when I am uploading files trough media I get the information that I cant do it… Can you help me please
January 10, 2023 at 6:24 am #2490087David
StaffCustomer SupportHi there,
which fonts are you trying to add ?
January 10, 2023 at 6:32 am #2490096January 10, 2023 at 8:30 am #2490372David
StaffCustomer SupportWhat file types are you trying to upload ? eg. woff, ttf etc.
January 10, 2023 at 11:36 am #2490572Bart
Hi David
There is only one file and it is .ttf
January 10, 2023 at 6:43 pm #2490814Fernando Customer Support
Hi Bart,
It may be that a security plugin or security mod on your server is stopping those from being uploaded.
If you want to upload that, try accessing your wp-config.php file through FTP then add
define('ALLOW_UNFILTERED_UPLOADS', true);inside the file.Alternatively, unless you need very specific TTF styling options you may want to consider just loading
.woffand.woff2fonts instead as they are supported across all modern browsers.And if you only have
ttffonts you can use a font convertor like the one at Font Squirrel to convert them: https://www.fontsquirrel.com/tools/webfont-generatorJanuary 11, 2023 at 5:47 am #2491290Bart
Great! I was able to upload TTF, WOFF and WOFF2 files however the font is not google font so i cant generate CSS for that. How do I now can use this font ?
January 11, 2023 at 7:02 am #2491409David
StaffCustomer SupportYou will need to write your own @font-face CSS.
Heres a template you can use for each font / font variant you have uplaoded:@font-face { font-family: 'Your Font name'; src: url('the_full_url_to_the_font_folder/fontname.woff2') format('woff2'), url('the_full_url_to_the_font_folder/fontname.woff') format('woff'); font-weight: normal; font-style: normal; }If you select the font in the Media Library it will provide you the Full URL.
January 11, 2023 at 9:23 am #2491702Bart
I did everything and still it does not appear in the typography ;(
January 11, 2023 at 9:48 am #2491733David
StaffCustomer SupportNow in Typography > Font Manager.
In the FONT FAMILY NAME field just type in the Name you added in your @font-face CSS font-family.
DO NOT Toggle the Google Font API and just click add.Then when you add New Typography you will be able to select your custom font
January 11, 2023 at 10:05 am #2491750Bart
Awesome. It worked, It just not apply on the view when i build the page but when I publish it and view as a normal website font is there 🙂 thank you
Last question, is there an easy way to justify text ?
January 12, 2023 at 3:12 am #2492595David
StaffCustomer SupportYou can tell WordPress to load the fonts in the editor by adding a PHP function.
Did you add the @font-face CSS to the Customizer > Additional CSS?If so add this PHP Snippet:
add_filter( 'block_editor_settings_all', function( $editor_settings ) { $css = wp_get_custom_css_post()->post_content; $editor_settings['styles'][] = array( 'css' => $css ); return $editor_settings; } );If you added the CSS elswhere let me know.
For justifying text, where do you want to apply it ?
Is it across the site or just for specific paragraphs ?January 12, 2023 at 4:09 am #2492651Bart
Hi David
You are a magician 😀 It worked
Justify I would like to do to specific text blocks.
January 12, 2023 at 8:01 am #2493029David
StaffCustomer SupportIf you use a GenerateBlocks Headline block when you want Justified text, you can a) change the heading tag from a H2 to any text tag including the
pand b) in its text align options it has justified.January 12, 2023 at 8:04 am #2493038Bart
Hi David
I do use the GenerateBlocks and I got only three options when aligning the text and its left center or right. I do use the newest version of the GB and GP but don’t have the option to justify despite the headline block is H or P .
-
AuthorPosts
- You must be logged in to reply to this topic.