On the font configuration page, there is a box for entering CSS selectors. The caption says: "Use commas to separate multiple selectors, just like you would in CSS. Leave blank to handle application of the font in your theme."
I am interested in the last part of this, i.e. how to apply the font in my theme?
Let's say I'd like to have h2.pane-title selector to use a specific font. First of all, according to documentation, I'd need to declare the font in the theme like this:
fonts[local_fonts][] = "http://localhost/#c666c4a0fd00152da2d2a1030a32530f"
But how to specify in the theme, to which selectors the font will be applied in this particular theme? I tried this: h2.pane-title { font-family: "Asap"} in CSS file but it does not work.
Comments
Comment #1
sreynen commentedThanks for the question. There's actually two different documentation problems here, which I didn't realize until reading this.
There are two parts to putting a font in a theme: loading and applying. You can apply any font in CSS, just like you've done. And you can load a font in the theme's .info file, just like you've done. However, only hosted fonts can be loaded in a theme. Local fonts cannot, despite what the interface suggests, though you can still apply them in the theme. We need to improve the documentation to make this clearer.
If you're just using this font on your own site, you don't need the statement in your theme .info file at all. But the suggestion to leave the selector blank is also wrong (problem #2). That previously worked, but we missed updating the documentation when the code changed. In the current version, fonts need a selector of "<none>" to indicate that they should load, but not have a CSS selector applied. A blank CSS selector does nothing. You can also add the CSS selector under the "Apply" tab after you've enabled the font, which is generally a little easier.
If you're wanting to distribute your theme with the font included, sorry, you won't be able to do that with a local font. Local fonts don't have a consistent URL to use for loading (the suggested URL isn't real), and they also can't be included in any theme hosted on Drupal.org due to the rule against 3rd party components. So the loading part will be restricted to hosted fonts and we need to make that clearer in the UI.
Comment #2
raincloud commentedI got the font applied through theme, thanks!
Comment #3
BarisW commentedComment #4
sreynen commentedCommitted two fixes (1, 2) for documentation on this.
Comment #5.0
(not verified) commentededit