Skip to content

Instantly share code, notes, and snippets.

@LoyEgor
Last active July 16, 2017 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LoyEgor/6acb2e1b7c06a70fcf5386de902b0b0d to your computer and use it in GitHub Desktop.
Save LoyEgor/6acb2e1b7c06a70fcf5386de902b0b0d to your computer and use it in GitHub Desktop.
/* fonts var */
@fdir: '../fonts/';
@ff-name: AvenirNextCyr CirceRoundedAlt;
@ff-style-1: Regular Bold BoldItalic;
@ff-style-2: Regular Bold;
@ff-count: length(@ff-name);
/* set to none if no need. Then use .ff(n,n) where first n - number of font, second for style of font */
@ff-name-short: av ci;
@ff-style-1-short: rg bd bdi;
@ff-style-2-short: rg bd;
// доделать
// возможность установить шрифт по умолчанию и стиль по умолчанию. Чтобы можно было использовать .ff(bd) и это был AvenirNextCyr Bold или .ff(ci) и это был CirceRoundedAlt Regular. Желательно чтобы работало и .ff(1)
.ff-mixin(@iname:1) when (@iname =< @ff-count) {
@ff-name-current: extract(@ff-name, @iname);
@ff-style-current-var: 'ff-style-@{iname}';
@ff-style-count: length(@@ff-style-current-var);
.ff-mixin_style(@istyle:1) when (@istyle =< @ff-style-count) {
@ff-style-current: extract(@@ff-style-current-var, @istyle);
@ff-name-current-var: '@{ff-name-current}-@{ff-style-current}';
@font-face {
font-family: @ff-name-current-var;
src: url('@{fdir}@{ff-name-current}-@{ff-style-current}.eot');
src: url('@{fdir}@{ff-name-current}-@{ff-style-current}.woff') format('woff');
font-weight: normal;
font-style: normal;
}
@ff-name-short-current: extract(@ff-name-short, @iname);
@ff-style-short-current-var: 'ff-style-@{iname}-short';
@ff-style-short-current: extract(@@ff-style-short-current-var, @istyle);
.ff(@a, @b) when (@a = @ff-name-short-current) and (@b = @ff-style-short-current) or (@a = @iname) and (@b = @istyle) {
font-family: @ff-name-current-var, Arial, Helvetica Neue, Helvetica, sans-serif;
}
.ff-mixin_style(@istyle + 1);
}
.ff-mixin_style();
.ff-mixin(@iname + 1);
}
.ff-mixin();
// .ff(av, bd);
// or if shorts dont set
// .ff(1, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment