“inherit” and Typography Control
-
Hey there,
Quick question regarding the typography control.
The main typography control deals with the body and this is where the font for the entire theme is set. The default is Source Sans Pro, the variant is set to regular.
OK so there are other typography controls in the other sections of the customizer that will, of course allow the user to change the font of the area where a typography control is.
So instead of going in and setting a default font for every typography control in every section, is there a way to set the font-family to “inherit” so all the other fonts use Source Sans Pro with a variant of regular?
This is the body typography control
TotalPress_Kirki::add_field('totalpress_theme_customizer',array( 'type' => 'typography', 'settings' => 'totalpress_theme_body_font', 'label' => esc_attr__('Body Font','totalpress' ), 'tooltip' => esc_attr__('Change the font family of your theme. Default is Source Sans Pro.','totalpress'), 'section' => 'totalpress_typography_section', 'priority' => 1, 'transport' => 'auto', 'default' => array( 'font-family' => 'Source Sans Pro', 'variant' => 'regular', 'font-size' => '17px', 'line-height' => '1.5', 'letter-spacing' => '0', 'subsets' => array('latin-ext'), 'text-transform' => 'none' ), 'choices' => array( 'variant' => array( 'regular', '700', '900', ), ), 'output' => array( array( 'element' => 'body', 'function' => 'css', 'property' => 'font-family,font-size,font-weight,line-height,letter-spacing,text-transform', ), ), ));
I played around and created the following typography control for a customizer section:
TP_Primo_Kirki::add_field('totalpress_theme_customizer',array( 'type' => 'typography', 'settings' => 'tp_primo_post_title_font', 'label' => esc_attr__('Post Title Font','tp-primo'), 'tooltip' => esc_attr__('Change the font family of post titles. Default is inherit, 35px, 1.2','tp-primo'), 'section' => 'tp_primo_post_typography_section', 'priority' => 1, 'transport' => 'auto', 'default' => array( 'font-family' => 'inherit', 'variant' => '900', 'font-size' => '35px', 'line-height' => '1.2', 'letter-spacing' => '0', 'subsets' => array('latin-ext'), 'text-transform' => 'none' ), 'choices' => array( 'fonts' => array( 'standard' => array( 'inherit', 'serif', 'sans-serif', 'monospace', ), ), 'variant' => array( '900', '700', 'regular', ), ), 'output' => array( array( 'element' => '.post h1.entry-title,.post h2.entry-title,.post h1.entry-title a,.post h2.entry-title a', 'function' => 'css', 'property' => 'font-family,font-size,line-height,letter-spacing,text-transform', ), ), ));
Now, I don’t even know if that’s correct, but
inherit
did show up in the list of available fonts. Cool. So for this particular control I changed the font to Montserrat, with a variant of 900…worked great.So then I decided to switch it back, so I selected “inherit”, worked like a charm BUT i did notice that the variant got set to regular. So I went in to change it to 900 BUT 900 was not available, only 700.
So it worked but only kinda worked…lol.
What yah think? Any help is greatly appreciated.
- The topic ‘“inherit” and Typography Control’ is closed to new replies.