From 57655760824041c8ade83b07e5a3989ff7c454eb Mon Sep 17 00:00:00 2001 From: Ruslan Abdullaev Date: Wed, 6 Jun 2018 11:57:56 +0300 Subject: [PATCH] [2.2.1] update google fonts lists --- CHANGELOG.md | 5 + package.json | 4 +- test/index.js | 347 ++++++++++++++++++++++++++++++++++++++++++++++++++ test/test.js | 339 ------------------------------------------------ yarn.lock | 6 +- 5 files changed, 357 insertions(+), 344 deletions(-) create mode 100644 test/index.js delete mode 100644 test/test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index fb919d4..ab7260b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.2.1 (2018-06-06) + +Updated: google-fonts-complete dependency + + ## 2.2.0 (2018-06-05) Fixed: issue with array options diff --git a/package.json b/package.json index abaf1ff..350b39d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-font-magician", - "version": "2.2.0", + "version": "2.2.1", "description": "PostCSS plugin that magically generates all the @font-face rules", "author": "Jonathan Neal ", "contributors": [ @@ -30,7 +30,7 @@ "dependencies": { "bootstrap-fonts-complete": "^1.0.0", "directory-fonts-complete": "^1.2.0", - "google-fonts-complete": "^1.2.1", + "google-fonts-complete": "^1.2.2", "postcss": "^6.0.22" }, "devDependencies": { diff --git a/test/index.js b/test/index.js new file mode 100644 index 0000000..faac492 --- /dev/null +++ b/test/index.js @@ -0,0 +1,347 @@ +/* global describe, it */ +var postcss = require('postcss'); +var expect = require('chai').expect; + +var plugin = require('../'); + +var test = function(input, output, opts, done) { + postcss([plugin(opts)]) + .process(input) + .then(function(result) { + result.root.walkAtRules('font-face', function(rule) { + rule.walkDecls(function(decl) { + expect(typeof decl.value).to.eql('string'); + }); + }); + + expect(result.css).to.eql(output); + + expect(result.warnings()).to.be.empty; + + done(); + }) + .catch(function(error) { + done(error); + }); +}; + +describe('postcss-font-magician', function() { + it('supports bootstrap fonts', function(done) { + test( + 'a{font-family:monospace}b{}', + + '@font-face{font-family:monospace;font-style:italic;font-weight:400;src:local("Menlo Italic"),local(Menlo-Italic),local("Consolas Italic"),local(Consolas-Italic),local("Courier New Italic")}' + + '@font-face{font-family:monospace;font-style:italic;font-weight:700;src:local("Menlo Bold Italic"),local(Menlo-BoldItalic),local(Monaco),local("Consolas Bold Italic"),local(Consolas-BoldItalic),local("Courier New Bold Italic")}' + + '@font-face{font-family:monospace;font-style:normal;font-weight:400;src:local("Menlo Regular"),local(Menlo-Regular),local(Monaco),local(Consolas),local("Courier New")}' + + '@font-face{font-family:monospace;font-style:normal;font-weight:700;src:local("Menlo Bold"),local(Menlo-Bold),local(Monaco),local("Consolas Bold"),local(Consolas-Bold),local("Courier New Bold")}' + + 'a{font-family:monospace}b{}', + + {}, + done + ); + }); + + it('adds bootstrap fonts once', function(done) { + test( + 'a{font-family:monospace}b{font-family:monospace}', + + '@font-face{font-family:monospace;font-style:italic;font-weight:400;src:local("Menlo Italic"),local(Menlo-Italic),local("Consolas Italic"),local(Consolas-Italic),local("Courier New Italic")}' + + '@font-face{font-family:monospace;font-style:italic;font-weight:700;src:local("Menlo Bold Italic"),local(Menlo-BoldItalic),local(Monaco),local("Consolas Bold Italic"),local(Consolas-BoldItalic),local("Courier New Bold Italic")}' + + '@font-face{font-family:monospace;font-style:normal;font-weight:400;src:local("Menlo Regular"),local(Menlo-Regular),local(Monaco),local(Consolas),local("Courier New")}' + + '@font-face{font-family:monospace;font-style:normal;font-weight:700;src:local("Menlo Bold"),local(Menlo-Bold),local(Monaco),local("Consolas Bold"),local(Consolas-Bold),local("Courier New Bold")}' + + 'a{font-family:monospace}b{font-family:monospace}', + + {}, + done + ); + }); + + it('supports google fonts', function(done) { + test( + 'a{font-family:"Alice"}b{}', + + '@font-face{font-family:Alice;font-style:normal;font-weight:400;src:local("Alice Regular"),local(Alice-Regular),url(//fonts.gstatic.com/s/alice/v9/OpNCnoEEmtHa6GcOrgo.eot?#) format("eot"),url(//fonts.gstatic.com/s/alice/v9/OpNCnoEEmtHa6GcOrg4.woff2) format("woff2"),url(//fonts.gstatic.com/s/alice/v9/OpNCnoEEmtHa6GcOrgg.woff) format("woff")}a{font-family:"Alice"}b{}', + {}, + done + ); + }); + + it('supports font-display option', function(done) { + test( + 'a{font-family:"Alice"}b{}', + + '@font-face{font-family:Alice;font-style:normal;font-weight:400;src:local("Alice Regular"),local(Alice-Regular),url(//fonts.gstatic.com/s/alice/v9/OpNCnoEEmtHa6GcOrgo.eot?#) format("eot"),url(//fonts.gstatic.com/s/alice/v9/OpNCnoEEmtHa6GcOrg4.woff2) format("woff2"),url(//fonts.gstatic.com/s/alice/v9/OpNCnoEEmtHa6GcOrgg.woff) format("woff");font-display:swap}a{font-family:"Alice"}b{}', + { display: 'swap' }, + done + ); + }); + + describe('Custom google fonts options:', function() { + it('supports custom google fonts', function(done) { + test( + 'a{font-family:"Open Sans"}b{}', + + '@font-face{font-family:"Open Sans";font-style:normal;font-weight:300;src:url(//fonts.gstatic.com/s/opensans/v15/mem5YaGs126MiZpBA-UN_r8OUuhv.woff) format("woff")}@font-face{font-family:"Open Sans";font-style:italic;font-weight:400;src:url(//fonts.gstatic.com/s/opensans/v15/mem6YaGs126MiZpBA-UFUK0Zdck.eot?#) format("eot"),url(//fonts.gstatic.com/s/opensans/v15/mem6YaGs126MiZpBA-UFUK0Zdcs.woff) format("woff")}a{font-family:"Open Sans"}b{}', + { + variants: { + 'Open Sans': { + '300': ['woff'], + '400 italic': ['eot woff'] + } + } + }, + done + ); + }); + + it('supports custom google fonts (default formats)', function(done) { + test( + 'a{font-family:"Open Sans"}b{}', + + '@font-face{font-family:"Open Sans";font-style:normal;font-weight:300;src:local("Open Sans Light"),local(OpenSans-Light),url(//fonts.gstatic.com/s/opensans/v15/mem5YaGs126MiZpBA-UN_r8OUuht.eot?#) format("eot"),url(//fonts.gstatic.com/s/opensans/v15/mem5YaGs126MiZpBA-UN_r8OUuhp.woff2) format("woff2"),url(//fonts.gstatic.com/s/opensans/v15/mem5YaGs126MiZpBA-UN_r8OUuhv.woff) format("woff")}a{font-family:"Open Sans"}b{}', + + { + variants: { + 'Open Sans': { + '300': [] + } + } + }, + done + ); + }); + + it('supports custom unicode-range', function(done) { + test( + 'a{font-family:"Open Sans"}b{}', + + '@font-face{font-family:"Open Sans";font-style:normal;font-weight:300;src:url(//fonts.gstatic.com/s/opensans/v15/mem5YaGs126MiZpBA-UN_r8OUuhv.woff) format("woff");unicode-range:U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF}@font-face{font-family:"Open Sans";font-style:italic;font-weight:400;src:url(//fonts.gstatic.com/s/opensans/v15/mem6YaGs126MiZpBA-UFUK0Zdck.eot?#) format("eot"),url(//fonts.gstatic.com/s/opensans/v15/mem6YaGs126MiZpBA-UFUK0Zdcs.woff) format("woff")}a{font-family:"Open Sans"}b{}', + { + variants: { + 'Open Sans': { + '300': [ + 'woff', + 'U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF' + ], + '400 italic': ['eot woff'] + } + } + }, + done + ); + }); + + it('supports custom font-stretch: omit "normal" style', function(done) { + test( + 'a{font-family:"Open Sans"}b{}', + + '@font-face{font-family:"Open Sans";font-style:normal;font-weight:300;src:url(//fonts.gstatic.com/s/opensans/v15/mem5YaGs126MiZpBA-UN_r8OUuhv.woff) format("woff");font-stretch:condensed}@font-face{font-family:"Open Sans";font-style:italic;font-weight:400;src:url(//fonts.gstatic.com/s/opensans/v15/mem6YaGs126MiZpBA-UFUK0Zdck.eot?#) format("eot"),url(//fonts.gstatic.com/s/opensans/v15/mem6YaGs126MiZpBA-UFUK0Zdcs.woff) format("woff")}a{font-family:"Open Sans"}b{}', + { + variants: { + 'Open Sans': { + '300 condensed': ['woff'], + '400 italic': ['eot woff'] + } + } + }, + done + ); + }); + + it('supports custom font-stretch: with "normal" style', function(done) { + test( + 'a{font-family:"Open Sans"}b{}', + + '@font-face{font-family:"Open Sans";font-style:normal;font-weight:300;src:url(//fonts.gstatic.com/s/opensans/v15/mem5YaGs126MiZpBA-UN_r8OUuhv.woff) format("woff");font-stretch:condensed}@font-face{font-family:"Open Sans";font-style:italic;font-weight:400;src:url(//fonts.gstatic.com/s/opensans/v15/mem6YaGs126MiZpBA-UFUK0Zdck.eot?#) format("eot"),url(//fonts.gstatic.com/s/opensans/v15/mem6YaGs126MiZpBA-UFUK0Zdcs.woff) format("woff")}a{font-family:"Open Sans"}b{}', + { + variants: { + 'Open Sans': { + '300 normal condensed': ['woff'], + '400 italic': ['eot woff'] + } + } + }, + done + ); + }); + + it('supports custom font-stretch: with "italic" style', function(done) { + test( + 'a{font-family:"Open Sans"}b{}', + + '@font-face{font-family:"Open Sans";font-style:normal;font-weight:300;src:url(//fonts.gstatic.com/s/opensans/v15/mem5YaGs126MiZpBA-UN_r8OUuhv.woff) format("woff")}@font-face{font-family:"Open Sans";font-style:italic;font-weight:400;src:url(//fonts.gstatic.com/s/opensans/v15/mem6YaGs126MiZpBA-UFUK0Zdck.eot?#) format("eot"),url(//fonts.gstatic.com/s/opensans/v15/mem6YaGs126MiZpBA-UFUK0Zdcs.woff) format("woff");font-stretch:ultra-condensed}a{font-family:"Open Sans"}b{}', + { + variants: { + 'Open Sans': { + '300': ['woff'], + '400 italic ultra-condensed': ['eot woff'] + } + } + }, + done + ); + }); + }); + + it('adds google fonts once', function(done) { + test( + 'a{font-family:"Alice"}b{font-family:"Alice"}', + + '@font-face{font-family:Alice;font-style:normal;font-weight:400;src:local("Alice Regular"),local(Alice-Regular),url(//fonts.gstatic.com/s/alice/v9/OpNCnoEEmtHa6GcOrgo.eot?#) format("eot"),url(//fonts.gstatic.com/s/alice/v9/OpNCnoEEmtHa6GcOrg4.woff2) format("woff2"),url(//fonts.gstatic.com/s/alice/v9/OpNCnoEEmtHa6GcOrgg.woff) format("woff")}a{font-family:"Alice"}b{font-family:"Alice"}', + + {}, + done + ); + }); + + it('supports hosted fonts', function(done) { + test( + 'a{font-family:"Source Sans Pro"}b{}', + + '@font-face{font-family:"Source Sans Pro";font-style:normal;font-weight:400;src:local(SourceSansPro-Regular),local(SourceSansPro-Regular),url(./test/fonts/pathFont.woff) format("woff")}' + + 'a{font-family:"Source Sans Pro"}b{}', + + { + hosted: ['./test/fonts'] + }, + done + ); + }); + + it('supports hosted fonts (string fallback)', function(done) { + test( + 'a{font-family:"Source Sans Pro"}b{}', + + '@font-face{font-family:"Source Sans Pro";font-style:normal;font-weight:400;src:local(SourceSansPro-Regular),local(SourceSansPro-Regular),url(./test/fonts/pathFont.woff) format("woff")}' + + 'a{font-family:"Source Sans Pro"}b{}', + + { + hosted: './test/fonts' + }, + done + ); + }); + + it('supports hosted fonts with custom font path', function(done) { + test( + 'a{font-family:"Source Sans Pro"}b{}', + + '@font-face{font-family:"Source Sans Pro";font-style:normal;font-weight:400;src:local(SourceSansPro-Regular),local(SourceSansPro-Regular),url(/some/custom/path/pathFont.woff) format("woff")}' + + 'a{font-family:"Source Sans Pro"}b{}', + + { + hosted: ['./test/fonts', '/some/custom/path'] + }, + done + ); + }); + + it('does not overwrite existing @font-face rules', function(done) { + test( + '@font-face{font-family:Alice}a{font-family:"Alice"}b{}', + + '@font-face{font-family:Alice}a{font-family:"Alice"}b{}', + + {}, + done + ); + }); + + it('support foundry exclusion', function(done) { + test( + 'a{font-family:"Alice"}b{}', + + 'a{font-family:"Alice"}b{}', + + { + foundries: 'hosted' + }, + done + ); + }); + + it('support font aliasing', function(done) { + test( + 'a{font-family:body}b{}', + + '@font-face{font-family:body;font-style:normal;font-weight:400;src:url(//fonts.gstatic.com/s/opensans/v15/mem8YaGs126MiZpBA-UFVZ0d.woff) format("woff")}a{font-family:body}b{}', + + { + aliases: { + body: 'Open Sans' + }, + variants: { + body: { + '400': ['woff'] + } + } + }, + done + ); + }); + + it('support custom fonts', function(done) { + test( + 'a{font-family:body}b{}', + + '@font-face{font-family:body;font-style:normal;font-weight:400;src:url(path/to/my-body-font.woff2) format("woff2")}' + + 'a{font-family:body}b{}', + + { + custom: { + body: { + variants: { + normal: { + 400: { + url: { + woff2: 'path/to/my-body-font.woff2' + } + } + } + } + } + } + }, + done + ); + }); + + it('support async font loading', function(done) { + test( + 'a{font-family:Alice}b{}', + + 'a{font-family:Alice}b{}', + + { + async: './test/fontface.js.result' + }, + done + ); + }); + + it('supports custom configuration protocol (http)', function(done) { + test( + 'a{font-family:"Alice"}b{}', + + '@font-face{font-family:Alice;font-style:normal;font-weight:400;src:local("Alice Regular"),local(Alice-Regular),url(http://fonts.gstatic.com/s/alice/v9/OpNCnoEEmtHa6GcOrgo.eot?#) format("eot"),url(http://fonts.gstatic.com/s/alice/v9/OpNCnoEEmtHa6GcOrg4.woff2) format("woff2"),url(http://fonts.gstatic.com/s/alice/v9/OpNCnoEEmtHa6GcOrgg.woff) format("woff")}a{font-family:"Alice"}b{}', + + { + protocol: 'http:' + }, + done + ); + }); + + it('supports custom configuration protocol (https)', function(done) { + test( + 'a{font-family:"Alice"}b{}', + + '@font-face{font-family:Alice;font-style:normal;font-weight:400;src:local("Alice Regular"),local(Alice-Regular),url(https://fonts.gstatic.com/s/alice/v9/OpNCnoEEmtHa6GcOrgo.eot?#) format("eot"),url(https://fonts.gstatic.com/s/alice/v9/OpNCnoEEmtHa6GcOrg4.woff2) format("woff2"),url(https://fonts.gstatic.com/s/alice/v9/OpNCnoEEmtHa6GcOrgg.woff) format("woff")}a{font-family:"Alice"}b{}', + + { + protocol: 'https:' + }, + done + ); + }); +}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1153303..0000000 --- a/test/test.js +++ /dev/null @@ -1,339 +0,0 @@ -var postcss = require('postcss'); -var expect = require('chai').expect; - -var plugin = require('../'); - -var test = function (input, output, opts, done) { - postcss([plugin(opts)]).process(input).then(function (result) { - result.root.walkAtRules('font-face', function (rule) { - rule.walkDecls(function (decl) { - expect(typeof decl.value).to.eql('string'); - }); - }); - - expect(result.css).to.eql(output); - - expect(result.warnings()).to.be.empty; - - done(); - }).catch(function (error) { - done(error); - }); -}; - -describe('postcss-font-magician', function () { - it('supports bootstrap fonts', function (done) { - test( - 'a{font-family:monospace}b{}', - - '@font-face{font-family:monospace;font-style:italic;font-weight:400;src:local("Menlo Italic"),local(Menlo-Italic),local("Consolas Italic"),local(Consolas-Italic),local("Courier New Italic")}' + - '@font-face{font-family:monospace;font-style:italic;font-weight:700;src:local("Menlo Bold Italic"),local(Menlo-BoldItalic),local(Monaco),local("Consolas Bold Italic"),local(Consolas-BoldItalic),local("Courier New Bold Italic")}' + - '@font-face{font-family:monospace;font-style:normal;font-weight:400;src:local("Menlo Regular"),local(Menlo-Regular),local(Monaco),local(Consolas),local("Courier New")}' + - '@font-face{font-family:monospace;font-style:normal;font-weight:700;src:local("Menlo Bold"),local(Menlo-Bold),local(Monaco),local("Consolas Bold"),local(Consolas-Bold),local("Courier New Bold")}' + - 'a{font-family:monospace}b{}', - - {}, - done - ); - }); - - it('adds bootstrap fonts once', function (done) { - test( - 'a{font-family:monospace}b{font-family:monospace}', - - '@font-face{font-family:monospace;font-style:italic;font-weight:400;src:local("Menlo Italic"),local(Menlo-Italic),local("Consolas Italic"),local(Consolas-Italic),local("Courier New Italic")}' + - '@font-face{font-family:monospace;font-style:italic;font-weight:700;src:local("Menlo Bold Italic"),local(Menlo-BoldItalic),local(Monaco),local("Consolas Bold Italic"),local(Consolas-BoldItalic),local("Courier New Bold Italic")}' + - '@font-face{font-family:monospace;font-style:normal;font-weight:400;src:local("Menlo Regular"),local(Menlo-Regular),local(Monaco),local(Consolas),local("Courier New")}' + - '@font-face{font-family:monospace;font-style:normal;font-weight:700;src:local("Menlo Bold"),local(Menlo-Bold),local(Monaco),local("Consolas Bold"),local(Consolas-Bold),local("Courier New Bold")}' + - 'a{font-family:monospace}b{font-family:monospace}', - - {}, - done - ); - }); - - it('supports google fonts', function (done) { - test('a{font-family:"Alice"}b{}', - - '@font-face{font-family:Alice;font-style:normal;font-weight:400;src:local("Alice Regular"),local(Alice-Regular),url(//fonts.gstatic.com/s/alice/v9/sZyKh5NKrCk1xkCk_F1S8A.eot?#) format("eot"),url(//fonts.gstatic.com/s/alice/v9/l5RFQT5MQiajQkFxjDLySg.woff2) format("woff2"),url(//fonts.gstatic.com/s/alice/v9/_H4kMcdhHr0B8RDaQcqpTA.woff) format("woff")}' + - 'a{font-family:"Alice"}b{}', - {}, done); - }); - - it('supports font-display option', function (done) { - test('a{font-family:"Alice"}b{}', - - '@font-face{font-family:Alice;font-style:normal;font-weight:400;src:local("Alice Regular"),local(Alice-Regular),url(//fonts.gstatic.com/s/alice/v9/sZyKh5NKrCk1xkCk_F1S8A.eot?#) format("eot"),url(//fonts.gstatic.com/s/alice/v9/l5RFQT5MQiajQkFxjDLySg.woff2) format("woff2"),url(//fonts.gstatic.com/s/alice/v9/_H4kMcdhHr0B8RDaQcqpTA.woff) format("woff");font-display:swap}' + - 'a{font-family:"Alice"}b{}', { display: 'swap' }, done); - }); - - describe('Custom google fonts options:', function () { - it('supports custom google fonts', function (done) { - test( - 'a{font-family:"Open Sans"}b{}', - - '@font-face{font-family:"Open Sans";font-style:normal;font-weight:300;src:url(//fonts.gstatic.com/s/opensans/v15/DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff) format("woff")}@font-face{font-family:"Open Sans";font-style:italic;font-weight:400;src:url(//fonts.gstatic.com/s/opensans/v15/xjAJXh38I15wypJXxuGMBmfQcKutQXcIrRfyR5jdjY8.eot?#) format("eot"),url(//fonts.gstatic.com/s/opensans/v15/xjAJXh38I15wypJXxuGMBobN6UDyHWBl620a-IRfuBk.woff) format("woff")}a{font-family:"Open Sans"}b{}', - { - variants: { - 'Open Sans': { - '300': ['woff'], - '400 italic': ['eot woff'] - } - } - }, - done - ); - }); - - it('supports custom google fonts (default formats)', function (done) { - test( - 'a{font-family:"Open Sans"}b{}', - - '@font-face{font-family:"Open Sans";font-style:normal;font-weight:300;src:local("Open Sans Light"),local(OpenSans-Light),url(//fonts.gstatic.com/s/opensans/v15/DXI1ORHCpsQm3Vp6mXoaTXZ2MAKAc2x4R1uOSeegc5U.eot?#) format("eot"),url(//fonts.gstatic.com/s/opensans/v15/DXI1ORHCpsQm3Vp6mXoaTegdm0LZdjqr5-oayXSOefg.woff2) format("woff2"),url(//fonts.gstatic.com/s/opensans/v15/DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff) format("woff")}a{font-family:"Open Sans"}b{}', - - { - variants: { - 'Open Sans': { - '300': [] - } - } - }, - done - ); - }); - - it('supports custom unicode-range', function (done) { - test( - 'a{font-family:"Open Sans"}b{}', - - '@font-face{font-family:"Open Sans";font-style:normal;font-weight:300;src:url(//fonts.gstatic.com/s/opensans/v15/DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff) format("woff");unicode-range:U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF}@font-face{font-family:"Open Sans";font-style:italic;font-weight:400;src:url(//fonts.gstatic.com/s/opensans/v15/xjAJXh38I15wypJXxuGMBmfQcKutQXcIrRfyR5jdjY8.eot?#) format("eot"),url(//fonts.gstatic.com/s/opensans/v15/xjAJXh38I15wypJXxuGMBobN6UDyHWBl620a-IRfuBk.woff) format("woff")}a{font-family:"Open Sans"}b{}', - { - variants: { - 'Open Sans': { - '300': ['woff', 'U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF'], - '400 italic': ['eot woff'] - } - } - }, - done - ); - }); - - it('supports custom font-stretch: omit "normal" style', function (done) { - test( - 'a{font-family:"Open Sans"}b{}', - - '@font-face{font-family:"Open Sans";font-style:normal;font-weight:300;src:url(//fonts.gstatic.com/s/opensans/v15/DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff) format("woff");font-stretch:condensed}@font-face{font-family:"Open Sans";font-style:italic;font-weight:400;src:url(//fonts.gstatic.com/s/opensans/v15/xjAJXh38I15wypJXxuGMBmfQcKutQXcIrRfyR5jdjY8.eot?#) format("eot"),url(//fonts.gstatic.com/s/opensans/v15/xjAJXh38I15wypJXxuGMBobN6UDyHWBl620a-IRfuBk.woff) format("woff")}a{font-family:"Open Sans"}b{}', - { - variants: { - 'Open Sans': { - '300 condensed': ['woff'], - '400 italic': ['eot woff'] - } - } - }, - done - ); - }); - - it('supports custom font-stretch: with "normal" style', function (done) { - test( - 'a{font-family:"Open Sans"}b{}', - - '@font-face{font-family:"Open Sans";font-style:normal;font-weight:300;src:url(//fonts.gstatic.com/s/opensans/v15/DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff) format("woff");font-stretch:condensed}@font-face{font-family:"Open Sans";font-style:italic;font-weight:400;src:url(//fonts.gstatic.com/s/opensans/v15/xjAJXh38I15wypJXxuGMBmfQcKutQXcIrRfyR5jdjY8.eot?#) format("eot"),url(//fonts.gstatic.com/s/opensans/v15/xjAJXh38I15wypJXxuGMBobN6UDyHWBl620a-IRfuBk.woff) format("woff")}a{font-family:"Open Sans"}b{}', - { - variants: { - 'Open Sans': { - '300 normal condensed': ['woff'], - '400 italic': ['eot woff'] - } - } - }, - done - ); - }); - - it('supports custom font-stretch: with "italic" style', function (done) { - test( - 'a{font-family:"Open Sans"}b{}', - - '@font-face{font-family:"Open Sans";font-style:normal;font-weight:300;src:url(//fonts.gstatic.com/s/opensans/v15/DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff) format("woff")}@font-face{font-family:"Open Sans";font-style:italic;font-weight:400;src:url(//fonts.gstatic.com/s/opensans/v15/xjAJXh38I15wypJXxuGMBmfQcKutQXcIrRfyR5jdjY8.eot?#) format("eot"),url(//fonts.gstatic.com/s/opensans/v15/xjAJXh38I15wypJXxuGMBobN6UDyHWBl620a-IRfuBk.woff) format("woff");font-stretch:ultra-condensed}a{font-family:"Open Sans"}b{}', - { - variants: { - 'Open Sans': { - '300': ['woff'], - '400 italic ultra-condensed': ['eot woff'] - } - } - }, - done - ); - }); - }); - - it('adds google fonts once', function (done) { - test( - 'a{font-family:"Alice"}b{font-family:"Alice"}', - - '@font-face{font-family:Alice;font-style:normal;font-weight:400;src:local("Alice Regular"),local(Alice-Regular),url(//fonts.gstatic.com/s/alice/v9/sZyKh5NKrCk1xkCk_F1S8A.eot?#) format("eot"),url(//fonts.gstatic.com/s/alice/v9/l5RFQT5MQiajQkFxjDLySg.woff2) format("woff2"),url(//fonts.gstatic.com/s/alice/v9/_H4kMcdhHr0B8RDaQcqpTA.woff) format("woff")}' + - 'a{font-family:"Alice"}b{font-family:"Alice"}', - - {}, - done - ); - }); - - it('supports hosted fonts', function (done) { - test( - 'a{font-family:"Source Sans Pro"}b{}', - - '@font-face{font-family:"Source Sans Pro";font-style:normal;font-weight:400;src:local(SourceSansPro-Regular),local(SourceSansPro-Regular),url(./test/fonts/pathFont.woff) format("woff")}' + - 'a{font-family:"Source Sans Pro"}b{}', - - { - hosted: ['./test/fonts'] - }, - done - ); - }); - - it('supports hosted fonts (string fallback)', function (done) { - test( - 'a{font-family:"Source Sans Pro"}b{}', - - '@font-face{font-family:"Source Sans Pro";font-style:normal;font-weight:400;src:local(SourceSansPro-Regular),local(SourceSansPro-Regular),url(./test/fonts/pathFont.woff) format("woff")}' + - 'a{font-family:"Source Sans Pro"}b{}', - - { - hosted: './test/fonts' - }, - done - ); - }); - - it('supports hosted fonts with custom font path', function (done) { - test( - 'a{font-family:"Source Sans Pro"}b{}', - - '@font-face{font-family:"Source Sans Pro";font-style:normal;font-weight:400;src:local(SourceSansPro-Regular),local(SourceSansPro-Regular),url(/some/custom/path/pathFont.woff) format("woff")}' + - 'a{font-family:"Source Sans Pro"}b{}', - - { - hosted: ['./test/fonts', '/some/custom/path'] - }, - done - ); - }); - - it('does not overwrite existing @font-face rules', function (done) { - test( - '@font-face{font-family:Alice}a{font-family:"Alice"}b{}', - - '@font-face{font-family:Alice}a{font-family:"Alice"}b{}', - - {}, - done - ); - }); - - it('support foundry exclusion', function (done) { - test( - 'a{font-family:"Alice"}b{}', - - 'a{font-family:"Alice"}b{}', - - { - foundries: 'hosted' - }, - done - ); - }); - - it('support font aliasing', function (done) { - test( - 'a{font-family:body}b{}', - - '@font-face{font-family:body;font-style:normal;font-weight:400;src:url(//fonts.gstatic.com/s/opensans/v15/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff) format("woff")}a{font-family:body}b{}', - - { - aliases: { - body: 'Open Sans' - }, - variants: { - 'body': { - '400': ['woff'] - } - } - }, - done - ); - }); - - it('support custom fonts', function (done) { - test( - 'a{font-family:body}b{}', - - '@font-face{font-family:body;font-style:normal;font-weight:400;src:url(path/to/my-body-font.woff2) format("woff2")}' + - 'a{font-family:body}b{}', - - { - custom: { - body: { - variants: { - normal: { - 400: { - url: { - woff2: 'path/to/my-body-font.woff2' - } - } - } - } - } - } - }, - done - ); - }); - - it('support async font loading', function (done) { - test( - 'a{font-family:Alice}b{}', - - 'a{font-family:Alice}b{}', - - { - async: './test/fontface.js.result' - }, - done - ); - }); - - it('supports custom configuration protocol (http)', function (done) { - test( - 'a{font-family:"Alice"}b{}', - - '@font-face{font-family:Alice;font-style:normal;font-weight:400;src:local("Alice Regular"),local(Alice-Regular),url(http://fonts.gstatic.com/s/alice/v9/sZyKh5NKrCk1xkCk_F1S8A.eot?#) format("eot"),url(http://fonts.gstatic.com/s/alice/v9/l5RFQT5MQiajQkFxjDLySg.woff2) format("woff2"),url(http://fonts.gstatic.com/s/alice/v9/_H4kMcdhHr0B8RDaQcqpTA.woff) format("woff")}' + - 'a{font-family:"Alice"}b{}', - - { - protocol: 'http:' - }, - done - ); - }); - - it('supports custom configuration protocol (https)', function (done) { - test( - 'a{font-family:"Alice"}b{}', - - '@font-face{font-family:Alice;font-style:normal;font-weight:400;src:local("Alice Regular"),local(Alice-Regular),url(https://fonts.gstatic.com/s/alice/v9/sZyKh5NKrCk1xkCk_F1S8A.eot?#) format("eot"),url(https://fonts.gstatic.com/s/alice/v9/l5RFQT5MQiajQkFxjDLySg.woff2) format("woff2"),url(https://fonts.gstatic.com/s/alice/v9/_H4kMcdhHr0B8RDaQcqpTA.woff) format("woff")}' + - 'a{font-family:"Alice"}b{}', - - { - protocol: 'https:' - }, - done - ); - }); - -}); diff --git a/yarn.lock b/yarn.lock index 707bbc7..76415eb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -756,9 +756,9 @@ globby@^5.0.0: pify "^2.0.0" pinkie-promise "^2.0.0" -google-fonts-complete@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/google-fonts-complete/-/google-fonts-complete-1.2.1.tgz#0be144d963f1af51de96ec0a34a814e6461b8bea" +google-fonts-complete@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/google-fonts-complete/-/google-fonts-complete-1.2.2.tgz#3ad95d4022a2f278acc41d4539b33a2899e8f76c" dependencies: postcss "^4.1.16"