Skip to content

Instantly share code, notes, and snippets.

@davidyeiser
Created January 12, 2016 18:37
Show Gist options
  • Save davidyeiser/2184dd2802756d73e877 to your computer and use it in GitHub Desktop.
Save davidyeiser/2184dd2802756d73e877 to your computer and use it in GitHub Desktop.
Typesetting with Sass
@function pem($target, $context: $em_base)
@return #{$target / $context}em
@function prem($target, $context: $em_base)
@return #{$target / $context}rem
@mixin setFont($face: "regular", $size: 0, $line-height: 0)
$family: "Helvetica Neue", Arial, sans-serif
$style: normal
$weight: normal
@if $face == "bold"
$family: "Helvetica Neue", Arial, sans-serif
$style: normal
$weight: 700
@else if $face == "serif"
$family: Georgia, serif
$style: normal
$weight: 400
@else if $face == "serif-italic"
$family: Georgia, serif
$style: italic
$weight: 400
@else
$family: "Helvetica Neue", Arial, sans-serif
$style: normal
$weight: normal
font:
family: $family
@if $size != 0
size: prem($size)
style: $style
weight: $weight
@if $line-height != 0
line-height: pem($line-height, $size)
@davidyeiser
Copy link
Author

Example use:

p
  @include setFont("regular", 16, 23)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment