Commit eff5abdf authored by Ryan LeFevre's avatar Ryan LeFevre

Add text size and alignment fetching from text layers

parent b1acb47d
...@@ -8,6 +8,9 @@ PSD.open(file).then(function (psd) { ...@@ -8,6 +8,9 @@ PSD.open(file).then(function (psd) {
type = node.get('typeTool'); type = node.get('typeTool');
if (!type) return; if (!type) return;
fonts = fonts.concat(type.fonts()); fonts = fonts.concat(type.fonts());
console.log(type.sizes());
console.log(type.alignment());
// type.styles();
}); });
console.log(_.uniq(fonts)); console.log(_.uniq(fonts));
......
_ = require 'lodash'
parseEngineData = require 'parse-engine-data' parseEngineData = require 'parse-engine-data'
LayerInfo = require '../layer_info.coffee' LayerInfo = require '../layer_info.coffee'
Descriptor = require '../descriptor.coffee' Descriptor = require '../descriptor.coffee'
...@@ -48,3 +49,27 @@ module.exports = class TextElements extends LayerInfo ...@@ -48,3 +49,27 @@ module.exports = class TextElements extends LayerInfo
fonts: -> fonts: ->
return [] unless @engineData? return [] unless @engineData?
@engineData.ResourceDict.FontSet.map (f) -> f.Name @engineData.ResourceDict.FontSet.map (f) -> f.Name
sizes: ->
return [] if not @engineData? and not @styles().FontSize?
_.uniq @styles().FontSize
alignment: ->
return [] unless @engineData?
alignments = ['left', 'right', 'center', 'justify']
@engineData.EngineDict.ParagraphRun.RunArray.map (s) ->
alignments[Math.min(parseInt(s.ParagraphSheet.Properties.Justification, 10), 3)]
styles: ->
return {} unless @engineData?
return @_styles if @_styles?
data = @engineData.EngineDict.StyleRun.RunArray.map (r) ->
r.StyleSheet.StyleSheetData
@_styles = _.reduce(data, (m, o) ->
for own k, v of o
m[k] or= []
m[k].push v
m
, {})
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