ttf2eot
Advanced tools
Comparing version 1.3.0 to 2.0.0
175
index.js
@@ -9,3 +9,3 @@ /* | ||
var ByteBuffer = require('./lib/byte_buffer.js'); | ||
var ByteBuffer = require('microbuffer'); | ||
@@ -16,14 +16,14 @@ /** | ||
var EOT_OFFSET = { | ||
LENGTH: 0 | ||
, FONT_LENGTH: 4 | ||
, VERSION: 8 | ||
, CHARSET: 26 | ||
, MAGIC: 34 | ||
, FONT_PANOSE: 16 | ||
, ITALIC: 27 | ||
, WEIGHT: 28 | ||
, UNICODE_RANGE: 36 | ||
, CODEPAGE_RANGE: 52 | ||
, CHECKSUM_ADJUSTMENT: 60 | ||
}; | ||
LENGTH: 0, | ||
FONT_LENGTH: 4, | ||
VERSION: 8, | ||
CHARSET: 26, | ||
MAGIC: 34, | ||
FONT_PANOSE: 16, | ||
ITALIC: 27, | ||
WEIGHT: 28, | ||
UNICODE_RANGE: 36, | ||
CODEPAGE_RANGE: 52, | ||
CHECKSUM_ADJUSTMENT: 60 | ||
}; | ||
@@ -35,32 +35,32 @@ /** | ||
// sfntHeader: | ||
NUMTABLES: 4 | ||
NUMTABLES: 4, | ||
// TableDirectoryEntry | ||
, TABLE_TAG: 0 | ||
, TABLE_OFFSET: 8 | ||
, TABLE_LENGTH: 12 | ||
TABLE_TAG: 0, | ||
TABLE_OFFSET: 8, | ||
TABLE_LENGTH: 12, | ||
// OS2Table | ||
, OS2_WEIGHT: 4 | ||
, OS2_FONT_PANOSE: 32 | ||
, OS2_UNICODE_RANGE: 42 | ||
, OS2_FS_SELECTION: 62 | ||
, OS2_CODEPAGE_RANGE: 78 | ||
OS2_WEIGHT: 4, | ||
OS2_FONT_PANOSE: 32, | ||
OS2_UNICODE_RANGE: 42, | ||
OS2_FS_SELECTION: 62, | ||
OS2_CODEPAGE_RANGE: 78, | ||
// headTable | ||
, HEAD_CHECKSUM_ADJUSTMENT: 8 | ||
HEAD_CHECKSUM_ADJUSTMENT: 8, | ||
// nameTable | ||
, NAMETABLE_FORMAT: 0 | ||
, NAMETABLE_COUNT: 2 | ||
, NAMETABLE_STRING_OFFSET: 4 | ||
NAMETABLE_FORMAT: 0, | ||
NAMETABLE_COUNT: 2, | ||
NAMETABLE_STRING_OFFSET: 4, | ||
// nameRecord | ||
, NAME_PLATFORM_ID: 0 | ||
, NAME_ENCODING_ID: 2 | ||
, NAME_LANGUAGE_ID: 4 | ||
, NAME_NAME_ID: 6 | ||
, NAME_LENGTH: 8 | ||
, NAME_OFFSET: 10 | ||
}; | ||
NAME_PLATFORM_ID: 0, | ||
NAME_ENCODING_ID: 2, | ||
NAME_LANGUAGE_ID: 4, | ||
NAME_NAME_ID: 6, | ||
NAME_LENGTH: 8, | ||
NAME_OFFSET: 10 | ||
}; | ||
@@ -71,8 +71,8 @@ /** | ||
var SIZEOF = { | ||
SFNT_TABLE_ENTRY: 16 | ||
, SFNT_HEADER: 12 | ||
, SFNT_NAMETABLE: 6 | ||
, SFNT_NAMETABLE_ENTRY: 12 | ||
, EOT_PREFIX: 82 | ||
}; | ||
SFNT_TABLE_ENTRY: 16, | ||
SFNT_HEADER: 12, | ||
SFNT_NAMETABLE: 6, | ||
SFNT_NAMETABLE_ENTRY: 12, | ||
EOT_PREFIX: 82 | ||
}; | ||
@@ -83,7 +83,7 @@ /** | ||
var MAGIC = { | ||
EOT_VERSION: 0x00020001 | ||
, EOT_MAGIC: 0x504c | ||
, EOT_CHARSET: 1 | ||
, LANGUAGE_ENGLISH: 0x0409 | ||
}; | ||
EOT_VERSION: 0x00020001, | ||
EOT_MAGIC: 0x504c, | ||
EOT_CHARSET: 1, | ||
LANGUAGE_ENGLISH: 0x0409 | ||
}; | ||
@@ -95,3 +95,3 @@ /** | ||
function strbuf(str) { | ||
var b = new ByteBuffer(new Array(str.length + 4)); | ||
var b = new ByteBuffer(str.length + 4); | ||
@@ -101,3 +101,3 @@ b.setUint16 (0, str.length, true); | ||
for (var i = 0; i < str.length; i += 2) { | ||
b.setUint16 (i+2, str.getUint16 (i), true); | ||
b.setUint16 (i + 2, str.getUint16 (i), true); | ||
} | ||
@@ -118,4 +118,4 @@ | ||
var buf = new ByteBuffer(arr); | ||
var out = new ByteBuffer(new Array(SIZEOF.EOT_PREFIX)) | ||
, i, j; | ||
var out = new ByteBuffer(SIZEOF.EOT_PREFIX), | ||
i, j; | ||
@@ -128,20 +128,17 @@ out.fill(0); | ||
var familyName = [] | ||
, subfamilyName = [] | ||
, fullName = [] | ||
, versionString = [] | ||
; | ||
var familyName = [], | ||
subfamilyName = [], | ||
fullName = [], | ||
versionString = []; | ||
var haveOS2 = false | ||
, haveName = false | ||
, haveHead = false | ||
; | ||
var haveOS2 = false, | ||
haveName = false, | ||
haveHead = false; | ||
var numTables = buf.getUint16 (SFNT_OFFSET.NUMTABLES); | ||
for (i = 0; i < numTables; ++i) | ||
{ | ||
var data = new ByteBuffer(buf, SIZEOF.SFNT_HEADER + i*SIZEOF.SFNT_TABLE_ENTRY); | ||
for (i = 0; i < numTables; ++i) { | ||
var data = new ByteBuffer(buf, SIZEOF.SFNT_HEADER + i * SIZEOF.SFNT_TABLE_ENTRY); | ||
var tableEntry = { | ||
tag: data.toString (SFNT_OFFSET.TABLE_TAG, SFNT_OFFSET.TABLE_TAG + 4), | ||
tag: data.toString (SFNT_OFFSET.TABLE_TAG, 4), | ||
offset: data.getUint32 (SFNT_OFFSET.TABLE_OFFSET), | ||
@@ -165,7 +162,7 @@ length: data.getUint32 (SFNT_OFFSET.TABLE_LENGTH) | ||
for (j = 0; j < 4; ++j) { | ||
out.setUint32 (EOT_OFFSET.UNICODE_RANGE + j*4, table.getUint32 (SFNT_OFFSET.OS2_UNICODE_RANGE + j*4), true); | ||
out.setUint32 (EOT_OFFSET.UNICODE_RANGE + j * 4, table.getUint32 (SFNT_OFFSET.OS2_UNICODE_RANGE + j * 4), true); | ||
} | ||
for (j = 0; j < 2; ++j) { | ||
out.setUint32 (EOT_OFFSET.CODEPAGE_RANGE + j*4, table.getUint32 (SFNT_OFFSET.OS2_CODEPAGE_RANGE + j*4), true); | ||
out.setUint32 (EOT_OFFSET.CODEPAGE_RANGE + j * 4, table.getUint32 (SFNT_OFFSET.OS2_CODEPAGE_RANGE + j * 4), true); | ||
} | ||
@@ -183,17 +180,17 @@ | ||
var nameTable = { | ||
format: table.getUint16 (SFNT_OFFSET.NAMETABLE_FORMAT) | ||
, count: table.getUint16 (SFNT_OFFSET.NAMETABLE_COUNT) | ||
, stringOffset: table.getUint16 (SFNT_OFFSET.NAMETABLE_STRING_OFFSET) | ||
}; | ||
format: table.getUint16 (SFNT_OFFSET.NAMETABLE_FORMAT), | ||
count: table.getUint16 (SFNT_OFFSET.NAMETABLE_COUNT), | ||
stringOffset: table.getUint16 (SFNT_OFFSET.NAMETABLE_STRING_OFFSET) | ||
}; | ||
for (j = 0; j < nameTable.count; ++j) { | ||
var nameRecord = new ByteBuffer(table, SIZEOF.SFNT_NAMETABLE + j*SIZEOF.SFNT_NAMETABLE_ENTRY); | ||
var nameRecord = new ByteBuffer(table, SIZEOF.SFNT_NAMETABLE + j * SIZEOF.SFNT_NAMETABLE_ENTRY); | ||
var name = { | ||
platformID: nameRecord.getUint16 (SFNT_OFFSET.NAME_PLATFORM_ID) | ||
, encodingID: nameRecord.getUint16 (SFNT_OFFSET.NAME_ENCODING_ID) | ||
, languageID: nameRecord.getUint16 (SFNT_OFFSET.NAME_LANGUAGE_ID) | ||
, nameID: nameRecord.getUint16 (SFNT_OFFSET.NAME_NAME_ID) | ||
, length: nameRecord.getUint16 (SFNT_OFFSET.NAME_LENGTH) | ||
, offset: nameRecord.getUint16 (SFNT_OFFSET.NAME_OFFSET) | ||
}; | ||
platformID: nameRecord.getUint16 (SFNT_OFFSET.NAME_PLATFORM_ID), | ||
encodingID: nameRecord.getUint16 (SFNT_OFFSET.NAME_ENCODING_ID), | ||
languageID: nameRecord.getUint16 (SFNT_OFFSET.NAME_LANGUAGE_ID), | ||
nameID: nameRecord.getUint16 (SFNT_OFFSET.NAME_NAME_ID), | ||
length: nameRecord.getUint16 (SFNT_OFFSET.NAME_LENGTH), | ||
offset: nameRecord.getUint16 (SFNT_OFFSET.NAME_OFFSET) | ||
}; | ||
@@ -204,14 +201,14 @@ if (name.platformID === 3 && name.encodingID === 1 && name.languageID === MAGIC.LANGUAGE_ENGLISH) { | ||
switch (name.nameID) { | ||
case 1: | ||
familyName = s; | ||
break; | ||
case 2: | ||
subfamilyName = s; | ||
break; | ||
case 4: | ||
fullName = s; | ||
break; | ||
case 5: | ||
versionString = s; | ||
break; | ||
case 1: | ||
familyName = s; | ||
break; | ||
case 2: | ||
subfamilyName = s; | ||
break; | ||
case 4: | ||
fullName = s; | ||
break; | ||
case 5: | ||
versionString = s; | ||
break; | ||
} | ||
@@ -239,3 +236,3 @@ } | ||
// Create final buffer with the the same array type as input one. | ||
var eot = new ByteBuffer(Array.isArray(arr) ? new Array(len) : new Uint8Array(len)); | ||
var eot = new ByteBuffer(len); | ||
@@ -247,3 +244,3 @@ eot.writeBytes(out.buffer); | ||
eot.writeBytes(fullName.buffer); | ||
eot.writeBytes([0, 0]); | ||
eot.writeBytes([ 0, 0 ]); | ||
eot.writeBytes(buf.buffer); | ||
@@ -250,0 +247,0 @@ |
{ | ||
"name" : "ttf2eot", | ||
"version" : "1.3.0", | ||
"description" : "Convert TTF font to EOT", | ||
"keywords" : ["font", "ttf", "eot", "convertor"], | ||
"homepage" : "https://github.com/nodeca/ttf2eot", | ||
"author" : { | ||
"name" : "Viktor Semykin", | ||
"email" : "thesame.ml@gmail.com" | ||
}, | ||
"bugs" : { "url": "https://github.com/fontello/ttf2eot/issues" }, | ||
"licenses" : [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/fontello/ttf2eot/raw/master/LICENSE" | ||
} | ||
], | ||
"dependencies" : { "argparse": "~0.1.15" }, | ||
"repository" : { | ||
"type": "git", | ||
"url": "git://github.com/fontello/ttf2eot.git" | ||
}, | ||
"main" : "./index.js", | ||
"bin" : { | ||
"ttf2eot": "./ttf2eot.js" | ||
} | ||
"name": "ttf2eot", | ||
"version": "2.0.0", | ||
"description": "Convert TTF font to EOT", | ||
"keywords": [ | ||
"font", | ||
"ttf", | ||
"eot", | ||
"convertor" | ||
], | ||
"author": "Viktor Semykin <thesame.ml@gmail.com>", | ||
"license": "MIT", | ||
"repository": "fontello/ttf2eot", | ||
"bin": { | ||
"ttf2eot": "./ttf2eot.js" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"ttf2eot.js" | ||
], | ||
"scripts": { | ||
"lint": "./node_modules/.bin/eslint .", | ||
"test": "npm run lint && ./node_modules/.bin/mocha" | ||
}, | ||
"dependencies": { | ||
"argparse": "^1.0.6", | ||
"microbuffer": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^2.3.0", | ||
"mocha": "^2.4.5" | ||
} | ||
} | ||
@@ -51,5 +51,5 @@ ttf2eot | ||
Copyright (c) 2013 [Vitaly Puzrin](https://github.com/puzrin). | ||
Copyright (c) 2013-2016 [Vitaly Puzrin](https://github.com/puzrin). | ||
Released under the MIT license. See | ||
[LICENSE](https://github.com/nodeca/ttf2eot/blob/master/LICENSE) for details. | ||
@@ -38,2 +38,4 @@ #!/usr/bin/env node | ||
/* eslint-disable no-console */ | ||
var args = parser.parseArgs(); | ||
@@ -51,3 +53,3 @@ | ||
} | ||
} catch(e) { | ||
} catch (e) { | ||
console.error("Can't open input file (%s)", args.infile || 'stdin'); | ||
@@ -54,0 +56,0 @@ process.exit(1); |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
10707
2
2
6
245
1
2
1
+ Addedmicrobuffer@^1.0.0
+ Addedargparse@1.0.10(transitive)
+ Addedmicrobuffer@1.0.0(transitive)
+ Addedsprintf-js@1.0.3(transitive)
- Removedargparse@0.1.16(transitive)
- Removedunderscore@1.7.0(transitive)
- Removedunderscore.string@2.4.0(transitive)
Updatedargparse@^1.0.6