Permalink
Browse files

Improved deviceFont util

  • Loading branch information...
nvh committed Mar 23, 2017
1 parent ed66ccb commit cd53f5d9c1c969a22bca1a94f16d870660f13014
Showing with 16 additions and 23 deletions.
  1. +1 −12 framer/TextLayer.coffee
  2. +14 −10 framer/Utils.coffee
  3. +1 −1 test/tests/TextLayerTest.coffee
View
@@ -69,18 +69,7 @@ class exports.TextLayer extends Layer
@on "change:height", @updateExplicitHeight
defaultFont: ->
appleFont = "-apple-system, SF UI Text, Helvetica Neue"
googleFont = "Roboto, Helvetica Neue"
microsoftFont = "Segoe UI, Helvetica Neue"
switch Framer.Device.platform()
when "Android" then return googleFont
when "iOS", "watchOS", "macOS" then return appleFont
when "Windows" then return microsoftFont
if Utils.isAndroid()
return googleFont
if Utils.isEdge()
return microsoftFont
return appleFont
return Utils.deviceFont(Framer.Device.platform())
autoSize: =>
constraints =
View
@@ -433,16 +433,20 @@ Utils.deviceFont = (os) ->
# https://github.com/jonathantneal/system-font-css
if not os
os = "macos" if Utils.isMacOS()
os = "ios" if Utils.isIOS()
os = "android" if Utils.isAndroid()
os = "windows" if Utils.isWindows()
return "-apple-system, SF UI Text, Helvetica Neue" if os is "macos"
return "-apple-system, SF UI Text, Helvetica Neue" if os is "ios"
return "Roboto, Helvetica Neue" if os is "android"
return "Segoe UI" if os is "windows"
return "Helvetica"
os = "macOS" if Utils.isMacOS()
os = "iOS" if Utils.isIOS()
os = "Android" if Utils.isAndroid()
os = "Windows" if Utils.isWindows()
appleFont = "-apple-system, BlinkMacSystemFont, SF UI Text, Helvetica Neue"
googleFont = "Roboto, Helvetica Neue"
microsoftFont = "Segoe UI, Helvetica Neue"
switch os
when "Android" then return googleFont
when "iOS", "watchOS", "macOS" then return appleFont
when "Windows" then return microsoftFont
return appleFont
# Load fonts from Google Web Fonts
_loadedFonts = []
@@ -18,7 +18,7 @@ describe "TextLayer", ->
text.fontWeight.should.equal 400
text.lineHeight.should.equal 1.25
text.fontStyle.should.equal "normal"
text.style.fontFamily.should.equal "-apple-system, 'SF UI Text', 'Helvetica Neue'"
text.style.fontFamily.should.equal "-apple-system, BlinkMacSystemFont, 'SF UI Text', 'Helvetica Neue'"
it "should not set the default fontFamily default if the fontFamily property is set", ->
text = new TextLayer

0 comments on commit cd53f5d

Please sign in to comment.