Skip to content

Commit

Permalink
Issue webcompat#2750 - Improves text renderig on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
marimeireles committed Feb 20, 2019
1 parent b5f0638 commit 131deb5
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 1 deletion.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"cssrecipes-grid": "^1.0.0",
"cssrecipes-reset": "^0.5.0",
"cssrecipes-utils": "^0.6.2",
"fontfaceobserver": "^2.1.0",
"handlebars": "^4.1.0",
"suitcss-utils-align": "^1.0.0",
"suitcss-utils-display": "^1.0.2",
"yargs": "^12.0.2"
Expand Down
8 changes: 8 additions & 0 deletions webcompat/static/css/src/typo.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,11 @@ blockquote {
margin-right: 0;
padding-left: 1em;
}

.font-mobile body {
font-family: Verdana, sans-serif !important;
}

.fonts-loaded body {
font-family: "Open Sans", Helvetica, Arial, sans-serif !important;
}
27 changes: 27 additions & 0 deletions webcompat/static/js/lib/fonts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
if (/Mobi/.test(navigator.userAgent)) {
document.documentElement.className += " font-mobile";
var sourceSansPro300 = new FontFaceObserver("Source Sans Pro", {
weight: 300
});

var sourceSansPro400 = new FontFaceObserver("Source Sans Pro", {
weight: 400
});

var openSans400 = new FontFaceObserver("Open Sans", {
weight: 400
});

var openSans600 = new FontFaceObserver("Open Sans", {
weight: 600
});

Promise.all([
sourceSansPro300.load(null, 20000),
sourceSansPro400.load(null, 20000),
openSans400.load(null, 20000),
openSans600.load(null, 20000)
]).then(function() {
document.documentElement.className += " fonts-loaded";
});
}
12 changes: 12 additions & 0 deletions webcompat/static/js/vendor/fontfaceobserver.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion webcompat/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<link rel="mask-icon" href="{{ url_for('static', filename='favicon/safari-pinned-tab.svg') }}" color="#202020">
<link rel="icon" type="image/png" href="{{ url_for('static', filename='favicon/favicon-16x16.png') }}" sizes="16x16">

<link rel="preload" href="https://fonts.googleapis.com/css?family=Open+Sans:400,600|Source+Sans+Pro:300,400|PT+Mono">
<link rel="preload" href="https://fonts.googleapis.com/css?family=Open+Sans:400,600|Source+Sans+Pro:300,400|PT+Mono" as="style">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600|Source+Sans+Pro:300,400|PT+Mono" rel="stylesheet">
<link href="{{ url_for('static', filename='css/dist/webcompat.min.css') }}" type="text/css" rel="stylesheet">
</head>
Expand All @@ -24,6 +24,8 @@
<!-- End Google Analytics -->
<script src="{{ url_for('static', filename='js/dist/webcompat.min.js')|bust_cache }}"></script>
{% else %}
<script src="{{ url_for('static', filename='js/vendor/fontfaceobserver.js') }}"></script>
<script src="{{ url_for('static', filename='js/lib/fonts.js') }}"></script>
<script src="{{ url_for('static', filename='js/vendor/jquery-3.3.1.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/vendor/lodash.custom.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/vendor/backbone-1.3.3.min.js') }}"></script>
Expand Down

0 comments on commit 131deb5

Please sign in to comment.