Skip to content

Commit

Permalink
Fix loadFont() and callback parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
alterebro committed Apr 12, 2024
1 parent 67f93c6 commit 9bfcec3
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions q5.js
Original file line number Diff line number Diff line change
Expand Up @@ -1637,16 +1637,23 @@ function Q5(scope){
// TYPOGRAPHY
//================================================================

$.loadFont = function(url,callback){
$.loadFont = function(url,success,failure){
let sp = url.split("/");
let name = sp[sp.length-1].split(".")[0].replace(" ","");
let cssStr = `@font-face {
font-family: '${name}';
src: url('${url}');
}`;
const style = document.createElement('style');
style.textContent = cssStr;
document.head.append(style);
let f = new FontFace( name , `url('${url}')`);
f.load().then(
function(font){
document.fonts.add(font);
if (success) {
success(name);
}
},
function(err) {
if (failure) {
failure(err)
}
});

return name;
}
$.textFont = function(x){
Expand Down

0 comments on commit 9bfcec3

Please sign in to comment.