Skip to content

Commit

Permalink
Changed to use self hosted fonts. Fixes issues for international uses…
Browse files Browse the repository at this point in the history
… accessing the site when google has been blocked.
  • Loading branch information
wdamien committed Jul 29, 2016
1 parent f1818dd commit 88ab1dc
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 40 deletions.
Binary file added fonts/cabin-v8-latin-700.woff
Binary file not shown.
Binary file added fonts/cabin-v8-latin-700.woff2
Binary file not shown.
Binary file added fonts/cabin-v8-latin-regular.woff
Binary file not shown.
Binary file added fonts/cabin-v8-latin-regular.woff2
Binary file not shown.
Binary file added fonts/source-code-pro-v6-latin-700.woff
Binary file not shown.
Binary file added fonts/source-code-pro-v6-latin-700.woff2
Binary file not shown.
Binary file added fonts/source-code-pro-v6-latin-regular.woff
Binary file not shown.
Binary file added fonts/source-code-pro-v6-latin-regular.woff2
Binary file not shown.
1 change: 1 addition & 0 deletions gulpfile.js
Expand Up @@ -22,6 +22,7 @@ var staticAssets = [
"./assets/**",
"./php/!(cache)**",
"*.ico",
"fonts/**",
".htaccess"
];

Expand Down
1 change: 0 additions & 1 deletion index.html
Expand Up @@ -52,7 +52,6 @@
<script src="js/regExWorker.template.js?no=<%=noCache %>"></script>

<link rel="stylesheet" href="css/regexr.css?no=<%=noCache %>">
<script src="//ajax.googleapis.com/ajax/libs/webfont/1/webfont.js"></script>
</head>
<body>

Expand Down
40 changes: 1 addition & 39 deletions js/index.template.js
Expand Up @@ -187,42 +187,4 @@ function createRegExr() {
}
}

if (window["WebFont"] != null) {
try {
WebFont.load({
google: {
families: ["Source Code Pro:400,700", "Cabin:400,700"],
fontinactive: function (family, fvd) {
WebFont.load({
custom: {
families: ["Source Code Pro:400,700", "Cabin:400,700"]
}
});
}
},
active: function () {
xhr.abort();
createRegExr();
}
});

// wdg:: Fix for https://github.com/gskinner/regexr/issues/111
// If the cors header is non-existent WebFont will silently fail, so we manually check to see if font can be loaded.
// and if not, just show the site.
var xhr = window.XDomainRequest == null?new XMLHttpRequest():new XDomainRequest();
xhr.onerror = function(evt) {
createRegExr();
};
xhr.open('get', 'http://fonts.gstatic.com/s/sourcecodepro/v6/leqv3v-yTsJNC7nFznSMqZkF8H8ye47wsfpWywda8og.woff2');
xhr.send();

// final fall back, if all other fall backs fail
setTimeout(function() {
createRegExr();
}, 500);
} catch (err) {
createRegExr();
}
} else {
createRegExr();
}
createRegExr();
1 change: 1 addition & 0 deletions js/views/DocView.js
Expand Up @@ -507,6 +507,7 @@ p.sourceMouseMove = function (evt) {
if (rect) {
rect.right = rect.left = evt.clientX;
}

this.sourceTooltip.show(Docs.forMatch(this.hoverMatch), rect);
};

Expand Down
42 changes: 42 additions & 0 deletions scss/fonts.scss
@@ -0,0 +1,42 @@
/****************************************************************************
* File is generated from https://google-webfonts-helper.herokuapp.com/fonts *
*****************************************************************************
*/

/* cabin-regular - latin */
@font-face {
font-family: 'Cabin';
font-style: normal;
font-weight: 400;
src: local('Cabin Regular'), local('Cabin-Regular'),
url('../fonts/cabin-v8-latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('../fonts/cabin-v8-latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* cabin-700 - latin */
@font-face {
font-family: 'Cabin';
font-style: normal;
font-weight: 700;
src: local('Cabin Bold'), local('Cabin-Bold'),
url('../fonts/cabin-v8-latin-700.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('../fonts/cabin-v8-latin-700.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}

/* source-code-pro-regular - latin */
@font-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 400;
src: local('Source Code Pro'), local('SourceCodePro-Regular'),
url('../fonts/source-code-pro-v6-latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('../fonts/source-code-pro-v6-latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* source-code-pro-700 - latin */
@font-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 700;
src: local('Source Code Pro Bold'), local('SourceCodePro-Bold'),
url('../fonts/source-code-pro-v6-latin-700.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('../fonts/source-code-pro-v6-latin-700.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
2 changes: 2 additions & 0 deletions scss/regexr.scss
Expand Up @@ -21,6 +21,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
@import "fonts";

@import "compass";
@import "compass/css3/transform";

Expand Down

0 comments on commit 88ab1dc

Please sign in to comment.