Skip to content

Commit

Permalink
Attempt to load font file with fs/promises
Browse files Browse the repository at this point in the history
  • Loading branch information
brookslybrand committed Jan 19, 2024
1 parent d3fad19 commit dff4056
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Binary file added app/routes/img.$slug/inter-roman-latin-var.woff
Binary file not shown.
16 changes: 14 additions & 2 deletions app/routes/img.$slug/utils.server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { json } from "@remix-run/node";
import getEmojiRegex from "emoji-regex";
import interFilePath from "./inter-roman-latin-var.woff";
import fsp from "fs/promises";
import path from "path";

function stripEmojis(string: string): string {
return string.replace(getEmojiRegex(), "").replace(/\s+/g, " ").trim();
Expand Down Expand Up @@ -60,8 +63,17 @@ export function getDataFromParams(

export async function getFont(fontPath: string) {
try {
let res = await fetch(fontPath);
return res.arrayBuffer();
console.log("cwd", process.cwd());

const builtPath = path.join(
process.cwd(),
process.env.NODE_ENV === "production" ? "build/client" : "",
interFilePath,
);

console.log({ builtPath });

return fsp.readFile(builtPath);
} catch (err) {
console.log(err);
throw new Error("Error reading font");
Expand Down

0 comments on commit dff4056

Please sign in to comment.