TheDesk Riina (ver.3)

This commit is contained in:
cutls
2018-02-19 02:41:25 +09:00
parent 0ada3a03b0
commit 7a1c6ea17c
997 changed files with 161887 additions and 34 deletions

74
app/node_modules/parse-bmfont-xml/README.md generated vendored Normal file
View File

@@ -0,0 +1,74 @@
# parse-bmfont-xml
[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)
Parses XML [BMFont files](http://www.angelcode.com/products/bmfont/).
Takes a string or Buffer:
```js
var fs = require('fs')
var parse = require('parse-bmfont-xml')
fs.readFileSync(__dirname+'/Arial.fnt', function(err, data) {
var result = parse(data)
console.log(result.info.face) // "Arial"
console.log(result.pages) // [ 'sheet0.png' ]
console.log(result.chars) // [ ... char data ... ]
console.log(result.kernings) // [ ... kernings data ... ]
})
```
Also works in the browser, for example using XHR:
```js
var parse = require('parse-bmfont-xml')
var xhr = require('xhr')
xhr({ uri: 'fonts/NexaLight32.xml' }, function(err, res, body) {
if (err)
throw err
var result = parse(body)
console.log(result.info.face)
})
```
The spec for the returned JSON object is [here](https://github.com/mattdesl/bmfont2json/wiki/JsonSpec). The input XML should match the spec with a `<font>` root element, see [test/Nexa Light-32.fnt](test/Nexa Light-32.fnt) for an example.
## See Also
See [text-modules](https://github.com/mattdesl/text-modules) for related modules.
## Usage
[![NPM](https://nodei.co/npm/parse-bmfont-xml.png)](https://www.npmjs.com/package/parse-bmfont-xml)
#### `result = parse(data)`
Parses `data`, a string or Buffer that represents XML data of an AngelCode BMFont file. The returned `result` object looks like this:
```js
{
pages: [
"sheet_0.png",
"sheet_1.png"
],
chars: [
{ chnl, height, id, page, width, x, y, xoffset, yoffset, xadvance },
...
],
info: { ... },
common: { ... },
kernings: [
{ first, second, amount }
]
}
```
If the data is malformed, an error will be thrown.
The browser implementation relies on [xml-parse-from-string](https://github.com/Jam3/xml-parse-from-string), which may not work in environments without valid DOM APIs (like CocoonJS).
## License
MIT, see [LICENSE.md](http://github.com/mattdesl/parse-bmfont-xml/blob/master/LICENSE.md) for details.

85
app/node_modules/parse-bmfont-xml/lib/browser.js generated vendored Normal file
View File

@@ -0,0 +1,85 @@
var parseAttributes = require('./parse-attribs')
var parseFromString = require('xml-parse-from-string')
//In some cases element.attribute.nodeName can return
//all lowercase values.. so we need to map them to the correct
//case
var NAME_MAP = {
scaleh: 'scaleH',
scalew: 'scaleW',
stretchh: 'stretchH',
lineheight: 'lineHeight',
alphachnl: 'alphaChnl',
redchnl: 'redChnl',
greenchnl: 'greenChnl',
bluechnl: 'blueChnl'
}
module.exports = function parse(data) {
data = data.toString()
var xmlRoot = parseFromString(data)
var output = {
pages: [],
chars: [],
kernings: []
}
//get config settings
;['info', 'common'].forEach(function(key) {
var element = xmlRoot.getElementsByTagName(key)[0]
if (element)
output[key] = parseAttributes(getAttribs(element))
})
//get page info
var pageRoot = xmlRoot.getElementsByTagName('pages')[0]
if (!pageRoot)
throw new Error('malformed file -- no <pages> element')
var pages = pageRoot.getElementsByTagName('page')
for (var i=0; i<pages.length; i++) {
var p = pages[i]
var id = parseInt(p.getAttribute('id'), 10)
var file = p.getAttribute('file')
if (isNaN(id))
throw new Error('malformed file -- page "id" attribute is NaN')
if (!file)
throw new Error('malformed file -- needs page "file" attribute')
output.pages[parseInt(id, 10)] = file
}
//get kernings / chars
;['chars', 'kernings'].forEach(function(key) {
var element = xmlRoot.getElementsByTagName(key)[0]
if (!element)
return
var childTag = key.substring(0, key.length-1)
var children = element.getElementsByTagName(childTag)
for (var i=0; i<children.length; i++) {
var child = children[i]
output[key].push(parseAttributes(getAttribs(child)))
}
})
return output
}
function getAttribs(element) {
var attribs = getAttribList(element)
return attribs.reduce(function(dict, attrib) {
var key = mapName(attrib.nodeName)
dict[key] = attrib.nodeValue
return dict
}, {})
}
function getAttribList(element) {
//IE8+ and modern browsers
var attribs = []
for (var i=0; i<element.attributes.length; i++)
attribs.push(element.attributes[i])
return attribs
}
function mapName(nodeName) {
return NAME_MAP[nodeName.toLowerCase()] || nodeName
}

45
app/node_modules/parse-bmfont-xml/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
var xml2js = require('xml2js')
var parseAttributes = require('./parse-attribs')
module.exports = function parseBMFontXML(data) {
data = data.toString().trim()
var output = {
pages: [],
chars: [],
kernings: []
}
xml2js.parseString(data, function(err, result) {
if (err)
throw err
if (!result.font)
throw "XML bitmap font doesn't have <font> root"
result = result.font
output.common = parseAttributes(result.common[0].$)
output.info = parseAttributes(result.info[0].$)
for (var i = 0; i < result.pages.length; i++) {
var p = result.pages[i].page[0].$
if (typeof p.id === "undefined")
throw new Error("malformed file -- needs page id=N")
if (typeof p.file !== "string")
throw new Error("malformed file -- needs page file=\"path\"")
output.pages[parseInt(p.id, 10)] = p.file
}
var chrArray = result.chars[0]['char'] || []
for (var i = 0; i < chrArray.length; i++) {
output.chars.push(parseAttributes(chrArray[i].$))
}
var kernArray = result.kernings[0]['kerning'] || []
for (var i = 0; i < kernArray.length; i++) {
output.kernings.push(parseAttributes(kernArray[i].$))
}
})
return output
}

28
app/node_modules/parse-bmfont-xml/lib/parse-attribs.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
//Some versions of GlyphDesigner have a typo
//that causes some bugs with parsing.
//Need to confirm with recent version of the software
//to see whether this is still an issue or not.
var GLYPH_DESIGNER_ERROR = 'chasrset'
module.exports = function parseAttributes(obj) {
if (GLYPH_DESIGNER_ERROR in obj) {
obj['charset'] = obj[GLYPH_DESIGNER_ERROR]
delete obj[GLYPH_DESIGNER_ERROR]
}
for (var k in obj) {
if (k === 'face' || k === 'charset')
continue
else if (k === 'padding' || k === 'spacing')
obj[k] = parseIntList(obj[k])
else
obj[k] = parseInt(obj[k], 10)
}
return obj
}
function parseIntList(data) {
return data.split(',').map(function(val) {
return parseInt(val, 10)
})
}

111
app/node_modules/parse-bmfont-xml/package.json generated vendored Normal file
View File

@@ -0,0 +1,111 @@
{
"_args": [
[
{
"raw": "parse-bmfont-xml@^1.1.0",
"scope": null,
"escapedName": "parse-bmfont-xml",
"name": "parse-bmfont-xml",
"rawSpec": "^1.1.0",
"spec": ">=1.1.0 <2.0.0",
"type": "range"
},
"C:\\Users\\ryuki\\TheDesk\\app\\node_modules\\load-bmfont"
]
],
"_from": "parse-bmfont-xml@>=1.1.0 <2.0.0",
"_id": "parse-bmfont-xml@1.1.3",
"_inCache": true,
"_location": "/parse-bmfont-xml",
"_npmUser": {
"name": "mattdesl",
"email": "dave.des@gmail.com"
},
"_npmVersion": "1.4.28",
"_phantomChildren": {},
"_requested": {
"raw": "parse-bmfont-xml@^1.1.0",
"scope": null,
"escapedName": "parse-bmfont-xml",
"name": "parse-bmfont-xml",
"rawSpec": "^1.1.0",
"spec": ">=1.1.0 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/load-bmfont"
],
"_resolved": "https://registry.npmjs.org/parse-bmfont-xml/-/parse-bmfont-xml-1.1.3.tgz",
"_shasum": "d6b66a371afd39c5007d9f0eeb262a4f2cce7b7c",
"_shrinkwrap": null,
"_spec": "parse-bmfont-xml@^1.1.0",
"_where": "C:\\Users\\ryuki\\TheDesk\\app\\node_modules\\load-bmfont",
"author": {
"name": "Matt DesLauriers",
"email": "dave.des@gmail.com",
"url": "https://github.com/mattdesl"
},
"browser": "lib/browser.js",
"bugs": {
"url": "https://github.com/mattdesl/parse-bmfont-xml/issues"
},
"dependencies": {
"xml-parse-from-string": "^1.0.0",
"xml2js": "^0.4.5"
},
"description": "parses XML BMFont files into a JavaScript object",
"devDependencies": {
"brfs": "^1.4.0",
"browserify": "^9.0.3",
"faucet": "0.0.1",
"tape": "^3.5.0",
"testling": "^1.7.1",
"xhr": "^2.0.1"
},
"directories": {},
"dist": {
"shasum": "d6b66a371afd39c5007d9f0eeb262a4f2cce7b7c",
"tarball": "https://registry.npmjs.org/parse-bmfont-xml/-/parse-bmfont-xml-1.1.3.tgz"
},
"gitHead": "4a22fe8ac0ac82ead4de5b6988b436e376456baa",
"homepage": "https://github.com/mattdesl/parse-bmfont-xml",
"keywords": [
"xml",
"parse",
"convert",
"bmfont",
"bm",
"bitmap",
"font",
"bitmaps",
"angel",
"angelcode",
"code",
"text",
"gl",
"sprite",
"sprites",
"stackgl"
],
"license": "MIT",
"main": "lib/index.js",
"maintainers": [
{
"name": "mattdesl",
"email": "dave.des@gmail.com"
}
],
"name": "parse-bmfont-xml",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/mattdesl/parse-bmfont-xml.git"
},
"scripts": {
"test": "npm run test-node && npm run test-browser",
"test-browser": "browserify test/test-browser.js -t brfs | testling | faucet",
"test-node": "node test/test.js | faucet"
},
"version": "1.1.3"
}