Permalink
Browse files

FIxed bug in setting font property

  • Loading branch information...
nvh committed Jul 11, 2017
1 parent 4ce455d commit 0697f9369a79da1391e9ca413d17cebe0e270d8c
Showing with 25 additions and 3 deletions.
  1. +2 −2 framer/TextLayer.coffee
  2. +23 −1 test/tests/TextLayerTest.coffee
View
@@ -407,7 +407,7 @@ class exports.TextLayer extends Layer
do (property) =>
@on "change:#{property}", (value) =>
# make an exception for fontSize, as it needs to be set on the inner style
if property isnt "fontSize"
if not (property in ["fontSize", "font"])
@_styledText.resetStyle(property)
@renderText()
@@ -492,7 +492,7 @@ class exports.TextLayer extends Layer
# Check if value contains number. We then assume proper use of font.
# Otherwise, we default to setting the fontFamily.
if /\d/.test(value)
layer._elementHTML.style.font = value
layer._styledText.setStyle("font", value)
else
layer.fontFamily = value
, "_elementHTML"
@@ -282,7 +282,7 @@ describe "TextLayer", ->
padding: 10
layerA.style.padding.should.equal "20px"
describe "webfonts", ->
describe "Fonts", ->
it "sets the weight if the font property is set", ->
l = new TextLayer
font: Utils.loadWebFont("Raleway", 800)
@@ -295,6 +295,28 @@ describe "TextLayer", ->
l.fontFamily.should.equal "Raleway"
expect(l.fontWeight).to.equal 400
it "should set the font property correctly", ->
tagLayer1 = new TextLayer
x: 24
y: 24
text: "tag"
fontSize: 15
fontFamily: "Courier"
fontWeight: 400
lineHeight: 1.6
color: "white"
backgroundColor: "red"
tagLayer2 = new TextLayer
x: 24
y: 200
text: "tag"
font: "400 15px/1.6 Courier"
color: "white"
backgroundColor: "red"
tagLayer1.size.should.eql tagLayer2.size
describe "textOverflow", ->
it "should enable clipping", ->
l = new TextLayer

0 comments on commit 0697f93

Please sign in to comment.