Skip to content

Commit

Permalink
Setting the default font if no other font is set
Browse files Browse the repository at this point in the history
  • Loading branch information
nvh committed Mar 22, 2017
1 parent 1c7d70d commit 570aa20
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions framer/TextLayer.coffee
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class exports.TextLayer extends Layer
fontSize: 40 fontSize: 40
fontWeight: 400 fontWeight: 400
lineHeight: 1.25 lineHeight: 1.25
font: options.fontFamily ? @defaultFont()


super options super options


Expand All @@ -51,11 +52,6 @@ class exports.TextLayer extends Layer
# Reset width and height # Reset width and height
@autoSize() @autoSize()


print @defaultFont()

# Set defaults
@fontFamily = @defaultFont()

for key, value of options for key, value of options
if _.isFunction(value) and @[key]? if _.isFunction(value) and @[key]?
@[key] = value @[key] = value
Expand All @@ -73,7 +69,6 @@ class exports.TextLayer extends Layer
@on "change:height", @updateExplicitHeight @on "change:height", @updateExplicitHeight


defaultFont: => defaultFont: =>

# Store current device # Store current device
@_currentDevice = Framer.Device.deviceType @_currentDevice = Framer.Device.deviceType


Expand Down Expand Up @@ -139,7 +134,7 @@ class exports.TextLayer extends Layer
@style.padding = @style.padding =
"#{@_padding.top}px #{@_padding.right}px #{@_padding.bottom}px #{@_padding.left}px" "#{@_padding.top}px #{@_padding.right}px #{@_padding.bottom}px #{@_padding.left}px"


@define "fontFamily", layerProperty(@, "fontFamily", "fontFamily", null, _.isString, {}, (layer, value) -> layer.font = value) @define "fontFamily", layerProperty(@, "fontFamily", "fontFamily", null, _.isString, null, (layer, value) -> layer.font = value)
@define "fontSize", layerProperty(@, "fontSize", "fontSize", null, _.isNumber) @define "fontSize", layerProperty(@, "fontSize", "fontSize", null, _.isNumber)
@define "fontWeight", layerProperty(@, "fontWeight", "fontWeight") @define "fontWeight", layerProperty(@, "fontWeight", "fontWeight")
@define "fontStyle", layerProperty(@, "fontStyle", "fontStyle", "normal", _.isString) @define "fontStyle", layerProperty(@, "fontStyle", "fontStyle", "normal", _.isString)
Expand Down

0 comments on commit 570aa20

Please sign in to comment.