https://github.com/spritejs/sprite-extend-bmfont
https://github.com/spritejs/sprite-extend-bmfont
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/spritejs/sprite-extend-bmfont
- Owner: spritejs
- Created: 2018-07-01T04:40:52.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-03T04:02:27.000Z (over 7 years ago)
- Last Synced: 2025-02-21T16:48:10.661Z (11 months ago)
- Language: JavaScript
- Size: 572 KB
- Stars: 2
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# sprite-extend-bmFont
SpriteJS [bmGlyph](https://www.bmglyph.com/) BitmapFont extend.
## How to use
Use [bmGlyph](https://www.bmglyph.com/) to publish BitMap font.

Choose publish format cocos2d/BMFont.
Use `tools/generate.js` to generate bmfont file for SpriteJS
```bash
node tools/generate.js fonts/testsprite.fnt
```
```html
const context = document.getElementById('container').getContext('2d')
const {Layer, BMFont, Label} = spritejs
const layer = new Layer({context})
const s = new BMFont()
s.attr({
anchor: 0.5,
fontFace: 'Arial',
text: 'SpriteJS\nabVu',
pos: [300, 200],
border: {
width: 4,
color: 'red',
},
// lineHeight: 30,
// letterSpacing: 20,
textAlign: 'center',
})
layer.append(s)
```
### Arguments of generate.js
** build for weixin **
```bash
node generate.js fonts/testsprite.fnt --weixin
```
Copy testsprite.png to `/assets/img/testsprite.png`
** build with online texture **
```bash
node generate.js fonts/testsprite.fnt --src=https://p4.ssl.qhimg.com/t016ec624e084e49c16.png
```
** build with preload resource id **
```bash
node generate.js fonts/testsprite.fnt --id=testsprite.png
```