Class: Fontico::Emitters::Stylesheet

Inherits:
Object
  • Object
show all
Defined in:
lib/fontico/emitters/stylesheet.rb

Overview

The small amount of CSS that makes an behave like a glyph.

Colour is already handled: bodies are folded to currentColor, which is what makes an external sprite themeable at all — host CSS does not cascade into a cross-document , but inherited properties like color do reach it.

Instance Method Summary collapse

Constructor Details

#initialize(manifest, _build) ⇒ Stylesheet

Returns a new instance of Stylesheet.



12
13
14
# File 'lib/fontico/emitters/stylesheet.rb', line 12

def initialize(manifest, _build)
  @manifest = manifest
end

Instance Method Details

#accepts?(_icon) ⇒ Boolean

Contributes no icons, only rules — so the builder must not count all 91 of them as "skipped" on its behalf.

Returns:

  • (Boolean)


18
# File 'lib/fontico/emitters/stylesheet.rb', line 18

def accepts?(_icon) = false

#callObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fontico/emitters/stylesheet.rb', line 21

def call
  <<~CSS
    /* generated by fontico — do not edit */
    .#{Fontico.css_class} {
      display: inline-block;
      width: 1em;
      height: 1em;

      /* An <svg> sits on the text baseline's bottom edge, a glyph sits
         slightly below it. This is the conventional nudge; tune it if
         your body face has unusual metrics. */
      vertical-align: -0.125em;

      /* Never let a flex or grid parent squash an icon. */
      flex: none;
    }

    /* Optical sizing for icons set beside larger text. */
    .#{Fontico.css_class}-lg { width: 1.25em; height: 1.25em; }
    .#{Fontico.css_class}-xl { width: 1.5em;  height: 1.5em;  }
  CSS
end

#rules_only?Boolean

Returns:

  • (Boolean)


19
# File 'lib/fontico/emitters/stylesheet.rb', line 19

def rules_only?     = true