Commit 3e377ae

HPCesia <me@hpcesia.com>
2026-03-13 08:58:24
Improve fonts both in web and PDF
1 parent 5dbf19a
Changed files (3)
src
contents
_lib
styles
src/contents/_lib/templates/font.typ
@@ -0,0 +1,18 @@
+#let latin-fonts = (
+  "Libertinus Serif",
+  "Georgia",
+  "Cambria",
+  "Times New Roman",
+)
+#let cjk-fonts = (
+  "Source Han Serif",
+  "SimSun",
+  "STSongti",
+)
+#let tybios-fonts = latin-fonts.map(f => (name: f, covers: "latin-in-cjk")) + cjk-fonts
+
+#let font-template(body) = {
+  set text(font: tybios-fonts)
+
+  body
+}
src/contents/_lib/tybios.typ
@@ -5,14 +5,16 @@
 #let post-template(body) = {
   import "./mathyml/src/lib.typ": to-mathml
 
-  import "./templates/raw.typ": raw-template
-  import "./templates/heading.typ": heading-template
+  import "./templates/font.typ": font-template
   import "./templates/footnote.typ": footnote-template
+  import "./templates/heading.typ": heading-template
+  import "./templates/raw.typ": raw-template
 
   show math.equation: to-mathml
 
-  show: heading-template
+  show: font-template
   show: footnote-template
+  show: heading-template
   show: raw-template
 
   body
src/styles/global.css
@@ -1,6 +1,10 @@
 @import "tailwindcss";
 @import "./article/index.css";
 
+@theme {
+  --font-serif: "Libertinus Serif", ui-serif, serif;
+}
+
 :root {
   background-color: var(--color-neutral-100);
   color: var(--color-neutral-700);
@@ -8,4 +12,29 @@
     background-color: var(--color-neutral-900);
     color: var(--color-neutral-300);
   }
+  & :lang("zh-CN") {
+    --font-serif:
+      "Libertinus Serif", "Noto Serif SC", "Source Han Serif SC",
+      "Source Han Serif", ui-serif, serif;
+  }
+  & :lang("zh-TW") {
+    --font-serif:
+      "Libertinus Serif", "Noto Serif TC", "Source Han Serif TC",
+      "Source Han Serif", ui-serif, serif;
+  }
+  & :lang("zh-HK") {
+    --font-serif:
+      "Libertinus Serif", "Noto Serif TC", "Source Han Serif TC",
+      "Source Han Serif", ui-serif, serif;
+  }
+  & :lang("jp") {
+    --font-serif:
+      "Libertinus Serif", "Noto Serif JP", "Source Han Serif JP",
+      "Source Han Serif", ui-serif, serif;
+  }
+  & :lang("ko") {
+    --font-serif:
+      "Libertinus Serif", "Noto Serif KR", "Source Han Serif KR",
+      "Source Han Serif", ui-serif, serif;
+  }
 }