Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
psd.js
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
regiostart
psd.js
Commits
2ac22aef
Commit
2ac22aef
authored
Mar 28, 2015
by
Ryan LeFevre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add CSS and export functions to type layers
parent
a27023a9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
4 deletions
+29
-4
fonts.js
examples/node/fonts.js
+0
-3
typetool.coffee
lib/psd/layer_info/typetool.coffee
+29
-1
No files found.
examples/node/fonts.js
View file @
2ac22aef
...
...
@@ -8,9 +8,6 @@ PSD.open(file).then(function (psd) {
type
=
node
.
get
(
'typeTool'
);
if
(
!
type
)
return
;
fonts
=
fonts
.
concat
(
type
.
fonts
());
console
.
log
(
type
.
sizes
());
console
.
log
(
type
.
alignment
());
// type.styles();
});
console
.
log
(
_
.
uniq
(
fonts
));
...
...
lib/psd/layer_info/typetool.coffee
View file @
2ac22aef
...
...
@@ -52,7 +52,7 @@ module.exports = class TextElements extends LayerInfo
sizes
:
->
return
[]
if
not
@
engineData
?
and
not
@
styles
().
FontSize
?
_
.
uniq
@
styles
().
FontSize
@
styles
().
FontSize
alignment
:
->
return
[]
unless
@
engineData
?
...
...
@@ -84,3 +84,31 @@ module.exports = class TextElements extends LayerInfo
m
[
k
].
push
v
m
,
{})
# Creates the CSS string and returns it. Each property is newline separated
# and not all properties may be present depending on the document.
#
# Colors are returned in rgba() format and fonts may include some internal
# Photoshop fonts.
toCSS
:
->
definition
=
'font-family'
:
@
fonts
().
join
(
', '
)
'font-size'
:
"
#{
@
sizes
()[
0
]
}
pt"
'color'
:
"rgba(
#{
@
colors
()[
0
].
join
(
', '
)
}
)"
'text-align'
:
@
alignment
()[
0
]
css
=
[]
for
k
,
v
of
definition
continue
unless
v
?
css
.
push
"
#{
k
}
:
#{
v
}
;"
css
.
join
(
"
\n
"
)
export
:
->
value
:
@
textValue
font
:
@
fonts
()[
0
]
left
:
@
coords
.
left
top
:
@
coords
.
top
right
:
@
coords
.
right
bottom
:
@
coords
.
bottom
transform
:
@
transform
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment