Skip to content

Instantly share code, notes, and snippets.

@jonbenwaa
Forked from mistakster/fonts-mixin.less
Created July 31, 2016 16:32
Show Gist options
  • Select an option

  • Save jonbenwaa/40e898f1d19b33557cf34b2c83c44f86 to your computer and use it in GitHub Desktop.

Select an option

Save jonbenwaa/40e898f1d19b33557cf34b2c83c44f86 to your computer and use it in GitHub Desktop.
// Conver scale factor into pixels
.fontScale(@scale: 0) {
@list: 14px, 16px, 20px, 24px, 28px, 34px, 41px, 50px, 60px;
.test-args(@scale) when (@scale >= -2) and (@scale <= 6) {
font-size: extract(@list, @scale + 3);
}
.test-args(@scale);
}
// Apply font with provided size or scale
.fontTimes(@size: "") {
font-family: "Times New Roman", serif;
.test-args() when (ispixel(@size)) {
font-size: @size;
}
.test-args() when (isnumber(@size)) and not (ispixel(@size)) {
.fontScale(@size);
}
.test-args();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment