Skip to content

Instantly share code, notes, and snippets.

@thasmo
Last active Oct 24, 2021
Embed
What would you like to do?
Generated by SassMeister.com.
// PACKAGE
@use 'sass:map';
@use 'sass:string';
@use 'sass:math';
$name: 'Open Sans';
$suffix: 'Variable';
$identifier: 'open-sans';
$formats: ('woff', 'woff2');
$directory: '~@fontsource/#{$identifier}/files';
$characters: (
cyrillic-ext: (
U+0460-052F,
U+1C80-1C88,
U+20B4,
U+2DE0-2DFF,
U+A640-A69F,
U+FE2E-FE2F,
),
cyrillic: (
U+0400-045F,
U+0490-0491,
U+04B0-04B1,
U+2116,
),
greek-ext: (
U+1F00-1FFF,
),
greek: (
U+0370-03FF,
),
hebrew: (
U+0590-05FF,
U+20AA,
U+25CC,
U+FB1D-FB4F,
),
vietnamese: (
U+0102-0103,
U+0110-0111,
U+0128-0129,
U+0168-0169,
U+01A0-01A1,
U+01AF-01B0,
U+1EA0-1EF9,
U+20AB,
),
latin-ext: (
U+0100-024F,
U+0259,
U+1E00-1EFF,
U+2020,
U+20A0-20AB,
U+20AD-20CF,
U+2113,
U+2C60-2C7F,
U+A720-A7FF,
),
latin: (
U+0000-00FF,
U+0131,
U+0152-0153,
U+02BB-02BC,
U+02C6,
U+02DA,
U+02DC,
U+2000-206F,
U+2074,
U+20AC,
U+2122,
U+2191,
U+2193,
U+2212,
U+2215,
U+FEFF,
U+FFFD,
),
);
$axes: (
ital: (
default: 0,
min: 0,
max: 1,
step: 1,
),
wdth: (
default: 100,
min: 75,
max: 100,
step: 0.1,
),
wght: (
default: 400,
min: 300,
max: 800,
step: 1,
),
);
@mixin face(
$name: $name, // font-family
$weight: 400, // font-weight
$style: normal, // font-style
$stretch: null, // font-stretch
$display: null, // font-display
$variant: null, // variable font variant
$subsets: map.keys($characters), // character subsets
) {
@each $subset in $subsets {
@font-face {
font-family: string.quote($name);
font-weight: $weight;
font-style: $style;
font-stretch: $stretch;
font-display: $display;
@if map.has-key($characters, $subset) {
unicode-range: map.get($characters, $subset);
}
src:
url('#{$directory}/#{$identifier}-#{$subset}-#{$weight}-#{$style}.woff2') format('woff2'),
url('#{$directory}/#{$identifier}-all-#{$weight}-#{$style}.woff') format('woff');
}
@if $variant {
@font-face {
font-family: string.quote(#{$name $suffix});
font-weight: $weight;
font-style: $style;
font-display: $display;
@if $variant == all {
font-stretch: math.percentage(map.get($axes, wdth, min) / 100) math.percentage(map.get($axes, wdth, max) / 100);
}
@if map.has-key($characters, $subset) {
unicode-range: map.get($characters, $subset);
}
src:
url('#{$directory}/#{$identifier}-#{$subset}-variable-#{$variant}-#{$style}.woff2') format('woff2');
}
}
}
}
// USAGE
@include face(
$weight: 300,
$style: normal,
);
@include face(
$weight: 500,
$style: italic,
$variant: all,
$subsets: (latin, latin-ext, hebrew),
);
@font-face {
font-family: "Open Sans";
font-weight: 300;
font-style: normal;
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
src: url("~@fontsource/open-sans/files/open-sans-cyrillic-ext-300-normal.woff2") format("woff2"), url("~@fontsource/open-sans/files/open-sans-all-300-normal.woff") format("woff");
}
@font-face {
font-family: "Open Sans";
font-weight: 300;
font-style: normal;
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
src: url("~@fontsource/open-sans/files/open-sans-cyrillic-300-normal.woff2") format("woff2"), url("~@fontsource/open-sans/files/open-sans-all-300-normal.woff") format("woff");
}
@font-face {
font-family: "Open Sans";
font-weight: 300;
font-style: normal;
unicode-range: U+1F00-1FFF;
src: url("~@fontsource/open-sans/files/open-sans-greek-ext-300-normal.woff2") format("woff2"), url("~@fontsource/open-sans/files/open-sans-all-300-normal.woff") format("woff");
}
@font-face {
font-family: "Open Sans";
font-weight: 300;
font-style: normal;
unicode-range: U+0370-03FF;
src: url("~@fontsource/open-sans/files/open-sans-greek-300-normal.woff2") format("woff2"), url("~@fontsource/open-sans/files/open-sans-all-300-normal.woff") format("woff");
}
@font-face {
font-family: "Open Sans";
font-weight: 300;
font-style: normal;
unicode-range: U+0590-05FF, U+20AA, U+25CC, U+FB1D-FB4F;
src: url("~@fontsource/open-sans/files/open-sans-hebrew-300-normal.woff2") format("woff2"), url("~@fontsource/open-sans/files/open-sans-all-300-normal.woff") format("woff");
}
@font-face {
font-family: "Open Sans";
font-weight: 300;
font-style: normal;
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB;
src: url("~@fontsource/open-sans/files/open-sans-vietnamese-300-normal.woff2") format("woff2"), url("~@fontsource/open-sans/files/open-sans-all-300-normal.woff") format("woff");
}
@font-face {
font-family: "Open Sans";
font-weight: 300;
font-style: normal;
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
src: url("~@fontsource/open-sans/files/open-sans-latin-ext-300-normal.woff2") format("woff2"), url("~@fontsource/open-sans/files/open-sans-all-300-normal.woff") format("woff");
}
@font-face {
font-family: "Open Sans";
font-weight: 300;
font-style: normal;
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
src: url("~@fontsource/open-sans/files/open-sans-latin-300-normal.woff2") format("woff2"), url("~@fontsource/open-sans/files/open-sans-all-300-normal.woff") format("woff");
}
@font-face {
font-family: "Open Sans";
font-weight: 500;
font-style: italic;
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
src: url("~@fontsource/open-sans/files/open-sans-latin-500-italic.woff2") format("woff2"), url("~@fontsource/open-sans/files/open-sans-all-500-italic.woff") format("woff");
}
@font-face {
font-family: "Open Sans Variable";
font-weight: 500;
font-style: italic;
font-stretch: 75% 100%;
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
src: url("~@fontsource/open-sans/files/open-sans-latin-variable-all-italic.woff2") format("woff2");
}
@font-face {
font-family: "Open Sans";
font-weight: 500;
font-style: italic;
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
src: url("~@fontsource/open-sans/files/open-sans-latin-ext-500-italic.woff2") format("woff2"), url("~@fontsource/open-sans/files/open-sans-all-500-italic.woff") format("woff");
}
@font-face {
font-family: "Open Sans Variable";
font-weight: 500;
font-style: italic;
font-stretch: 75% 100%;
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
src: url("~@fontsource/open-sans/files/open-sans-latin-ext-variable-all-italic.woff2") format("woff2");
}
@font-face {
font-family: "Open Sans";
font-weight: 500;
font-style: italic;
unicode-range: U+0590-05FF, U+20AA, U+25CC, U+FB1D-FB4F;
src: url("~@fontsource/open-sans/files/open-sans-hebrew-500-italic.woff2") format("woff2"), url("~@fontsource/open-sans/files/open-sans-all-500-italic.woff") format("woff");
}
@font-face {
font-family: "Open Sans Variable";
font-weight: 500;
font-style: italic;
font-stretch: 75% 100%;
unicode-range: U+0590-05FF, U+20AA, U+25CC, U+FB1D-FB4F;
src: url("~@fontsource/open-sans/files/open-sans-hebrew-variable-all-italic.woff2") format("woff2");
}
{
"sass": {
"compiler": "dart-sass/1.32.12",
"extensions": {},
"syntax": "SCSS",
"outputStyle": "expanded"
},
"autoprefixer": false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment