Skip to content

Commit

Permalink
add transparent option
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdesl committed Mar 2, 2018
1 parent ec454a8 commit b3cd2c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -76,6 +76,8 @@ Options:
- the dimensions of an output texture sheet, normally power-of-2 for GPU usage. Both dimensions default to `512`
- `texturePadding` (Number)
- pixels between each glyph in the texture. Defaults to `2`
- `transparent` (Boolean)
- generate texture atlases with a transparent background, instead of white
- `fieldType` (String)
- what kind of distance field to generate. Defaults to `msdf`. Must be one of:
- `msdf` Multi-channel signed distance field
Expand Down
4 changes: 3 additions & 1 deletion index.js
Expand Up @@ -74,7 +74,9 @@ function generateBMFont (fontPath, opt, callback) {
const textures = packer.bins.map((bin, index) => {
context.fillStyle = '#ffffff';
context.fillRect(0, 0, canvas.width, canvas.height);
// context.clearRect(0, 0, canvas.width, canvas.height);
if (opt.transparent) {
context.clearRect(0, 0, canvas.width, canvas.height);
}
bin.rects.forEach(rect => {
if (rect.data.imageData) {
context.putImageData(rect.data.imageData, rect.x, rect.y);
Expand Down

0 comments on commit b3cd2c0

Please sign in to comment.