Skip to content

Commit

Permalink
Use fantasticon to generate web fonts (#515)
Browse files Browse the repository at this point in the history
* Generate webfonts via fantasticon

- Includes new docs section and fonts page
- Generates CSS and JSON in addition to 4x font types
- Adds new script and hooks into existing icons and zip scripts

* casing

* Update to drop ttf and eot for woff and woff2 only for now

* remove eot and ttf there too

* simplify stylelint
  • Loading branch information
mdo authored Dec 9, 2020
1 parent 83ababc commit 03d6dae
Show file tree
Hide file tree
Showing 13 changed files with 8,383 additions and 6 deletions.
30 changes: 30 additions & 0 deletions .fantasticonrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module.exports = {
inputDir: './icons', // (required)
outputDir: './font', // (required)
fontTypes: ['woff', 'woff2'],
assetTypes: ['css', 'json', 'html'],
name: 'bootstrap-icons',
prefix: 'bi',
selector: '.bi',
fontsUrl: './fonts',
formatOptions: {
json: {
// render the JSON human readable with two spaces indent (default is none, so minified)
indent: 2
}
},
// Use a custom Handlebars template
templates: {
css: './src/css.hbs',
html: './src/html.hbs'
},
pathOptions: {
json: './font/bootstrap-icons.json',
css: './font/bootstrap-icons.css',
html: './font/index.html',
ttf: './font/fonts/bootstrap-icons.ttf',
woff: './font/fonts/bootstrap-icons.woff',
woff2: './font/fonts/bootstrap-icons.woff2',
eot: './font/fonts/bootstrap-icons.eot'
}
};
2 changes: 2 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ module:
target: static/bootstrap-icons.svg
- source: icons
target: static/icons
- source: font
target: static/font

params:
description: "Official open source SVG icon library for Bootstrap"
Expand Down
24 changes: 24 additions & 0 deletions docs/assets/scss/docs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,27 @@
padding-bottom: 4.5rem !important;
}
// stylelint-enable declaration-no-important

// stylelint-disable
@font-face {
font-family: bootstrap-icons;
src: url("../../font/fonts/bootstrap-icons.woff?1ef5213d557344d80e31924ac255216d") format("woff"),
url("../../font/fonts/bootstrap-icons.woff2?1ef5213d557344d80e31924ac255216d") format("woff2");
}

[class^="bi-"]::before,
[class*=" bi-"]::before {
display: inline-block;
font-family: bootstrap-icons !important;
font-style: normal;
font-weight: 400 !important;
font-variant: normal;
line-height: 1;
text-transform: none;
vertical-align: text-bottom;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

.bi-alarm::before { content: "\f102"; }
// stylelint-enable
15 changes: 15 additions & 0 deletions docs/content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ Copy the Bootstrap icons SVGs to your directory of choice and reference them lik
</div>
</div>

<div class="row my-4">
<div class="col-md-4">
{{< md >}}
### Icon font
Icon fonts with classes for every icon are also included for Bootstrap Icons. Include the icon web fonts in your page via CSS, then reference the class names as needed in your HTML (e.g., `<i class="bi-alarm-clock"></i>`).

Use `font-size` and `color` to change the icon appearance.
{{< /md >}}
</div>
<div class="col-md-8">
{{< example >}}<i class="bi-alarm"></i>{{< /example >}}
{{< example >}}<i class="bi-alarm" style="font-size: 2rem; color: cornflowerblue;"></i>{{< /example >}}
</div>
</div>

<div class="row">
<div class="col-md-4">
{{< md >}}
Expand Down
Loading

0 comments on commit 03d6dae

Please sign in to comment.