[feat] build font subset file

This commit is contained in:
SouthFox 2025-01-06 16:56:24 +08:00
parent 5050ca1d4c
commit 1bcd7de0d0

View file

@ -1,6 +1,7 @@
#!/usr/bin/env hy
(import requests)
(import argparse)
(import sys)
(import os)
(import json)
@ -18,6 +19,24 @@
(let [file (os.path.join root -file)]
(when (and (in "posts" file) (file.endswith ".md"))
(markdown-files.append file))))
(print markdown-files))
(return markdown-files))
(get-post-files)
(defn subset-font-file [post-files]
(let [str-set #{}]
(for [f post-files]
(with [o (open f "r" :encoding "utf-8")]
(for [w (o.read)]
(str-set.add w))))
(print f"{(len str-set)} characters in all files.")
(print (.join "" str-set))
(with [f (open "strdb.txt" "w")]
(f.write (.join "" str-set)))))
(setv parser (argparse.ArgumentParser))
(parser.add_argument "-d" :dest "deploy" :action "store_true")
(setv args (parser.parse_args))
(when args.deploy
(let [post-files (get-post-files)]
(subset-font-file post-files)))