Skip to content

Commit

Permalink
atlast.html line height, drop URL.canParse
Browse files Browse the repository at this point in the history
URL.canParse is not well supported in many browsers so try-catch instead
  • Loading branch information
sqwishy committed Nov 4, 2023
1 parent bf42013 commit 4bb77e1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions atlast.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
html
{ background: var(--pale);
color: #fbf1f7;
font: 18px 'Tex Gyre Adventor', corbel, sans-serif }
font: 18px/1.25 'Tex Gyre Adventor', corbel, sans-serif }

body
{ min-height: 100%;
Expand Down Expand Up @@ -239,8 +239,13 @@ <h1>About</h1>

function loadExternalFont({ setExternalFont, setExternalFontStatus }) {
let { value } = document.querySelector("#externalFontUrl")
if (URL.canParse(value))
value = `url(${value})`

/* the external font value should be `url({url})`,
* if we just got a url then surround it in "url()" */
try {
if (new URL(value))
value = `url(${value})`
} catch (_) { }

const [oldFont, newFont] = setExternalFont(value ? new FontFace("External", value) : null);

Expand Down

0 comments on commit 4bb77e1

Please sign in to comment.