Comparing version 0.1.1 to 0.2.0
var Subset = module.exports = function(font) { | ||
this.font = font | ||
this.font = font.clone() | ||
this.subset = { '32': 32 } | ||
@@ -100,2 +100,6 @@ this.mapping = { '32': 32 } | ||
this.font.tables.name.embed(cmap.charMap) | ||
} | ||
Subset.prototype.save = function() { | ||
return this.font.save() | ||
} |
@@ -12,2 +12,8 @@ var Struct = require('structjs') | ||
Glyf.prototype.clone = function() { | ||
var clone = new Glyf(this.loca) | ||
clone.cache = this.cache | ||
return clone | ||
} | ||
Glyf.prototype.embed = function(glyphs, mapping, old2new) { | ||
@@ -14,0 +20,0 @@ var offsets = [], offset = 0 |
@@ -6,6 +6,12 @@ var Directory = require('./directory') | ||
var self = this | ||
this.buffer = buffer = buffer instanceof ArrayBuffer ? buffer : toArrayBuffer(buffer) | ||
this.buffer = buffer instanceof TTFFont | ||
? buffer.buffer | ||
: buffer = buffer instanceof ArrayBuffer ? buffer : toArrayBuffer(buffer) | ||
this.directory = new Directory() | ||
this.directory.unpack(new DataView(buffer)) | ||
if (buffer instanceof TTFFont) { | ||
this.directory = buffer.directory.clone() | ||
} else { | ||
this.directory = new Directory() | ||
this.directory.unpack(new DataView(buffer)) | ||
} | ||
@@ -22,2 +28,6 @@ var scalerType = this.directory.scalerType.toString(16) | ||
if (!entry) return | ||
if (buffer instanceof TTFFont) { | ||
self.tables[name] = self.tables[table] = buffer.tables[table].clone() | ||
return | ||
} | ||
var Table = require('./table/' + name) | ||
@@ -120,4 +130,12 @@ , view = new DataView(buffer, entry.offset, entry.length) | ||
TTFFont.TABLES = ['cmap', 'glyf', 'loca', 'hmtx', 'hhea', 'maxp', 'post', 'name', 'head', 'OS/2'] | ||
TTFFont.prototype.clone = function() { | ||
var clone = new TTFFont(this) | ||
clone.tables.glyf.view = this.tables.glyf.view | ||
return clone | ||
} | ||
TTFFont.prototype.save = function() { | ||
var self = this, tables = ['cmap', 'glyf', 'loca', 'hmtx', 'hhea', 'maxp', 'post', 'name', 'head', 'OS/2'] | ||
var self = this, tables = TTFFont.TABLES | ||
for (var name in this.directory.entries) { | ||
@@ -141,3 +159,3 @@ if (!!!~tables.indexOf(name)) delete this.directory.entries[name] | ||
var view = new DataView(new ArrayBuffer(size + 1000)) | ||
var view = new DataView(new ArrayBuffer(size)) | ||
@@ -144,0 +162,0 @@ tables.forEach(function(name) { |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"main": "./lib/ttf", | ||
@@ -10,0 +10,0 @@ "homepage": "https://github.com/rkusa/ttfjs", |
@@ -7,3 +7,3 @@ # ttfjs | ||
{ "name": "ttfjs", | ||
"version": "0.1.1" } | ||
"version": "0.2.0" } | ||
``` | ||
@@ -10,0 +10,0 @@ |
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
38092
18
804