From 3620d94e7ad8d9b04ff39e2eaf01d3e023f3eda1 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 16 Jun 2025 11:56:44 -0400 Subject: [PATCH] switched to harfbuzz subsetting and now subset alegreya* --- .gitignore | 1 + acl.cool/site/draft/nomad.dj | 2 +- acl.cool/site/writings/culture-order.dj | 2 +- build.sh | 49 ++++++++++++++++--------- css/fonts.css | 16 ++++---- deps.sh | 29 ++++++++++++++- 6 files changed, 69 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index ef22b71..95757f2 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ css/code.css pgvv/ all_chars.txt **/fonts/**/*-Subset.* +woff2/ \ No newline at end of file diff --git a/acl.cool/site/draft/nomad.dj b/acl.cool/site/draft/nomad.dj index d83273e..fe24358 100644 --- a/acl.cool/site/draft/nomad.dj +++ b/acl.cool/site/draft/nomad.dj @@ -78,7 +78,7 @@ let various_floats = [1.0; 4.0; 9.0] let together : float ListMonad.t = ListMonad.bind sqrt various_floats ``` -Here's an example of the monad in action. `together` is `[1.0; -1.0] @ [2.0; -2.0] @ [3.0; -3.0]`, which of course is `[1.0; -1.0; 2.0' -2.0; 3.0; -3.0]`. In this case, we used the taking-all-branches nature of the list monad to compute all the square roots of the numbers in the provided list. If taking the square-root is considered to be an ambiguous operation[^i-know], then *yada yada*. This monad is often used to run operations that have some ambiguous result, to capture the idea that multiple possible return values are valid, e.g. "the square root of four" can be considered ambiguous, since both 2^2^ and (-2)^2^ are 4. Another example of this can be found in parsing with ambiguous grammars. Parser combinator libraries often make it easy to define ambiguous-on-the-face parsers and resolve the ambiguity through some convention, but perhaps +Here's an example of the monad in action. `together` is `[1.0; -1.0] @ [2.0; -2.0] @ [3.0; -3.0]`, which of course is `[1.0; -1.0; 2.0; -2.0; 3.0; -3.0]`. In this case, we used the taking-all-branches nature of the list monad to compute all the square roots of the numbers in the provided list. If taking the square-root is considered to be an ambiguous operation[^i-know], then *yada yada*. This monad is often used to run operations that have some ambiguous result, to capture the idea that multiple possible return values are valid, e.g. "the square root of four" can be considered ambiguous, since both 2^2^ and (-2)^2^ are 4. Another example of this can be found in parsing with ambiguous grammars. Parser combinator libraries often make it easy to define ambiguous-on-the-face parsers and resolve the ambiguity through some convention, but perhaps looks like multiple return with only one in the chain, but the sequencing is what gives us nondeterminism; multiple return doesn't chain the same. To do this without a monad we'd need to do diff --git a/acl.cool/site/writings/culture-order.dj b/acl.cool/site/writings/culture-order.dj index 35fd2be..67e826b 100644 --- a/acl.cool/site/writings/culture-order.dj +++ b/acl.cool/site/writings/culture-order.dj @@ -1,6 +1,6 @@ # Reading Order of The Culture -I've generated a reading order dependency graph for books in Iain M. Banks' monumental _Culture_ series. The idea is that if there's an arrow from book A to book B, then to get the most possible enjoyment from either A or B, A should be read before B. +I've generated a reading order dependency graph for books in Iain M. Banks' unsurpassable Sci-Fi classic, the _Culture_ series. The idea is that if there's an arrow from book A to book B, then to get the most possible enjoyment from either A or B, A should be read before B. ![A dependency graph diagram of what Culture books must eb read before what others.](/culture.dot.png) Above is the graph, and [right here](/culture.dot.txt) is the vizgraph description file that lists my rationale for each dependency. diff --git a/build.sh b/build.sh index d787f6b..fee9b88 100755 --- a/build.sh +++ b/build.sh @@ -7,34 +7,47 @@ find acl.cool/serve/ ytheleus.org/serve/ -type f -mmin +11 -delete function soup_config { rm soupault.toml cp ../soupault.toml soupault.toml - cat soupault.toml.frag* >> soupault.toml + cat soupault.toml.frag* >>soupault.toml } source ./pgvv/bin/activate -find acl.cool/site/ ytheleus.org/site/ -type f \( -name '*.dj' -o -name '*.html' \) -exec cat {} + > all_chars.txt -cat common_chars.txt >> all_chars.txt +find acl.cool/site/ ytheleus.org/site/ -type f \( -name '*.dj' -o -name '*.html' \) -exec cat {} + >all_chars.txt +cat common_chars.txt >>all_chars.txt for font in fonts/JuliaMono/*{-Light,-Regular,-SemiBold}{,Italic}.woff2; do - echo "Subsetting $font" - pyftsubset "$font" --flavor=woff2 --text-file=all_chars.txt --layout-features='*' \ - --output-file="$(awk -F '.woff2' '{print $1}' <<< "$font")-Subset.woff2" + ./woff2/woff2_decompress "$font" + ttf_font="${font%.woff2}.ttf" + + subset_ttf="${ttf_font%.ttf}-Subset.ttf" + hb-subset "$ttf_font" \ + --output-file="$subset_ttf" \ + --text-file=all_chars.txt \ + --layout-features='*' \ + --passthrough-tables + + ./woff2/woff2_compress "$subset_ttf" + + rm "$subset_ttf" "$ttf_font" done -#for font in fonts/Alegreya/static/Alegreya-{Regular,Italic,Bold,BoldItalic}.ttf; do -# echo "Subsetting $font" -# pyftsubset "$font" --text-file=all_chars.txt --layout-features='*' \ -# --output-file="$(awk -F '.ttf' '{print $1}' <<< "$font")-Subset.ttf" -#done -# -#for font in fonts/Alegreya_Sans/AlegreyaSans-{Regular,Italic,Bold,BoldItalic}.ttf; do -# echo "Subsetting $font" -# pyftsubset "$font" --text-file=all_chars.txt --layout-features='*' \ -# --output-file="$(awk -F '.ttf' '{print $1}' <<< "$font")-Subset.ttf" -#done +for font in \ + fonts/Alegreya/static/Alegreya-{Regular,Italic,Bold,BoldItalic}.ttf \ + fonts/Alegreya_Sans/AlegreyaSans-{Regular,Italic,Bold,BoldItalic}.ttf; do + subset_ttf="${font%.ttf}-Subset.ttf" + hb-subset "$font" \ + --output-file="$subset_ttf" \ + --text-file=all_chars.txt \ + --layout-features='*' \ + --passthrough-tables + + ./woff2/woff2_compress "$subset_ttf" + + rm "$subset_ttf" +done rm css/code.css -pygmentize -f html -S algol_nu | grep -v 'line-height' > css/code.css +pygmentize -f html -S algol_nu | grep -v 'line-height' >css/code.css builtin pushd acl.cool soup_config diff --git a/css/fonts.css b/css/fonts.css index b2e464a..c5e45e0 100644 --- a/css/fonts.css +++ b/css/fonts.css @@ -56,56 +56,56 @@ @font-face { font-family: 'BodySerif'; - src: url('../assets/fonts/Alegreya/static/Alegreya-Regular.ttf') format('truetype'); + src: url('../assets/fonts/Alegreya/static/Alegreya-Regular-Subset.woff2') format('woff2'); font-weight: normal; font-style: normal; } @font-face { font-family: 'BodySerif'; - src: url('../assets/fonts/Alegreya/static/Alegreya-Italic.ttf') format('truetype'); + src: url('../assets/fonts/Alegreya/static/Alegreya-Italic-Subset.woff2') format('woff2'); font-weight: normal; font-style: italic; } @font-face { font-family: 'BodySerif'; - src: url('../assets/fonts/Alegreya/static/Alegreya-Bold.ttf') format('truetype'); + src: url('../assets/fonts/Alegreya/static/Alegreya-Bold-Subset.woff2') format('woff2'); font-weight: bold; font-style: normal; } @font-face { font-family: 'BodySerif'; - src: url('../assets/fonts/Alegreya/static/Alegreya-BoldItalic.ttf') format('truetype'); + src: url('../assets/fonts/Alegreya/static/Alegreya-BoldItalic-Subset.woff2') format('woff2'); font-weight: bold; font-style: italic; } @font-face { font-family: 'BodySans'; - src: url('../assets/fonts/Alegreya_Sans/AlegreyaSans-Regular.ttf') format('truetype'); + src: url('../assets/fonts/Alegreya_Sans/AlegreyaSans-Regular-Subset.woff2') format('woff2'); font-weight: normal; font-style: normal; } @font-face { font-family: 'BodySans'; - src: url('../assets/fonts/Alegreya_Sans/AlegreyaSans-Italic.ttf') format('truetype'); + src: url('../assets/fonts/Alegreya_Sans/AlegreyaSans-Italic-Subset.woff2') format('woff2'); font-weight: normal; font-style: italic; } @font-face { font-family: 'BodySans'; - src: url('../assets/fonts/Alegreya_Sans/AlegreyaSans-Bold.ttf') format('truetype'); + src: url('../assets/fonts/Alegreya_Sans/AlegreyaSans-Bold-Subset.woff2') format('woff2'); font-weight: bold; font-style: normal; } @font-face { font-family: 'BodySans'; - src: url('../assets/fonts/Alegreya_Sans/AlegreyaSans-BoldItalic.ttf') format('truetype'); + src: url('../assets/fonts/Alegreya_Sans/AlegreyaSans-BoldItalic-Subset.woff2') format('woff2'); font-weight: bold; font-style: italic; } diff --git a/deps.sh b/deps.sh index 7834f41..8f890d8 100755 --- a/deps.sh +++ b/deps.sh @@ -5,11 +5,17 @@ if ! [[ -d pgvv/ ]]; then source ./pgvv/bin/activate python3 -m pip install --upgrade pip pip install --upgrade pygments - pip install --upgrade fonttools - pip install --upgrade brotli + # pip install --upgrade fonttools + # pip install --upgrade brotli deactivate fi +which dnf +if ! [[ $? == 0 ]]; then + echo 'please install hb-subset (provided by harfbuzz-devel on RedHat)' + exit 6 +fi + which opam 2> /dev/null if [[ $? == 0 ]]; then opam install -y soupault @@ -25,3 +31,22 @@ else echo 'failed to install jotdown with cargo' exit 3 fi + +which git 2> /dev/null +if ! [[ $? == 0 ]]; then + echo 'you need git' + exit 4 +fi + +which cc 2> /dev/null +if ! [[ $? == 0 ]]; then + echo 'you need a C compiler' + exit 5 +fi + +if ! [[ -d woff2/ ]]; then + git clone https://github.com/mobotsar/woff2.git --recursive || exit 7 + builtin pushd woff2 + make clean all || exit 8 + popd +fi \ No newline at end of file