Skip to content

Commit

Permalink
fix font rendering problem
Browse files Browse the repository at this point in the history
  • Loading branch information
plrthink committed Aug 22, 2024
1 parent 95766d4 commit 9edafdb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
},
"dependencies": {
"@astrojs/check": "^0.7.0",
"@fontsource-variable/noto-sans": "^5.0.5",
"@fontsource-variable/noto-sans-sc": "^5.0.7",
"astro": "^3.6.4"
}
Expand Down
11 changes: 9 additions & 2 deletions src/layouts/Minimalist.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
import "@fontsource-variable/noto-sans-sc";
import Download from "../components/Download.astro";
import "../styles.css";
Expand All @@ -18,6 +17,14 @@ const { PDF_VIEW, FORCE_THEME = "" } = import.meta.env;
const { title, pdfLink, noIndex, description, locale } = Astro.props
.frontmatter as Props["frontmatter"];
if (locale === 'zh') {
// @ts-ignore
import("@fontsource-variable/noto-sans-sc");
} else if (locale === 'en') {
// @ts-ignore
import("@fontsource-variable/noto-sans");
}
// Firstname Lastname -> ['F', 'L']
const initials = title
.split(locale === "zh" ? "" : " ")
Expand All @@ -36,7 +43,7 @@ const initials = title
{noIndex && <meta name="robots" content="noindex" />}
<title>{title}</title>
</head>
<body class={!PDF_VIEW ? "bg-indigo-50 dark:bg-slate-900 sm:my-14" : ""}>
<body class={locale + " " + (!PDF_VIEW ? "bg-indigo-50 dark:bg-slate-900 sm:my-14" : "")}>
<div class="container mx-auto flex justify-center">
<article class="minimalist relative">
<div
Expand Down
6 changes: 5 additions & 1 deletion src/styles.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
body {
body.zh {
font-family: "Noto Sans SC Variable", sans-serif;
}

body.en {
font-family: "Noto Sans Variable", sans-serif;
}

::selection {
@apply bg-indigo-400 bg-opacity-50 text-white;
}
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,11 @@
resolved "https://registry.npmmirror.com/@fontsource-variable/noto-sans-sc/-/noto-sans-sc-5.0.7.tgz#acc672c6e8bd80c6b92147e0e2e90e53310a7f92"
integrity sha512-Bsp2O0QgJm9HnvY0dmCHnEq4+2NkNZ9iWYkj3afuDQIOL+2D5E07+jjYRWNWmW9DAXwIQG4NTqQrZ9OI5YsGVQ==

"@fontsource-variable/noto-sans@^5.0.5":
version "5.0.5"
resolved "https://registry.yarnpkg.com/@fontsource-variable/noto-sans/-/noto-sans-5.0.5.tgz#89e044227de4210bd62b4ab28ec9e688c78f1f03"
integrity sha512-SVixgckO4DIgvFJ+vTRZEj8vTvjZceuGOhKMgnETItKELl1tHzk+ZFatSTCofPJ1zjhTwqvHrHkFeCbUGiqaRg==

"@hapi/hoek@^9.0.0":
version "9.3.0"
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.3.0.tgz#8368869dcb735be2e7f5cb7647de78e167a251fb"
Expand Down

0 comments on commit 9edafdb

Please sign in to comment.