Skip to content

Commit

Permalink
Fix font loading for safari
Browse files Browse the repository at this point in the history
  • Loading branch information
neoformit committed Dec 10, 2024
1 parent 46d6d39 commit b3eafa8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
20 changes: 20 additions & 0 deletions app/labs/static/labs/js/load-fonts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Load material icons and display when page has loaded
if ('fonts' in document) {
document.fonts.ready.then(() => {
$('.material-icons').css({
'opacity': 1,
'max-width': 'unset',
'overflow': 'visible'
});
}).catch((error) => {
console.error('Font loading failed:', error);
});
} else {
// Fallback for browsers that don't support document.fonts
console.warn('Font API not supported in this browser.');
$('.material-icons').css({
'opacity': 1,
'max-width': 'unset',
'overflow': 'visible'
});
}
11 changes: 1 addition & 10 deletions app/labs/templates/labs/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,8 @@
{% block script %}
{% endblock %}

<script src="{% static 'labs/js/load-fonts.js' %}"></script>
<script type="text/javascript">

// Load material icons and display when page has loaded
document.fonts.onloadingdone = () => {
$('.material-icons').css({
'opacity': 1,
'max-width': 'unset',
'overflow': 'visible'
});
}

$(document).ready( () => {
// Enable bootstrap tooltips
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
Expand Down

0 comments on commit b3eafa8

Please sign in to comment.