How to add true italics

Posted in: Newsmag
Post count: 25

Sorry if this is duplicated in some way but the other post where I asked this (but didn’t start) is not being answered (although all around them seem to be).

I need the true italics on Google fonts like open sans, etc. What is the best way to achieve this? Please.

Thanks,

Jeff

Post count: 6600

Hi,

Sorry for the delay!
Have you tried to set it trough custom css and target the fonts you need as Open Sans and apply the font-family and style, like this:

a {
font-family: Opens Sans;
font-style: italic;
}

Please let me know and also send your site’s URL.

Thanks

Post count: 9544

Note that in the td_fonts.php file it does appear italic is specified to be loaded from line 889 (this whole block was found in functions.php in Newspaper theme for those who are moving over).

e.g.,

wp_enqueue_style('google-font-rest', td_global::$http_or_https . '://fonts.googleapis.com/css?family=PT+Sans:400,700,400italic|Ubuntu:400,400italic|Open+Sans:400italic,400|Oswald:400,700|Roboto+Condensed:400italic,700italic,400,700'); //used on menus/small text

That “should” be loading the “normal” body font (400 weight) in both normal and true italic (vs oblique/slanted non-italic font).

Check your page source for a post to see if that is actually there.

Similarly at line 902 this is found; presumably this would be enabled and enqueued if selected from the theme fonts selectors:
if(!in_array('g_438', $td_user_fonts_list)) {//'g_438', //Open Sans
wp_enqueue_style('google-font-opensans', td_global::$http_or_https . '://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700&subset=latin,cyrillic-ext,greek-ext,greek,vietnamese,latin-ext,cyrillic'); //used on menus/small text

This has the light, normal, semi-bold, and bold weights, however does not have the italics, which I am not sure appends or replaces the main element at line 889.

Likely if one were so inclined they would edit the line 889 to add all the weights desired for Open Sans, remove the fonts and languages not being used, following the schema spit out from the Google Fonts website font builder:
http://www.google.com/fonts#UsePlace:use/Collection:Open+Sans

e.g., Open+Sans:300italic,400italic,600italic,700italic,400,300,600,700

so, you could edit this code like so:
wp_enqueue_style('google-font-rest', td_global::$http_or_https . '://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,300,600,700'); //used on menus/small text

For expert users, one might actually remove that block from the td_fonts.php file entirely, edit the style.css to search/replace all fonts to Open Sans, then grab the CSS from Google’s server by loading the above URL in a browser, and putting all the styles at bottom of the style.css sheet (I actually did this for Newspaper on one site, for better PageSpeed Insights score).

I only provide these examples as possible solutions and they may not apply to you. Hope that helps somebody on this topic.

Post count: 25

Christopher, thanks again for your lengthy solution, but I really wanted to keep this post simple… that’s why I separated it from the other one so as to keep the focus and get some help from the staff on this particular topic.

Lucian, what we need is a solution that would apply any time we call an italic using Open Sans (or any other Google font if need be that has a true italic)… in a post, page or whatever. And, I don’t think it should be wiped out every time I update. Simple as that. If possible.

Lucian, normally I would not make this public yet because I’m still building it, but since there is no private here and you asked… http://positivityworld.com

Thanks… Jeff

Post count: 9544

Righto… I was also posting this for radu o. And co in case the italic fonts were not, in fact, being loaded.

Did you actually look at your page source to see if the italic font is being called from google or not?

Post count: 25

Doesn’t look like it… but it’s calling a number of others…

<link rel='stylesheet' id='google-font-opensans-css'  href='http://fonts.googleapis.com/css?family=Open+Sans%3A300%2C400%2C600%2C700&subset=latin%2Ccyrillic-ext%2Cgreek-ext%2Cgreek%2Cvietnamese%2Clatin-ext%2Ccyrillic&ver=4.0.1' type='text/css' media='all' />
<link rel='stylesheet' id='google-font-ubuntu-css'  href='http://fonts.googleapis.com/css?family=Ubuntu%3A300%2C400%2C500%2C700%2C300italic%2C400italic%2C500italic%2C700italic&subset=latin%2Ccyrillic-ext%2Cgreek-ext%2Cgreek%2Clatin-ext%2Ccyrillic&ver=4.0.1' type='text/css' media='all' />
<link rel='stylesheet' id='google-font-pt-sans-css'  href='http://fonts.googleapis.com/css?family=PT+Sans%3A400%2C700%2C400italic&subset=latin%2Ccyrillic-ext%2Clatin-ext%2Ccyrillic&ver=4.0.1' type='text/css' media='all' />
<link rel='stylesheet' id='google-font-oswald-css'  href='http://fonts.googleapis.com/css?family=Oswald%3A400%2C300%2C700&subset=latin%2Clatin-ext&ver=4.0.1' type='text/css' media='all' />
<link rel='stylesheet' id='google-roboto-cond-css'  href='http://fonts.googleapis.com/css?family=Roboto+Condensed%3A300italic%2C400italic%2C700italic%2C400%2C300%2C700&subset=latin%2Ccyrillic-ext%2Cgreek-ext%2Cgreek%2Cvietnamese%2Clatin-ext%2Ccyrillic&ver=4.0.1' type='text/css' media='all' />
<link rel='stylesheet' id='google-vollkorn-css'  href='http://fonts.googleapis.com/css?family=Vollkorn%3A400italic%2C700italic%2C400%2C700&ver=4.0.1' type='text/css' media='all' />
<link rel='stylesheet' id='google-fonts-style-css'  href='http://fonts.googleapis.com/css?family=Lato%3A400%2C700%7CDroid+Serif%3A400%2C700&ver=4.0.1' type='text/css' media='all' />

Many of these I am not using at all.

  • This reply was modified 11 years by agent314.
Post count: 9544

Yeah.. Looks like italics need to be added to the section at line 902 in the fonts file.

Post count: 6600

Hi,

Thanks Christopher!
You are right unfortunately we do have an issue with this. Emil wrote in details about this here: https://forum.tagdiv.com/topic/how-to-add-additional-google-fonts-weightstyle/#post-28943

Sorry for the inconvenience!

Viewing 8 posts - 1 through 8 (of 8 total)
The forum ‘Newsmag’ is closed to new topics and replies.