Commit 8be456c8 authored by Ryan LeFevre's avatar Ryan LeFevre

Add enginedata parsing and ability to get fonts

parent 4a810737
var _ = require('lodash');
var PSD = require('../../');
var file = process.argv[2] || './examples/images/example.psd';
PSD.open(file).then(function (psd) {
var type, fonts = [];
psd.tree().descendants().forEach(function (node) {
type = node.get('typeTool');
if (!type) return;
fonts = fonts.concat(type.fonts());
});
console.log(_.uniq(fonts));
});
parseEngineData = require 'parse-engine-data'
LayerInfo = require '../layer_info.coffee' LayerInfo = require '../layer_info.coffee'
Descriptor = require '../descriptor.coffee' Descriptor = require '../descriptor.coffee'
...@@ -15,6 +16,7 @@ module.exports = class TextElements extends LayerInfo ...@@ -15,6 +16,7 @@ module.exports = class TextElements extends LayerInfo
@textVersion = null @textVersion = null
@descriptorVersion = null @descriptorVersion = null
@textData = null @textData = null
@engineData = null
@textValue = null @textValue = null
@warpVersion = null @warpVersion = null
@descriptorVersion = null @descriptorVersion = null
...@@ -32,6 +34,7 @@ module.exports = class TextElements extends LayerInfo ...@@ -32,6 +34,7 @@ module.exports = class TextElements extends LayerInfo
@textData = new Descriptor(@file).parse() @textData = new Descriptor(@file).parse()
@textValue = @textData['Txt '] @textValue = @textData['Txt ']
@engineData = parseEngineData(@textData.EngineData)
@warpVersion = @file.readShort() @warpVersion = @file.readShort()
...@@ -41,3 +44,7 @@ module.exports = class TextElements extends LayerInfo ...@@ -41,3 +44,7 @@ module.exports = class TextElements extends LayerInfo
for name, index in COORDS_VALUE for name, index in COORDS_VALUE
@coords[name] = @file.readDouble() @coords[name] = @file.readDouble()
fonts: ->
return [] unless @engineData?
@engineData.ResourceDict.FontSet.map (f) -> f.Name
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
"coffee-script": "~ 1.7.1", "coffee-script": "~ 1.7.1",
"jspack": "~ 0.0.3", "jspack": "~ 0.0.3",
"coffeescript-module": "~ 0.2.1", "coffeescript-module": "~ 0.2.1",
"parse-engine-data": "~ 0.1",
"pngjs": "~ 0.4.0", "pngjs": "~ 0.4.0",
"rsvp": "~ 3.0.6", "rsvp": "~ 3.0.6",
"lodash": "~ 2.4", "lodash": "~ 2.4",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment