fix font
This commit is contained in:
parent
0b1dcf165f
commit
49cabb5a25
|
|
@ -31,21 +31,29 @@ export const _ = {
|
|||
}
|
||||
}
|
||||
let f: Response = null as any;
|
||||
let raw = false;
|
||||
if (pathname?.startsWith("/s/")) {
|
||||
f = await fetch(`https://fonts.gstatic.com${pathname}`);
|
||||
raw = true;
|
||||
} else {
|
||||
f = await fetch(`https://fonts.googleapis.com${pathname}`);
|
||||
}
|
||||
if (f) {
|
||||
const body = await f.text();
|
||||
let body = null as any;
|
||||
|
||||
if (!raw) {
|
||||
body = await f.text();
|
||||
body = body.replaceAll("https://fonts.gstatic.com", "/_font");
|
||||
} else {
|
||||
body = await f.arrayBuffer();
|
||||
}
|
||||
|
||||
g._font_cache[pathname] = { body, headers: {} };
|
||||
f.headers.forEach((v, k) => {
|
||||
g._font_cache[pathname].headers[k] = v;
|
||||
});
|
||||
|
||||
const res = new Response(
|
||||
body.replaceAll("https://fonts.gstatic.com", "/_font")
|
||||
);
|
||||
const res = new Response(body);
|
||||
|
||||
res.headers.set("content-type", f.headers.get("content-type") || "");
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ export const prodIndex = (
|
|||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, user-scalable=1.0, minimum-scale=1.0, maximum-scale=1.0">
|
||||
<link rel="stylesheet" href="/index.css">
|
||||
<style>
|
||||
@import url('/_font/css2?family=Source+Sans+3:wght@400;600&display=swap');
|
||||
</style>
|
||||
${this.head.join("\n")}
|
||||
</head>
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -240,7 +240,7 @@ export const PanelFont: FC<{
|
|||
const doc = document;
|
||||
let weight = `:wght@${[300, 400, 500, 600].join(";")}`;
|
||||
let fontName = item.value.replace(/ /g, "+");
|
||||
const _href = `https://api.fonts.coollabs.io/css2?family=${fontName}${weight}`;
|
||||
const _href = `/_font/css2?family=${fontName}${weight}`;
|
||||
if (!doc.querySelector(`link[href="${_href}]`)) {
|
||||
const link = doc.createElement("link");
|
||||
link.type = "text/css";
|
||||
|
|
|
|||
Loading…
Reference in New Issue