Skip to content

Commit 16ad8b7

Browse files
committed
➕ Add font-awesome
1 parent 01fe973 commit 16ad8b7

File tree

8 files changed

+606
-53
lines changed

8 files changed

+606
-53
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/checkout@v4
19+
- uses: typst-community/setup-typst@v3
1920
- uses: actions/checkout@v4
2021
with:
2122
repository: chengda/popular-fonts
@@ -24,8 +25,17 @@ jobs:
2425
with:
2526
repository: StellarCN/scp_zh
2627
path: fonts/scp_zh
27-
- uses: typst-community/setup-typst@v3
28+
- uses: actions/checkout@v4
29+
with:
30+
repository: siaimes/pytorch
31+
path: fonts/pytorch
32+
- uses: actions/checkout@v4
33+
with:
34+
repository: Kangzhengwei/androidFront
35+
path: fonts/androidFront
2836
- run: |
37+
sudo apt-get -y update
38+
sudo apt-get -y install fonts-font-awesome
2939
mkdir -p ~/.local/share
3040
mv fonts ~/.local/share
3141
typst compile main.typ

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ repos:
7272
- id: markdownlint-cli2
7373
additional_dependencies:
7474
- markdown-it-texmath
75+
- repo: https://github.com/Enter-tainer/typstyle
76+
rev: v0.12.14
77+
hooks:
78+
- id: typstyle
7579
- repo: https://github.com/NixOS/nixfmt
7680
rev: 8d4bd690c247004d90d8554f0b746b1231fe2436
7781
hooks:

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,20 @@
3131

3232
- [华文字体](https://github.com/chengda/popular-fonts)
3333
- [中易字体](https://github.com/StellarCN/scp_zh/tree/master/fonts)
34+
- [方正字体](https://github.com/Kangzhengwei/androidFront)
35+
- [Times New Roman](https://github.com/siaimes/pytorch/tree/main/fonts)
36+
- [font-awesome](https://github.com/FortAwesome/Font-Awesome)
3437

3538
## Build
3639

40+
Download all fonts, then
41+
3742
```sh
3843
typst compile main.typ
3944
```
45+
46+
Or use Nix:
47+
48+
```sh
49+
nix run '.#build'
50+
```

flake.lock

Lines changed: 167 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
{
2+
description = "ustc-proposal";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
7+
typix = {
8+
url = "github:loqusion/typix";
9+
inputs.nixpkgs.follows = "nixpkgs";
10+
};
11+
12+
flake-utils.url = "github:numtide/flake-utils";
13+
14+
typst-packages = {
15+
url = "github:typst/packages";
16+
flake = false;
17+
};
18+
19+
fonts-popular-fonts = {
20+
url = "github:chengda/popular-fonts";
21+
flake = false;
22+
};
23+
24+
fonts-scp_zh = {
25+
url = "github:StellarCN/scp_zh";
26+
flake = false;
27+
};
28+
29+
fonts-pytorch = {
30+
url = "github:siaimes/pytorch";
31+
flake = false;
32+
};
33+
34+
fonts-androidFront = {
35+
url = "github:Kangzhengwei/androidFront";
36+
flake = false;
37+
};
38+
};
39+
40+
outputs =
41+
inputs@{
42+
nixpkgs,
43+
typix,
44+
flake-utils,
45+
...
46+
}:
47+
flake-utils.lib.eachDefaultSystem (
48+
system:
49+
let
50+
pkgs = nixpkgs.legacyPackages.${system};
51+
typixLib = typix.lib.${system};
52+
53+
src = typixLib.cleanTypstSource ./.;
54+
commonArgs = {
55+
typstSource = "main.typ";
56+
57+
fontPaths = [
58+
"${pkgs.font-awesome}/share/fonts/opentype"
59+
"${inputs.fonts-popular-fonts}"
60+
"${inputs.fonts-scp_zh}/fonts"
61+
"${inputs.fonts-pytorch}/fonts"
62+
"${inputs.fonts-androidFront}"
63+
];
64+
65+
virtualPaths = [
66+
# Add paths that must be locally accessible to typst here
67+
# {
68+
# dest = "icons";
69+
# src = "${inputs.font-awesome}/svgs/regular";
70+
# }
71+
];
72+
};
73+
typstPackagesSrc = pkgs.symlinkJoin {
74+
name = "typst-packages-src";
75+
paths = [
76+
"${inputs.typst-packages}/packages"
77+
# More Typst packages can be added here
78+
];
79+
};
80+
typstPackagesCache = pkgs.stdenvNoCC.mkDerivation {
81+
name = "typst-packages-cache";
82+
src = typstPackagesSrc;
83+
dontBuild = true;
84+
installPhase = ''
85+
mkdir -p "$out/typst/packages"
86+
cp -LR --reflink=auto --no-preserve=mode -t "$out/typst/packages" "$src"/*
87+
'';
88+
};
89+
90+
# Compile a Typst project, *without* copying the result
91+
# to the current directory
92+
build-drv = typixLib.buildTypstProject (
93+
commonArgs
94+
// {
95+
inherit src;
96+
XDG_CACHE_HOME = typstPackagesCache;
97+
}
98+
);
99+
100+
# Compile a Typst project, and then copy the result
101+
# to the current directory
102+
build-script = typixLib.buildTypstProjectLocal (
103+
commonArgs
104+
// {
105+
inherit src;
106+
XDG_CACHE_HOME = typstPackagesCache;
107+
}
108+
);
109+
110+
# Watch a project and recompile on changes
111+
watch-script = typixLib.watchTypstProject commonArgs;
112+
in
113+
{
114+
checks = {
115+
inherit build-drv build-script watch-script;
116+
};
117+
118+
packages.default = build-drv;
119+
120+
apps = rec {
121+
default = watch;
122+
build = flake-utils.lib.mkApp {
123+
drv = build-script;
124+
};
125+
watch = flake-utils.lib.mkApp {
126+
drv = watch-script;
127+
};
128+
};
129+
130+
devShells.default = typixLib.devShell {
131+
inherit (commonArgs) fontPaths virtualPaths;
132+
packages = [
133+
# WARNING: Don't run `typst-build` directly, instead use `nix run .#build`
134+
# See https://github.com/loqusion/typix/issues/2
135+
# build-script
136+
watch-script
137+
# More packages can be added here, like typstfmt
138+
# pkgs.typstfmt
139+
];
140+
};
141+
}
142+
);
143+
}

0 commit comments

Comments
 (0)