Comparing version 0.2.0 to 0.2.1
@@ -9,3 +9,3 @@ var Directory = require('./directory') | ||
: buffer = buffer instanceof ArrayBuffer ? buffer : toArrayBuffer(buffer) | ||
if (buffer instanceof TTFFont) { | ||
@@ -17,3 +17,3 @@ this.directory = buffer.directory.clone() | ||
} | ||
var scalerType = this.directory.scalerType.toString(16) | ||
@@ -23,3 +23,3 @@ if (scalerType !== '74727565' && scalerType !== '10000') { | ||
} | ||
this.tables = {} | ||
@@ -39,3 +39,3 @@ function unpackTable(table, args) { | ||
} | ||
// workaround for browserify | ||
@@ -54,3 +54,3 @@ if (false) { | ||
} | ||
unpackTable('cmap') | ||
@@ -78,10 +78,10 @@ for (var i = 0, len = this.tables.cmap.subtables.length; i < len; ++i) { | ||
unpackTable('OS/2') | ||
this.baseFont = this.tables.name.records.filter(function(record) { | ||
return record.nameID === 6 | ||
})[0].string | ||
this.fontName = 'MARKUS+' + this.baseFont | ||
this.fontName = 'TTFJS+' + this.baseFont | ||
this.scaleFactor = 1000.0 / this.tables.head.unitsPerEm | ||
this.italicAngle = parseFloat(this.tables.post.italicAngleHi + '.' + this.tables.post.italicAngleLow) | ||
@@ -97,3 +97,3 @@ var os2 = this.tables.os2 || {} | ||
}) | ||
var flags = 0, familyClass = (os2.sFamilyClass || 0) >> 8 | ||
@@ -114,2 +114,3 @@ , isSerif = !!~[1, 2, 3, 4, 5, 6, 7].indexOf(familyClass) | ||
} | ||
this.avgCharWidth = this.tables.os2 && (this.tables.os2.xAvgCharWidth * this.scaleFactor) || 0 | ||
} | ||
@@ -121,3 +122,3 @@ | ||
var code = string.charCodeAt(i) - 32 // - 32 because of non AFM font | ||
width += this.widths[code] || 0 | ||
width += this.widths[code] || this.avgCharWidth | ||
} | ||
@@ -150,3 +151,3 @@ return width * scale | ||
} | ||
// calculate total size | ||
@@ -162,6 +163,6 @@ var size = offset = this.directory.lengthFor(this.directory, true) * this.directory.sizeFor(this.directory, true) | ||
}) | ||
// prepare head | ||
this.tables.head.checkSumAdjustment = 0 | ||
var view = new DataView(new ArrayBuffer(size)) | ||
@@ -181,3 +182,3 @@ | ||
} | ||
// pad up to a length completely divisible by 4 | ||
@@ -187,3 +188,3 @@ var padding = entry.length % 4, length = entry.length + padding | ||
view.setInt8(i, 0) | ||
// checksum | ||
@@ -194,9 +195,9 @@ var sum = 0 | ||
entry.checkSum = sum | ||
// update offset for the next table | ||
offset += length | ||
}) | ||
this.directory.pack(view, 0) | ||
// file checksum | ||
@@ -208,3 +209,3 @@ var sum = 0 | ||
this.tables.head.pack(view, this.directory.entries.head.offset) | ||
return view.buffer | ||
@@ -211,0 +212,0 @@ } |
@@ -7,3 +7,4 @@ { | ||
}, | ||
"version": "0.2.0", | ||
"description": "TTFjs is a TrueType font parser entirely written in JavaScript and compatible to both Node.js and the Browser.", | ||
"version": "0.2.1", | ||
"main": "./lib/ttf", | ||
@@ -10,0 +11,0 @@ "homepage": "https://github.com/rkusa/ttfjs", |
@@ -5,10 +5,8 @@ # ttfjs | ||
```json | ||
{ "name": "ttfjs", | ||
"version": "0.2.0" } | ||
``` | ||
[![NPM][npm]](https://npmjs.org/package/ttfjs) | ||
[![Dependency Status][deps]](https://david-dm.org/rkusa/ttfjs) | ||
### Specification Coverage | ||
The following tables are implemented: **cmap** (currently only format 4), **glyf** (glyphs are not actually decomposed, only rewritten), **head**, **hhea**, **hmtx**, **loca**, **maxp**, **name**, **os2**, **post** (currently only format 3). | ||
The following tables are implemented: **cmap** (currently only format 4), **glyf** (glyphs are not actually decomposed, only rewritten), **head**, **hhea**, **hmtx**, **loca**, **maxp**, **name**, **os2**, **post** (currently only format 3). | ||
@@ -22,3 +20,3 @@ **TrueType Font Specification:** [Apple](https://developer.apple.com/fonts/TTRefMan/RM06/Chap6.html), [Microsoft](http://www.microsoft.com/typography/specs/default.htm) | ||
## MIT License | ||
Copyright (c) 2013 Markus Ast | ||
Copyright (c) 2013-2014 Markus Ast | ||
@@ -30,1 +28,4 @@ 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 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. | ||
[npm]: http://img.shields.io/npm/v/ttfjs.svg?style=flat | ||
[deps]: http://img.shields.io/david/rkusa/ttfjs.svg?style=flat |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
805
30649