Black Friday Sale! Get up to $40 off GP Premium!Learn more

[Resolved] Fonts in TinyMCE

Home Forums Support Fonts in TinyMCE

Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • #373262
    Luis

    I’m using GP premiun with Visual Composer and TinyMCE.
    GP’s management of the typography is perfect, but when I enter TinyMCE between the fonts to choose, I do not appear the ones that use GP typography.
    Is it possible to copy in TinyMCE this typography (fonts) so that they appear in both places the same?
    I assume that as GP loads Google Fonts, this is no longer necessary, and it would be sufficient to appear and can be selected in TinyMCE!
    Can you help me?
    Thank you very much.

    #373411
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Fonts typically aren’t select-able in TinyMCE unless you’re using a plugin.

    Also, with the new Gutenberg editor on the horizon, TinyMCE is likely going to be gone.

    #373441
    Luis

    If, indeed, I use TinyMCE Advanced
    Is it possible to copy in TinyMCE Advanced this typography (fonts) so that they appear in both places the same?
    Thank you

    #373612
    Tom
    Lead Developer
    Lead Developer

    I’m not sure – they would have to have some sort of filter which you could add your custom fonts to. Perhaps asking over in their support – if they can provide a filter, I should be able to help with some code.

    #374284
    Luis

    It is possible to use this code:

    function my_mce_settings_font ( $settings ) {
    $font_formats= ‘Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;AkrutiKndPadmini=Akpdmi-n’;

    $settings[‘font_formats’] = $font_formats;
    return $settings;
    };
    add_filter(‘tiny_mce_before_init’, ‘my_mce_settings_font’);

    The question is if GP has a function that returns the fonts it uses, and copy them into $font_formats

    If this is not possible, do not worry, I can add just the font I’m going to use, and that’s it!

    Thank you very much, and sorry for my bad English.

    #374486
    Tom
    Lead Developer
    Lead Developer

    So you’re trying to get every font family option that you’ve set in the Customizer?

    #374635
    Luis

    Yes it is. I could look at the customirzer every time, and copy them in the filter, but every web would touch me to do the same. If there were any way to get them, it would be more comfortable.

    #374786
    Tom
    Lead Developer
    Lead Developer

    This is how you would get those values:

    $settings = wp_parse_args( 
        get_option( 'generate_settings', array() ), 
        generate_get_default_fonts() 
    );
    
    $settings[ 'font_top_bar' ];
    $settings[ 'font_site_title' ];
    $settings[ 'font_site_tagline' ];
    $settings[ 'font_navigation' ];
    $settings[ 'font_widget_title' ];
    $settings[ 'font_buttons' ];
    $settings[ 'font_heading_1' ];
    $settings[ 'font_heading_2' ];
    $settings[ 'font_heading_3' ];
    $settings[ 'font_heading_4' ];
    $settings[ 'font_heading_5' ];
    $settings[ 'font_footer' ];
    #375191
    Luis

    Fantastico, try it and I’ll tell you.
    The body font I suposse is ‘font_body’ ok?

    #375461
    Tom
    Lead Developer
    Lead Developer
    #375854
    Luis

    Hello Tom,
    Something must be wrong, because nothing comes out (the screen goes blank). The code I put is:

    function my_mce_settings_font ( $settings ) {

    $generate_settings = wp_parse_args(
    get_option( ‘generate_settings’, array() ),
    generate_get_default_fonts()
    );

    $settings[‘font_formats’] = $generate_settings[‘font_body’];

    return $settings;
    };
    add_filter(‘tiny_mce_before_init’, ‘my_mce_settings_font’);

    Thank you.

    #376218
    Tom
    Lead Developer
    Lead Developer

    Give this a shot:

    function my_mce_settings_font( $settings ) {
    
    	$generate_settings = wp_parse_args(
    		get_option( 'generate_settings', array() ),
    		generate_get_default_fonts()
    	);
    
    	$settings['font_formats'] = $generate_settings['font_body'];
    
    	return $settings;
    }
    add_filter( 'tiny_mce_before_init' , 'my_mce_settings_font' );
    #376568
    Luis

    Sorry, I do not understand.
    Give him a chance?
    But it’s the same code, right?
    Thank you

    #376795
    Tom
    Lead Developer
    Lead Developer

    I made sure there’s no syntax errors which would turn the screen white.

    If you add that into a plugin like Code Snippets, it won’t cause any blank screens 🙂

    #376936
    Luis

    OK. I’ve tried it, and same thing happens.
    It does nothing, and leaves the window blank.
    Thank you. 🙂

Viewing 15 posts - 1 through 15 (of 23 total)
  • You must be logged in to reply to this topic.