Installations
npm install logo.svg
Releases
Unable to fetch releases
Developer
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
4.4.0
NPM Version
3.8.5
Statistics
55 Stars
49 Commits
9 Forks
4 Watching
1 Branches
1 Contributors
Updated on 02 Nov 2024
Bundle Size
289.52 kB
Minified
77.87 kB
Minified + Gzipped
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
9,509
Last day
200%
3
Compared to previous day
Last week
66.7%
15
Compared to previous week
Last month
11.6%
48
Compared to previous month
Last year
-23.6%
789
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
1
Generate a svg logo, then you can embed it in you README.md
Feature:
- Custom font, font size, letter spacing
- Generate individual path for every char
- Support any valid attributes and style
- Handily cli
Install
To use the logo
command, install it globally:
$ npm install logo.svg -g
To use the JavaScript API, install logo.svg
locally:
$ npm install logo.svg --save
If you need both the logo
command and the JavaScript API, install logo.svg
.js both ways.
Usage
CLI
$ logo [options]
Options:
-l, --logo ??? ............. The logo text. Default is the `name` of the `package.json`.
-f, --font ??? ............. Specify the font path or url.
-s, --fontSize ??? ......... Specify the font size. Default `72`.
-o, --output ??? ........... Specify the output path. Default `logo.svg`
-c, --config ??? ........... Specify the `.logorc` file.
-O, --overwrite ............ Overwrite when a logo file exist. Default `true`.
-k, --kerning .............. Take kerning information into account. Default `true`.
-d, --divided .............. Generate individual path for every char. Default `false`.
-V, --version .............. Print the current version.
-h, --help ................. You're looking at it.
-h, --help ??? ............. Show details for the specified command.
Examples:
$ logo
$ logo -Odo ./logo/logo.svg
$ logo --config ./logo/.logorc
$ logo --help
$ logo --help font
$ logo --help config
$ logo --version
JavaScript API
1var logo = require('logo.svg'); 2// generate the svg string, then you can use it in you code 3var svg = logo.generate(options);
Options
font
The font's path or full url. If it's an url, we will load the font asynchronous then generate the logo.
If the path is relative, it is relative to the current work directory(process.cwd()
).
If the path is a basename, such as fontName.ttf
, we will fisrtly try to load it as a relative path, if that failed we will search it from the preset folder, and then search it from system and user fonts folders.
The preset folder is ./fonts/
, contribute your fonts by pull request.
logo
The logo text. Default is the name
in package.json
.
x
Horizontal position of the beginning of the text. (default: 0
)
y
Vertical position of the baseline of the text. (default: 0
)
fontSize
Size of the text. (default: 72
)
spacing
The letter spacing. (default: 0
)
kerning
If true
takes kerning information into account. (default: true
)
divided
If true
generates individual path for every char. (default: false
)
grouped
If true
groups the individual <path>
with <g></g>
element. (default: false
)
title
If specified will generate a <title>
at the root of <svg>
. (default: logo
)
desc
If specified will generate a <desc>
at the root of <svg>
. (default: null
)
Styling the logo
Specify the padding of the <path>
relative to the <svg>
:
- options.padding
- options.paddingTop or options['padding-top']
- options.paddingRight or options['padding-right']
- options.paddingBottom or options['padding-bottom']
- options.paddingLeft or options['padding-left']
The <svg>
, <path>
and <g>
elements can be styled by any valid attributes.
The generated <svg>
has the following default attributes:
1{ 2 'version' : '1.1', 3 'xmlns' : 'http://www.w3.org/2000/svg', 4 'xmlns:xlink': 'http://www.w3.org/1999/xlink', 5 'role' : 'img', 6 'width' : width, 7 'height' : height, 8 'viewbox': [x, y, width, height].join(' ') 9}
We can add/update/remove by options.svg
:
1options.svg = { 2 'version': '', // remove this attribute 3 'role' : 'logo', // update this attribute 4 'fill' : 'red' // add some custiom styles 5}
Note that the width
, height
and viewbox
can't be specified.
Styling the <path>
by options.path
. If divided
is true
we can style the individual <path>
element by options.path?
, which ?
is the index of each char in the logo
:
1// style for every path(s) 2options.path = { 3 'fill': yellow 4}; 5 6// style the first char 7options.path0 = { 8 'fill': '#FF0000', 9 'stroke': '#000000' 10};
As the same options.g
specified the style of <g>
element.
.logorc
All the options can be specified in the following files:
- .logorc.js
- .logorc.yaml
- .logorc.yml
- .logorc.json
- .logorc
- The
logo
section inpackage.json
We will try to load configuration from these files order by order, stop until any file load succeed.
Example for .logorc
:
1font: Origami-Mommy-Pixellated.ttf 2fontSzie: 72 3output: logo.svg 4# style the logo 5path: 6 fill: '#6ccb99'
Example for package.json
:
1{ 2 "name": "module", 3 "version": "1.0.0", 4 5 "logo": { 6 "font": "Origami-Mommy-Pixellated.ttf", 7 "fontSzie": 72, 8 "output": "logo.svg", 9 "path": { 10 "fill": "#6ccb99" 11 } 12 }, 13 14}
Embed the logo
SVG does not work from README by design for security concerns ...
We have had to disable svg image rendering on GitHub.com due to potential cross site scripting vulnerabilities.
So, we can not embed by the raw url, rawgit.com solves this problem nicely. For each request, it retrieves the appropriate document from GitHub and, crucially, serves it with the correct Content-Type header.
Link to your logo.svg using the following pattern:
https://cdn.rawgit.com/<repo-owner>/<repo>/<branch>/path/to.svg
To ensure that the CDN always serves the version of the file you want, use a git tag or commit hash in the file's path instead of a branch name, and update the URL if you push a new version of the file.
So, instead of a URL like https://cdn.rawgit.com/user/repo/branch/file
, use a URL like https://cdn.rawgit.com/user/repo/tag/file
or https://cdn.rawgit.com/user/repo/commit/file
.
The embed code looks like:
1![logo.svg](https://cdn.rawgit.com/<repo-owner>/<repo>/<branch>/path/to.svg) 2 3<img alt="logo.svg" width="500" src="https://cdn.rawgit.com/<repo-owner>/<repo>/<branch>/path/to.svg">
Demos
1font: 'gubblebum-glocky.ttf' 2logo: 'npm ' 3output: './demos/gubblebum-blocky/npm.svg' 4path: 5 fill: '#cb3837'
1logo: 'divided' 2font: 'origami-mommy.ttf' 3output: './demos/origami-mommy/divided.svg' 4divided: true 5path: 6 fill: '#6af72e' 7path1: 8 fill: '#c6e03c' 9path2: 10 fill: '#fc428f' 11path3: 12 fill: '#cea2fd' 13path4: 14 fill: '#fb3f24' 15path5: 16 fill: '#3cc8f6' 17path6: 18 fill: '#ff3e74'
1logo: 'Blocked' 2font: 'blocked.ttf' 3output: './demos/blocked/blocked.svg' 4path: 5 fill: '#fc174f'
1logo: 'Square' 2font: 'mk-zodnig-square.ttf' 3fontSize: 96 4output: './demos/mk-zodnig-square/square.svg' 5path: 6 fill: '#fd742d' 7# stroke: '#fd742d'
1logo: 'Gubblebum ' 2font: 'gubblebum.ttf' 3output: './demos/gubblebum/gubblebum.svg' 4spacing: 10 5divided: true 6path: 7 fill: '#6af72e' 8path0: 9 fill: '#fc428f'
Related
TODO
- Support logo template.
- What's your suggestion? Open an issue.
Contributing
Pull requests and stars are highly welcome.
For bugs and feature requests, please create an issue.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Score
3
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to logo.svg
sveltestrap
![sveltestrap](./logo.svg)
quicktype
![](https://raw.githubusercontent.com/quicktype/quicktype/master/media/quicktype-logo.svg?sanitize=true)
infocharts
<img src="https://raw.githubusercontent.com/garethslinn/public_infocharts/refs/heads/main/logo.svg" />
rivalz-node-cli
![Rivalz Logo](https://rivalz.ai/logo.svg)