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.