Google Fonts Short Code - Line height

Hi team,

Is it possible to change the line height when using the Google Font short code? If not, could you add it as a feature please?

It looks to default to the same as the font size, but I need more control. Also being able to superscript and subscript would also be handy if possible. I have tried a work around using <span> and <div> but couldn't get it working, unless you know of another solution....?

Thanks

Comments

  • Hi,
    I do not understand the question.
    You want to increase the line height value of the custom font added in theme options?
    It inherits the options of place where you applied it.
    I mean, if you applied it to "Content"(Theme Options > Fonts > Family), then size and style will be taken from there (Theme Options > Fonts > Size & Style)

    Thanks
  • No, sorry let me explain again.

    I am using the "Google_font" shortcode - [google_font font="Open Sans" size="25" weight="400" italic="0" letter_spacing="" color="#fff" subset=""]Insert your <br />content here[/google_font]

    I want to be able to control the line height independently of the font size but there is no attribute available in the short code to edit, but it is present in the CSS.

    Am I able to edit the Google_font shortcode to add the "line-height" attribute and put it in my child theme for future use?

    Thanks
  • I got this, thanks you.
    The "Line Height" value is the same as the provided value in 'size' parameter.
    Unfortunately, there is no way to increase that value using the shortcode, you can only customize it with the custom css.

    If you would like to see it as a next feature of betheme, please post your suggestion here:

    Thanks
  • Thanks Pablo. I'll add it to the list, I managed to customise the files anyway.

    For anyone wanting to know how. I customised the theme-shortcode.php file to get it working anyway and added it to my Child theme.

    /**
     * Google Font [google_font]
     */

    if (! function_exists('sc_google_font')) {
    function sc_google_font($attr, $content = null)
    {
    extract(shortcode_atts(array(
    'font' => '',

    'size' => '25',
    'line_height' => '25',
    'weight' => '400',

    'italic' => '',
    'letter_spacing' => '',
    'subset' => '',

    'color' => '',
    'inline' => '',
    ), $attr));

    // style

    $style_escaped = array();
    $style_escaped[] = "font-family:'". esc_attr($font) ."',Arial,Tahoma,sans-serif;";
    $style_escaped[] = "font-size:". intval($size, 10) ."px;";
    $style_escaped[] = "line-height:". esc_attr($line_height, 10) ."px;";
    $style_escaped[] = "font-weight:". esc_attr($weight) .";";
    $style_escaped[] = "letter-spacing:". intval($letter_spacing, 10) ."px;";

    if ($color) {
    $style_escaped[] = "color:". esc_attr($color) .";";
    }

    Also, edit the scripts.js file in files theme > functions > builder > js > script.js to add in the field to the shortcode when placed in the editor:

    '[google_font font="Open Sans" size="25" line-height="25" weight="400" italic="0" letter_spacing="" color="#626262" subset=""]Insert your content here[/google_font]',
Sign In or Register to comment.
This website uses cookies

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.

Cookies are small text files that can be used by websites to make a user's experience more efficient.

The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies we need your permission. This means that cookies which are categorized as necessary, are processed based on GDPR Art. 6 (1) (f). All other cookies, meaning those from the categories preferences and marketing, are processed based on GDPR Art. 6 (1) (a) GDPR.

This site uses different types of cookies. Some cookies are placed by third party services that appear on our pages.

You can at any time change or withdraw your consent from the Cookie Declaration on our website.

Learn more about who we are, how you can contact us and how we process personal data in our Privacy Policy.

Please state your consent ID and date when you contact us regarding your consent.