This commit is contained in:
Yamozha
2021-04-02 02:24:13 +03:00
parent c23950b545
commit 7256d79e2c
31493 changed files with 3036630 additions and 0 deletions

21
node_modules/parse-bmfont-binary/LICENSE.md generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015 Jam3
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE.

37
node_modules/parse-bmfont-binary/README.md generated vendored Normal file
View File

@ -0,0 +1,37 @@
# parse-bmfont-binary
[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)
Encodes a BMFont from a binary Buffer into JSON, as per the [BMFont Spec](http://www.angelcode.com/products/bmfont/doc/file_format.html). Can be used in Node or the browser (e.g. with browserify).
```js
var parse = require('parse-bmfont-binary')
fs.readFile('fonts/Lato.bin', function(err, data) {
if (err) throw err
var font = parse(data)
//do something with your font
console.log(font.info.face)
console.log(font.info.size)
console.log(font.common.lineHeight)
console.log(font.chars)
console.log(font.kernings)
})
```
## See Also
See [text-modules](https://github.com/mattdesl/text-modules) for related modules.
## Usage
[![NPM](https://nodei.co/npm/parse-bmfont-binary.png)](https://www.npmjs.com/package/parse-bmfont-binary)
#### `font = parse(buffer)`
Reads a binary BMFont Buffer and returns a new JSON representation of that font. See [here](https://github.com/mattdesl/bmfont2json/wiki/JsonSpec) for details on the return format.
## License
MIT, see [LICENSE.md](http://github.com/Jam3/parse-bmfont-binary/blob/master/LICENSE.md) for details.

160
node_modules/parse-bmfont-binary/index.js generated vendored Normal file
View File

@ -0,0 +1,160 @@
var HEADER = [66, 77, 70]
module.exports = function readBMFontBinary(buf) {
if (buf.length < 6)
throw new Error('invalid buffer length for BMFont')
var header = HEADER.every(function(byte, i) {
return buf.readUInt8(i) === byte
})
if (!header)
throw new Error('BMFont missing BMF byte header')
var i = 3
var vers = buf.readUInt8(i++)
if (vers > 3)
throw new Error('Only supports BMFont Binary v3 (BMFont App v1.10)')
var target = { kernings: [], chars: [] }
for (var b=0; b<5; b++)
i += readBlock(target, buf, i)
return target
}
function readBlock(target, buf, i) {
if (i > buf.length-1)
return 0
var blockID = buf.readUInt8(i++)
var blockSize = buf.readInt32LE(i)
i += 4
switch(blockID) {
case 1:
target.info = readInfo(buf, i)
break
case 2:
target.common = readCommon(buf, i)
break
case 3:
target.pages = readPages(buf, i, blockSize)
break
case 4:
target.chars = readChars(buf, i, blockSize)
break
case 5:
target.kernings = readKernings(buf, i, blockSize)
break
}
return 5 + blockSize
}
function readInfo(buf, i) {
var info = {}
info.size = buf.readInt16LE(i)
var bitField = buf.readUInt8(i+2)
info.smooth = (bitField >> 7) & 1
info.unicode = (bitField >> 6) & 1
info.italic = (bitField >> 5) & 1
info.bold = (bitField >> 4) & 1
//fixedHeight is only mentioned in binary spec
if ((bitField >> 3) & 1)
info.fixedHeight = 1
info.charset = buf.readUInt8(i+3) || ''
info.stretchH = buf.readUInt16LE(i+4)
info.aa = buf.readUInt8(i+6)
info.padding = [
buf.readInt8(i+7),
buf.readInt8(i+8),
buf.readInt8(i+9),
buf.readInt8(i+10)
]
info.spacing = [
buf.readInt8(i+11),
buf.readInt8(i+12)
]
info.outline = buf.readUInt8(i+13)
info.face = readStringNT(buf, i+14)
return info
}
function readCommon(buf, i) {
var common = {}
common.lineHeight = buf.readUInt16LE(i)
common.base = buf.readUInt16LE(i+2)
common.scaleW = buf.readUInt16LE(i+4)
common.scaleH = buf.readUInt16LE(i+6)
common.pages = buf.readUInt16LE(i+8)
var bitField = buf.readUInt8(i+10)
common.packed = 0
common.alphaChnl = buf.readUInt8(i+11)
common.redChnl = buf.readUInt8(i+12)
common.greenChnl = buf.readUInt8(i+13)
common.blueChnl = buf.readUInt8(i+14)
return common
}
function readPages(buf, i, size) {
var pages = []
var text = readNameNT(buf, i)
var len = text.length+1
var count = size / len
for (var c=0; c<count; c++) {
pages[c] = buf.slice(i, i+text.length).toString('utf8')
i += len
}
return pages
}
function readChars(buf, i, blockSize) {
var chars = []
var count = blockSize / 20
for (var c=0; c<count; c++) {
var char = {}
var off = c*20
char.id = buf.readUInt32LE(i + 0 + off)
char.x = buf.readUInt16LE(i + 4 + off)
char.y = buf.readUInt16LE(i + 6 + off)
char.width = buf.readUInt16LE(i + 8 + off)
char.height = buf.readUInt16LE(i + 10 + off)
char.xoffset = buf.readInt16LE(i + 12 + off)
char.yoffset = buf.readInt16LE(i + 14 + off)
char.xadvance = buf.readInt16LE(i + 16 + off)
char.page = buf.readUInt8(i + 18 + off)
char.chnl = buf.readUInt8(i + 19 + off)
chars[c] = char
}
return chars
}
function readKernings(buf, i, blockSize) {
var kernings = []
var count = blockSize / 10
for (var c=0; c<count; c++) {
var kern = {}
var off = c*10
kern.first = buf.readUInt32LE(i + 0 + off)
kern.second = buf.readUInt32LE(i + 4 + off)
kern.amount = buf.readInt16LE(i + 8 + off)
kernings[c] = kern
}
return kernings
}
function readNameNT(buf, offset) {
var pos=offset
for (; pos<buf.length; pos++) {
if (buf[pos] === 0x00)
break
}
return buf.slice(offset, pos)
}
function readStringNT(buf, offset) {
return readNameNT(buf, offset).toString('utf8')
}

42
node_modules/parse-bmfont-binary/package.json generated vendored Normal file
View File

@ -0,0 +1,42 @@
{
"name": "parse-bmfont-binary",
"version": "1.0.6",
"description": "reads a BMFont binary in a Buffer into a JSON object",
"main": "index.js",
"license": "MIT",
"author": {
"name": "Matt DesLauriers",
"email": "dave.des@gmail.com",
"url": "https://github.com/mattdesl"
},
"dependencies": {},
"devDependencies": {
"tape": "^3.5.0"
},
"scripts": {
"test": "node test/test.js"
},
"keywords": [
"bmfont",
"bitmap",
"font",
"angel",
"code",
"angelcode",
"fonts",
"text",
"layout",
"glyph",
"glyphdesigner",
"canvas",
"webgl"
],
"repository": {
"type": "git",
"url": "git://github.com/Jam3/parse-bmfont-binary.git"
},
"homepage": "https://github.com/Jam3/parse-bmfont-binary",
"bugs": {
"url": "https://github.com/Jam3/parse-bmfont-binary/issues"
}
}