Selaa lähdekoodia

Use local fonts (#573)

This updates the way fonts are handled to not have to download the font from the internet.

If you do `./public/font.ttf` in the .scss file, unfortunately the bundle packages them somewhere that's different from the public folder that is used by the index.html to preload them.

The fix I used is to use absolute path `/font.ttf` so that both work. Unfortunately, this means that the website will only work if at the root of the domain. That's the case so far so it's okay but still annoying if we want to embed it somewhere.
Christopher Chedeau 5 vuotta sitten
vanhempi
commit
1d9cdf4d46
3 muutettua tiedostoa jossa 5 lisäystä ja 4 poistoa
  1. 2 2
      public/index.html
  2. 1 0
      src/index-node.ts
  3. 2 2
      src/styles.scss

+ 2 - 2
public/index.html

@@ -50,14 +50,14 @@
     <link rel="icon" href="%PUBLIC_URL%/logo.png" />
     <link rel="icon" href="%PUBLIC_URL%/logo.png" />
     <link
     <link
       rel="preload"
       rel="preload"
-      href="https://uploads.codesandbox.io/uploads/user/f7fdc300-3c43-44c1-9a59-4338a82a9954/_oPE-FG_Virgil.ttf"
+      href="/FG_Virgil.ttf"
       as="font"
       as="font"
       type="font/ttf"
       type="font/ttf"
       crossorigin="anonymous"
       crossorigin="anonymous"
     />
     />
     <link
     <link
       rel="preload"
       rel="preload"
-      href="https://uploads.codesandbox.io/uploads/user/5f5b1ecd-ac15-4c7f-803e-e11ff53ea4ce/z1tp-Cascadia.ttf"
+      href="/Cascadia.ttf"
       as="font"
       as="font"
       type="font/ttf"
       type="font/ttf"
       crossorigin="anonymous"
       crossorigin="anonymous"

+ 1 - 0
src/index-node.ts

@@ -57,6 +57,7 @@ const elements = [
 ];
 ];
 
 
 registerFont("./public/FG_Virgil.ttf", { family: "Virgil" });
 registerFont("./public/FG_Virgil.ttf", { family: "Virgil" });
+registerFont("./public/Cascadia.ttf", { family: "Cascadia" });
 const canvas = getExportCanvasPreview(
 const canvas = getExportCanvasPreview(
   elements as any,
   elements as any,
   {
   {

+ 2 - 2
src/styles.scss

@@ -3,14 +3,14 @@
 /* http://www.eaglefonts.com/fg-virgil-ttf-131249.htm */
 /* http://www.eaglefonts.com/fg-virgil-ttf-131249.htm */
 @font-face {
 @font-face {
   font-family: "Virgil";
   font-family: "Virgil";
-  src: url("https://uploads.codesandbox.io/uploads/user/f7fdc300-3c43-44c1-9a59-4338a82a9954/_oPE-FG_Virgil.ttf");
+  src: url("/FG_Virgil.ttf");
   font-display: swap;
   font-display: swap;
 }
 }
 
 
 /* https://github.com/microsoft/cascadia-code */
 /* https://github.com/microsoft/cascadia-code */
 @font-face {
 @font-face {
   font-family: "Cascadia";
   font-family: "Cascadia";
-  src: url("https://uploads.codesandbox.io/uploads/user/5f5b1ecd-ac15-4c7f-803e-e11ff53ea4ce/z1tp-Cascadia.ttf");
+  src: url("/Cascadia.ttf");
   font-display: swap;
   font-display: swap;
 }
 }