Archived topic
Fonts in TinyMCE
22 replies · Started by Luis on August 25, 2017
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.
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.
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
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.
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.
So you're trying to get every font family option that you've set in the Customizer?
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.
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' ];
Fantastico, try it and I'll tell you.
The body font I suposse is 'font_body' ok?
Correct :)
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.
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' );
Sorry, I do not understand.
Give him a chance?
But it's the same code, right?
Thank you
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 :)
OK. I've tried it, and same thing happens.
It does nothing, and leaves the window blank.
Thank you. :-)