Skip to content

Instantly share code, notes, and snippets.

@mistakster
Created December 15, 2015 13:21
Show Gist options
  • Select an option

  • Save mistakster/2dceffdab9f2afdd8321 to your computer and use it in GitHub Desktop.

Select an option

Save mistakster/2dceffdab9f2afdd8321 to your computer and use it in GitHub Desktop.

Revisions

  1. mistakster created this gist Dec 15, 2015.
    25 changes: 25 additions & 0 deletions fonts-mixin.less
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    // 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();
    }