Skip to content

Commit 7d0f90a

Browse files
Fix scaling icons (#17)
* adjust viewbox param on svg files * Fix some extra svg's to be compatible with all converters Co-authored-by: Oscar Fonts <[email protected]>
1 parent fdac1c4 commit 7d0f90a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+287
-162
lines changed

README.md

+13-2

scripts/generate-index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const template = fs.readFileSync("index-template.html").toString();
88
const data = {
99
"version": 'v' + version,
1010
"svg": fs.readdirSync('../static/svg'),
11-
"png64": fs.readdirSync('../static/png/64'),
11+
"png": fs.readdirSync('../static/png/originalSize'),
1212
};
1313

1414
const output = Mustache.render(template, data);

scripts/index-template.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ <h1>SVG Icons</h1>
4545
<div class="icon-container"><a href="svg/{{.}}"><img src="svg/{{.}}"/></a></div>
4646
{{/svg}}</p>
4747

48-
<h1>PNG Icons (64x64)</h1>
49-
<p>{{#png64}}
50-
<div class="icon-container"><a href="png/64/{{.}}"><img src="png/64/{{.}}"/></a></div>
51-
{{/png64}}</p>
48+
<h1>PNG Icons</h1>
49+
<p>{{#png}}
50+
<div class="icon-container"><a href="png/originalSize/{{.}}"><img src="png/originalSize/{{.}}"/></a></div>
51+
{{/png}}</p>
5252

5353
<h1>MapboxGL sprites</h1>
5454

55-
<p>Use <code>"sprite": "https://TMB-Barcelona.github.io/TMB-Icons/mapboxgl/sprites"</code> in your mapboxgl style definition.
55+
<p>Use <code>"sprite": "https://cdn.tmb.cat/icons/{{version}}/static/mapboxgl/sprites"</code> in your mapboxgl style definition.
5656
Then use them as "icon-image" property in a layer:</p>
5757

5858
<pre><code>

scripts/svg2png.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
#!/usr/bin/env node
2+
const path = require('path');
23
const fs = require('fs');
3-
const svg2png = require("svg2png");
4+
const svg2png = require('svg2png');
45

5-
const outputDir = '../static/png/64/';
6+
const arguments = process.argv;
7+
8+
// Too much arguments, show help & exit
9+
if (arguments.length > 3) {
10+
console.log(`Usage: ${path.basename(__filename)} [image_height_in_pixels]`);
11+
process.exit(1);
12+
}
13+
14+
const imageHeight = parseInt(arguments[arguments.length - 1]);
15+
const config = imageHeight > 0 ? { height: imageHeight } : undefined;
16+
17+
const outputDir = `../static/png/${config ? config.height : 'originalSize'}/`;
18+
console.log(`Outputting to ${outputDir}`);
619

720
if (!fs.existsSync(outputDir)){
821
fs.mkdirSync(outputDir, {recursive: true});
@@ -16,7 +29,7 @@ function convert(file) {
1629
targetName = targetName.join(".") + ".png";
1730
console.log("Converting " + file + " to " + targetName);
1831
const source = fs.readFileSync('../svg/'+file);
19-
const target = svg2png.sync(source);
32+
const target = svg2png.sync(source, config);
2033

2134
fs.writeFileSync(outputDir + targetName, target);
2235
}

svg/FGC.svg

+1

svg/FGC_gris.svg

+1

svg/FM.svg

+1

svg/FV.svg

+1

svg/L1.svg

+1

svg/L10.svg

+1

svg/L10N.svg

+1-1

svg/L10S.svg

+1-1

svg/L10_II.svg

+1-1

svg/L11.svg

+1

svg/L12.svg

+1

svg/L13.svg

+1

svg/L1L2.svg

+1-1

svg/L1L3.svg

+1-1

svg/L1L4.svg

+1-1

svg/L1L5.svg

+1-1

svg/L1L5L9NL10.svg

+1-1

svg/L1L5L9NL10N.svg

+1

svg/L1L9N.svg

+1-1

svg/L1L9S.svg

+1-1

svg/L1L9SL10S.svg

+1

svg/L2.svg

+1

svg/L2L10.svg

+1-1

svg/L2L10N.svg

+1

svg/L2L3FM.svg

+1-1

svg/L2L3L4.svg

+1-1

svg/L2L4.svg

+1-1

svg/L2L5.svg

+1-1

svg/L3.svg

+1

svg/L3L4L11.svg

+1-1

svg/L3L5.svg

+1-1

svg/L3L9S.svg

+1-1

svg/L4.svg

+1

svg/L4L5.svg

+1-1

svg/L5.svg

+1

svg/L5L9S.svg

+1-1

svg/L5L9SL10S.svg

+1

svg/L6.svg

+1

svg/L7.svg

+1

svg/L8.svg

+1

0 commit comments

Comments
 (0)