Support FontAwesome solid, regular, and brands

(might as well.. only the used ones get bundled into the fa-sprite anyway)
This commit is contained in:
Bryan Housel
2018-06-06 17:58:48 -04:00
parent 15c36f8acc
commit cbfe23c9e1
14 changed files with 36 additions and 29 deletions
+12 -9
View File
@@ -22,7 +22,9 @@ const suggestions = require('name-suggestion-index/name-suggestions.json');
// fontawesome icons
const fontawesome = require('@fortawesome/fontawesome');
const fas = require('@fortawesome/fontawesome-free-solid').default;
fontawesome.library.add(fas);
const far = require('@fortawesome/fontawesome-free-regular').default;
const fab = require('@fortawesome/fontawesome-free-brands').default;
fontawesome.library.add(fas, far, fab);
module.exports = function buildData() {
@@ -146,7 +148,7 @@ function generateCategories(tstrings, faIcons) {
categories[id] = category;
// fontawesome icon, remember for later
if (/^fa-/.test(category.icon)) {
if (/^fa[srb]-/.test(category.icon)) {
faIcons[category.icon] = {};
}
});
@@ -179,7 +181,7 @@ function generateFields(tstrings, faIcons) {
fields[id] = field;
// fontawesome icon, remember for later
if (/^fa-/.test(field.icon)) {
if (/^fa[srb]-/.test(field.icon)) {
faIcons[field.icon] = {};
}
});
@@ -277,7 +279,7 @@ function generatePresets(tstrings, faIcons) {
presets[id] = preset;
// fontawesome icon, remember for later
if (/^fa-/.test(preset.icon)) {
if (/^fa[srb]-/.test(preset.icon)) {
faIcons[preset.icon] = {};
}
});
@@ -377,9 +379,9 @@ function generateTaginfo(presets, fields) {
} else if (/^temaki-/.test(preset.icon)) {
tag.icon_url = 'https://raw.githubusercontent.com/bhousel/temaki/master/icons/' +
preset.icon.replace(/^temaki-/, '') + '.svg?sanitize=true';
} else if (/^fa-/.test(preset.icon)) {
} else if (/^fa[srb]-/.test(preset.icon)) {
tag.icon_url = 'https://raw.githubusercontent.com/openstreetmap/iD/master/svg/fontawesome/' +
preset.icon.replace(/^fa-/, '') + '.svg?sanitize=true';
preset.icon + '.svg?sanitize=true';
}
coalesceTags(taginfo, tag);
@@ -536,9 +538,10 @@ function writeEnJson(tstrings) {
function writeFaIcons(faIcons) {
for (var key in faIcons) {
var name = key.substring(3); // without `fa-`
var def = fontawesome.findIconDefinition({ iconName: name });
writeFileProm('svg/fontawesome/' + name + '.svg', fontawesome.icon(def).html);
var prefix = key.substring(0, 3); // `fas`, `far`, `fab`
var name = key.substring(4);
var def = fontawesome.findIconDefinition({ prefix: prefix, iconName: name });
writeFileProm('svg/fontawesome/' + key + '.svg', fontawesome.icon(def).html);
}
}
+3 -1
View File
@@ -217,7 +217,9 @@ You can use any of the following open source map icon sets as preset icons.
* [Maki](http://www.mapbox.com/maki/) - prefix: `maki-`
* [Temaki](http://bhousel.github.io/temaki/docs/) - prefix: `temaki-`
* [Font Awesome](https://fontawesome.com/icons?d=gallery&s=solid) (free, solid only) - prefix: `fa-`
* [Font Awesome (free, solid)](https://fontawesome.com/icons?d=gallery&s=solid) - prefix: `fas-`
* [Font Awesome (free, regular)](https://fontawesome.com/icons?d=gallery&s=regular) - prefix: `far-`
* [Font Awesome (free, brands)](https://fontawesome.com/icons?d=gallery&s=brands) - prefix: `fab-`
When specifying an icon, use the prefixed version of the name, for example `"icon": "maki-park"`.
+6 -6
View File
@@ -2021,7 +2021,7 @@
"name": "Monastery Grounds"
},
"amenity/motorcycle_parking": {
"icon": "fa-motorcycle",
"icon": "fas-motorcycle",
"fields": [
"capacity",
"operator",
@@ -6485,7 +6485,7 @@
"matchScore": 0.01
},
"emergency/ambulance_station": {
"icon": "fa-ambulance",
"icon": "fas-ambulance",
"fields": [
"name",
"operator",
@@ -18056,7 +18056,7 @@
"name": "Money Lender"
},
"shop/motorcycle_repair": {
"icon": "fa-motorcycle",
"icon": "fas-motorcycle",
"fields": [
"name",
"operator",
@@ -18084,7 +18084,7 @@
"name": "Motorcycle Repair Shop"
},
"shop/motorcycle": {
"icon": "fa-motorcycle",
"icon": "fas-motorcycle",
"fields": [
"name",
"operator",
@@ -83203,7 +83203,7 @@
"shop": "motorcycle"
},
"name": "Harley Davidson",
"icon": "fa-motorcycle",
"icon": "fas-motorcycle",
"geometry": [
"point",
"area"
@@ -83224,7 +83224,7 @@
"shop": "motorcycle"
},
"name": "Yamaha",
"icon": "fa-motorcycle",
"icon": "fas-motorcycle",
"geometry": [
"point",
"area"
@@ -1,5 +1,5 @@
{
"icon": "fa-motorcycle",
"icon": "fas-motorcycle",
"fields": [
"capacity",
"operator",
@@ -1,5 +1,5 @@
{
"icon": "fa-ambulance",
"icon": "fas-ambulance",
"fields": [
"name",
"operator",
+1 -1
View File
@@ -1,5 +1,5 @@
{
"icon": "fa-motorcycle",
"icon": "fas-motorcycle",
"fields": [
"name",
"operator",
@@ -1,5 +1,5 @@
{
"icon": "fa-motorcycle",
"icon": "fas-motorcycle",
"fields": [
"name",
"operator",
+4 -4
View File
@@ -924,7 +924,7 @@
"node",
"area"
],
"icon_url": "https://raw.githubusercontent.com/openstreetmap/iD/master/svg/fontawesome/motorcycle.svg?sanitize=true"
"icon_url": "https://raw.githubusercontent.com/openstreetmap/iD/master/svg/fontawesome/fas-motorcycle.svg?sanitize=true"
},
{
"key": "amenity",
@@ -2946,7 +2946,7 @@
"node",
"area"
],
"icon_url": "https://raw.githubusercontent.com/openstreetmap/iD/master/svg/fontawesome/ambulance.svg?sanitize=true"
"icon_url": "https://raw.githubusercontent.com/openstreetmap/iD/master/svg/fontawesome/fas-ambulance.svg?sanitize=true"
},
{
"key": "emergency",
@@ -7313,7 +7313,7 @@
"node",
"area"
],
"icon_url": "https://raw.githubusercontent.com/openstreetmap/iD/master/svg/fontawesome/motorcycle.svg?sanitize=true"
"icon_url": "https://raw.githubusercontent.com/openstreetmap/iD/master/svg/fontawesome/fas-motorcycle.svg?sanitize=true"
},
{
"key": "shop",
@@ -7323,7 +7323,7 @@
"node",
"area"
],
"icon_url": "https://raw.githubusercontent.com/openstreetmap/iD/master/svg/fontawesome/motorcycle.svg?sanitize=true"
"icon_url": "https://raw.githubusercontent.com/openstreetmap/iD/master/svg/fontawesome/fas-motorcycle.svg?sanitize=true"
},
{
"key": "shop",
+1 -1
View File
@@ -32,7 +32,7 @@ export function uiPresetIcon() {
var picon = getIcon(p, geom);
var isMaki = /^maki-/.test(picon);
var isTemaki = /^temaki-/.test(picon);
var isFa = /^fa-/.test(picon);
var isFa = /^fa[srb]-/.test(picon);
var isPOI = isMaki || isTemaki || isFa;
var isFramed = (geom === 'area' || geom === 'vertex');
+4 -2
View File
@@ -20,7 +20,7 @@
"dist:svg:community": "svg-sprite --symbol --symbol-dest . --shape-id-generator \"community-%s\" --symbol-sprite dist/img/community-sprite.svg node_modules/osm-community-index/dist/img/*.svg",
"dist:svg:maki": "svg-sprite --symbol --symbol-dest . --shape-id-generator \"maki-%s\" --symbol-sprite dist/img/maki-sprite.svg node_modules/@mapbox/maki/icons/*.svg",
"dist:svg:temaki": "svg-sprite --symbol --symbol-dest . --shape-id-generator \"temaki-%s\" --symbol-sprite dist/img/temaki-sprite.svg node_modules/temaki/icons/*.svg",
"dist:svg:fa": "svg-sprite --symbol --symbol-dest . --shape-id-generator \"fa-%s\" --symbol-sprite dist/img/fa-sprite.svg svg/fontawesome/*.svg",
"dist:svg:fa": "svg-sprite --symbol --symbol-dest . --symbol-sprite dist/img/fa-sprite.svg svg/fontawesome/*.svg",
"imagery": "node data/update_imagery",
"lint": "eslint *.js js/id test/spec modules",
"start": "node development_server.js develop",
@@ -42,7 +42,9 @@
},
"devDependencies": {
"@fortawesome/fontawesome": "^1.1.5",
"@fortawesome/fontawesome-free-solid": "^5.0.9",
"@fortawesome/fontawesome-free-brands": "^5.0.13",
"@fortawesome/fontawesome-free-regular": "^5.0.13",
"@fortawesome/fontawesome-free-solid": "^5.0.13",
"@mapbox/maki": "^4.0.0",
"chai": "^4.1.0",
"colors": "^1.1.2",
-1
View File
@@ -1 +0,0 @@
<svg aria-hidden="true" data-prefix="fa" data-icon="ambulance" class="svg-inline--fa fa-ambulance fa-w-20" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path fill="currentColor" d="M624 352h-16V243.9c0-12.7-5.1-24.9-14.1-33.9L494 110.1c-9-9-21.2-14.1-33.9-14.1H416V48c0-26.5-21.5-48-48-48H48C21.5 0 0 21.5 0 48v320c0 26.5 21.5 48 48 48h16c0 53 43 96 96 96s96-43 96-96h128c0 53 43 96 96 96s96-43 96-96h48c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zM160 464c-26.5 0-48-21.5-48-48s21.5-48 48-48 48 21.5 48 48-21.5 48-48 48zm144-248c0 4.4-3.6 8-8 8h-56v56c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8v-56h-56c-4.4 0-8-3.6-8-8v-48c0-4.4 3.6-8 8-8h56v-56c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v56h56c4.4 0 8 3.6 8 8v48zm176 248c-26.5 0-48-21.5-48-48s21.5-48 48-48 48 21.5 48 48-21.5 48-48 48zm80-208H416V144h44.1l99.9 99.9V256z"></path></svg>

Before

Width:  |  Height:  |  Size: 846 B

+1
View File
@@ -0,0 +1 @@
<svg aria-hidden="true" data-prefix="fas" data-icon="ambulance" class="svg-inline--fa fa-ambulance fa-w-20" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path fill="currentColor" d="M624 352h-16V243.9c0-12.7-5.1-24.9-14.1-33.9L494 110.1c-9-9-21.2-14.1-33.9-14.1H416V48c0-26.5-21.5-48-48-48H48C21.5 0 0 21.5 0 48v320c0 26.5 21.5 48 48 48h16c0 53 43 96 96 96s96-43 96-96h128c0 53 43 96 96 96s96-43 96-96h48c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zM160 464c-26.5 0-48-21.5-48-48s21.5-48 48-48 48 21.5 48 48-21.5 48-48 48zm144-248c0 4.4-3.6 8-8 8h-56v56c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8v-56h-56c-4.4 0-8-3.6-8-8v-48c0-4.4 3.6-8 8-8h56v-56c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v56h56c4.4 0 8 3.6 8 8v48zm176 248c-26.5 0-48-21.5-48-48s21.5-48 48-48 48 21.5 48 48-21.5 48-48 48zm80-208H416V144h44.1l99.9 99.9V256z"></path></svg>

After

Width:  |  Height:  |  Size: 847 B

+1
View File
@@ -0,0 +1 @@
<svg aria-hidden="true" data-prefix="fas" data-icon="motorcycle" class="svg-inline--fa fa-motorcycle fa-w-20" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path fill="currentColor" d="M512.949 192.003c-14.862-.108-29.14 2.322-42.434 6.874L437.589 144H520c13.255 0 24-10.745 24-24V88c0-13.255-10.745-24-24-24h-45.311a24 24 0 0 0-17.839 7.945l-37.496 41.663-22.774-37.956A24 24 0 0 0 376 64h-80c-8.837 0-16 7.163-16 16v16c0 8.837 7.163 16 16 16h66.411l19.2 32H227.904c-17.727-23.073-44.924-40-99.904-40H72.54c-13.455 0-24.791 11.011-24.536 24.464C48.252 141.505 58.9 152 72 152h56c24.504 0 38.686 10.919 47.787 24.769l-11.291 20.529c-13.006-3.865-26.871-5.736-41.251-5.21C55.857 194.549 1.565 249.605.034 317.021-1.603 389.076 56.317 448 128 448c59.642 0 109.744-40.794 123.953-96h84.236c13.673 0 24.589-11.421 23.976-25.077-2.118-47.12 17.522-93.665 56.185-125.026l12.485 20.808c-27.646 23.654-45.097 58.88-44.831 98.179.47 69.556 57.203 126.452 126.758 127.11 71.629.678 129.839-57.487 129.234-129.099-.588-69.591-57.455-126.386-127.047-126.892zM128 400c-44.112 0-80-35.888-80-80s35.888-80 80-80c4.242 0 8.405.341 12.469.982L98.97 316.434C90.187 332.407 101.762 352 120 352h81.297c-12.37 28.225-40.56 48-73.297 48zm388.351-.116C470.272 402.337 432 365.554 432 320c0-21.363 8.434-40.781 22.125-55.144l49.412 82.352c4.546 7.577 14.375 10.034 21.952 5.488l13.72-8.232c7.577-4.546 10.034-14.375 5.488-21.952l-48.556-80.927A80.005 80.005 0 0 1 512 240c45.554 0 82.338 38.273 79.884 84.352-2.16 40.558-34.974 73.372-75.533 75.532z"></path></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

-1
View File
@@ -1 +0,0 @@
<svg aria-hidden="true" data-prefix="fa" data-icon="motorcycle" class="svg-inline--fa fa-motorcycle fa-w-20" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path fill="currentColor" d="M512.949 192.003c-14.862-.108-29.14 2.322-42.434 6.874L437.589 144H520c13.255 0 24-10.745 24-24V88c0-13.255-10.745-24-24-24h-45.311a24 24 0 0 0-17.839 7.945l-37.496 41.663-22.774-37.956A24 24 0 0 0 376 64h-80c-8.837 0-16 7.163-16 16v16c0 8.837 7.163 16 16 16h66.411l19.2 32H227.904c-17.727-23.073-44.924-40-99.904-40H72.54c-13.455 0-24.791 11.011-24.536 24.464C48.252 141.505 58.9 152 72 152h56c24.504 0 38.686 10.919 47.787 24.769l-11.291 20.529c-13.006-3.865-26.871-5.736-41.251-5.21C55.857 194.549 1.565 249.605.034 317.021-1.603 389.076 56.317 448 128 448c59.642 0 109.744-40.794 123.953-96h84.236c13.673 0 24.589-11.421 23.976-25.077-2.118-47.12 17.522-93.665 56.185-125.026l12.485 20.808c-27.646 23.654-45.097 58.88-44.831 98.179.47 69.556 57.203 126.452 126.758 127.11 71.629.678 129.839-57.487 129.234-129.099-.588-69.591-57.455-126.386-127.047-126.892zM128 400c-44.112 0-80-35.888-80-80s35.888-80 80-80c4.242 0 8.405.341 12.469.982L98.97 316.434C90.187 332.407 101.762 352 120 352h81.297c-12.37 28.225-40.56 48-73.297 48zm388.351-.116C470.272 402.337 432 365.554 432 320c0-21.363 8.434-40.781 22.125-55.144l49.412 82.352c4.546 7.577 14.375 10.034 21.952 5.488l13.72-8.232c7.577-4.546 10.034-14.375 5.488-21.952l-48.556-80.927A80.005 80.005 0 0 1 512 240c45.554 0 82.338 38.273 79.884 84.352-2.16 40.558-34.974 73.372-75.533 75.532z"></path></svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB