-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfont.min.js
More file actions
1 lines (1 loc) · 1.37 KB
/
font.min.js
File metadata and controls
1 lines (1 loc) · 1.37 KB
1
function Font(t){return(new font).setName(t)}var font=function(){this.name=null,this.url=null,this.style="normal",this.size="14px",this.weight="normal",this.variant="normal",this.stretch="normal",this.setName=function(t){return this.name=t,this},this.setURL=function(t){return this.url=t,this},this.setStyle=function(t){return this.style=t,this},this.setSize=function(t){return this.size=t,this},this.setWeight=function(t){return this.weight=t,this},this.setVariant=function(t){return this.variant=t,this},this.setStrech=function(t){return this.strech=t,this},this.load=function(t){if(document.getElementById("fontjs-"+this.name))document.getElementById("fontjs-"+this.name).innerHTML="@font-face {font-family:"+this.name+"; src:url("+this.url+");font-style:"+this.style+"font-weight:"+this.weight+"font-stretch:"+this.stretch+"}";else{var e=document.getElementsByTagName("head").item(0),s=document.createElement("style");s.setAttribute("type","text/css"),s.setAttribute("id","fontjs-"+this.name);var i="@font-face {font-family:"+this.name+"; src:url("+this.url+");font-style:"+this.style+"font-weight:"+this.weight+"font-stretch:"+this.stretch+"}";s.styleSheet?s.styleSheet.cssText=i:(s.appendChild(document.createTextNode(i)),e.appendChild(s))}for(var n=document.querySelectorAll(t),h=n.length-1;h>=0;h--)n[h].setAttribute("style","font-family:"+this.name+";font-size:"+this.size+";");return this}};