Expand repertoire
[llpp.git] / misc / llppac
blobba872a49801dcae9f83d7bfb2b7d886b7bdb8bd1
1 #!/bin/sh
2 set -e
4 font=$HOME/x/fnt/LastResort.ttf
5 ! test -r $font || export LLPP_FALLBACK_FONT=$font
7 die() {
8 echo "$1" >&2
9 exit 1
12 cachedir="${XDG_CACHE_HOME:-$HOME/.cache}/llpp"
13 test -d "$cachedir" || die "cache directory '$cachedir' does not exist"
15 caspsuf=
16 type=
18 executable_p() { command -v "$1" >/dev/null 2>&1; }
20 missing() {
21 executable_p $1 || \
22 eval "$1() { die \"$2 is needed for \$type conversion\"; }"
25 text() {
26 cat <<EOF
27 <pre style="font-size: ${1}pt;">
28 $1 <hr>
29 EOF
30 test -n "$2" && cat $2 || cat <<EOF
31 S9 З3Ӡʒ I|l1 O0 0O o0 0o
33 ЁЖЗ
35 abcdefghijklmnopqrstuvwxyz
36 ABCDEFGHIJKLMNOPQRSTUVWXYZ
37 абвгдеёжзийклмнопрстуфхцчшщэюя
38 АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЭЮЯ
39 инпипнишпнипшнипнпншпнпинпипнпипщнпипипин
40 иннициатива шиорокошарикоподшипниковый взбзднуть гидроаэроионизация
41 телегаммааппарат фельдъегерь четырёхсотпятидесятисемимиллиметровое
42 превысокомногорассмотрительствующий вскользь забулдыжничество
43 цецецница
44 https://ru.wikipedia.org/wiki/Панграмма https://en.wikipedia.org/wiki/Pangram
45 Экс-граф? Плюш изъят. Бьём чуждый цен хвощ!
46 Waltz, bad nymph, for quick jigs vex
47 ',.ფyfგcრლაოეუიდჰთნსყჯქxბმwვზ
48 Σομε πσθδο γρεεκ
49 Il1| Il|1 I1l| I1|l I|1l I|l1 lI1| lI|1 l1I| l1|I l|1I l|I1
50 1lI| 1l|I 1Il| 1I|l 1|Il 1|lI |l1I |lI1 |1lI |1Il |I1l |Il1
51 \`1234567890-=\\
52 ~!@#\$$%^&*()_+|
53 ₹₽£$€
54 [];',.//|/\ &gt;- -&gt; ~~&lt; &lt;-- --&gt; == === ==&gt; &lt;==
55 {}:"&lt;&gt;?"
56 S in S9 59 S9 is like 5 also 8B B8 BB 88B8 88B8
57 final fjord flair ft fff
58 3ЗЭэзээз3ЗqgO0o ijklI1| bgqpykvwlliliiijil1 lLLl
59 01234567890 3ДС ЗДС ӠДС ʒДС
60 rnrmnnmrrrnmmr <i>Nürnberg</i> (rn -> m)
61 Apay Арау
62 örök für A̋ a̋ ő ű https://en.wikipedia.org/wiki/Diacritic
63 молодо́й
64 - - (~-) ~ ~ (-~) ''"''""., 1.65Mb
65 curly vs plain braces {} () {} ({ {( }) )} →
66 Bjarne Stroustrup (/ˈbjɑːrnə ˈstraʊstrʊp/; Danish: [ˈbjɑːnə ˈsdʁʌwˀsdʁɔb]
67 ○●🅼
68 😁 😂 😃 😅 😆 😇 😈 😉 😊 😋 😌 😍 😎 😏 😐 😑
69 😒 😓 😕 😗 😘 😙 😚 😛 😜 😞 😠 😡 😢 😥 😧 😨
70 😩 😪 😫 😬 😭 😮 😯 😰 😱 😲 😳 😵 😶 😸 😹 😻
71 😼 😽 😾 😿 🙀 🙁 🙂 🙃 🙄 🙆 🙇 🙉 🙊 🙌 🙍 🙎
72 🙏 1F600 😀 1F621 😤 😦 😖 😄 😔 🙅 🙈 🙋 1F620
73 1F627 😟 😴 😷 😺 1F609 1F60C 😝 😣 ✉ 📧
75 kerning
76 echo \${@:5}
77 life [l i fe]
78 lambdabot [l a mb]
79 Commutative [Co mm utative]
80 weird [we i rd]
81 Before [Bef ore, Be for e]
82 higher [gh, h i gher, hi gher]
83 multi [mu lti]
84 till [ti ll]
85 language [an]
86 plan [la]
87 when [wh]
88 kerning [rn | ng]
89 мне [мн е]
90 oiled [oi led]
91 mkfifo [mk f i fo, mk f i fo]
92 didn't [di dn't]
93 argumnet (sic) []
94 more [mo re]
95 CmmCall [CmmC a l l]
96 -Wvla [-Wv la]
97 align [a l i gn]
98 Compiling [Co mp iling]
99 print [pr int]
100 fcmono [f cmono]
101 Mail [M ail]
102 xsrc [x src]
103 Pokorna
104 buildglyphs.js [buil dg lyphs]
105 Dollar [Do ll ar]
106 signed [s i gned]
107 Pine [Pi ne]
108 right [r i ght]
109 ugliness
110 Nigeria [Ni g eria]
111 Nothing [Nothi ng]
112 modify [mo dify]
113 mplus [mp lus]
114 Apostolic [A postolic]
115 коде [к о де]
116 Прокофьевну [Про ко фьевну]
117 Хэлп [X элп]
118 коснулся [ко снулся]
119 обьявляным [об ья вленым]
120 Queen [Qu een]
121 etymological [et ymological]
122 sigh [s i gh]
123 git [gi t]
124 некочевого [не ко чевого]
125 Розовое [Ро зо вое]
126 Trump [Tru mp]
127 покрытие [по кр ытие]
128 Singapore [Si ng apore]
129 Georgy [Ge orgy]
130 with [wi th]
131 Yokozuna [Y okozuna]
132 подтверждение [под тверждение]
133 Xwayland [X wayland]
134 callable [ca l l ab le]
135 Noah [N oa h]
136 Los [L os]
137 refused [ref used]
138 Julia [J ulia | Jul i a]
139 Joe Armstrong [J oe (rip :()]
140 James [J ames]
141 CAPTCHA [CA PTCHA]
142 KIZER [KI ZER]
144 almost kerning
145 hope doesn't
146 Illegal
147 automatically effective
148 Ilium is the Latin for Ilion.
149 jtanx
151 (from UTF8-demo.txt)
152 Box drawing alignment tests: █
154 ╔══╦══╗ ┌──┬──┐ ╭──┬──╮ ╭──┬──╮ ┏━━┳━━┓ ┎┒┏┑ ╷ ╻ ┏┯┓ ┌┰┐ ▊ ╱╲╱╲╳╳╳
155 ║┌─╨─┐║ │╔═╧═╗│ │╒═╪═╕│ │╓─╁─╖│ ┃┌─╂─┐┃ ┗╃╄┙ ╶┼╴╺╋╸┠┼┨ ┝╋┥ ▋ ╲╱╲╱╳╳╳
156 ║│╲ ╱│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╿ │┃ ┍╅╆┓ ╵ ╹ ┗┷┛ └┸┘ ▌ ╱╲╱╲╳╳╳
157 ╠╡ ╳ ╞╣ ├╢ ╟┤ ├┼─┼─┼┤ ├╫─╂─╫┤ ┣┿╾┼╼┿┫ ┕┛┖┚ ┌┄┄┐ ╎ ┏┅┅┓ ┋ ▍ ╲╱╲╱╳╳╳
158 ║│╱ ╲│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╽ │┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▎
159 ║└─╥─┘║ │╚═╤═╝│ │╘═╪═╛│ │╙─╀─╜│ ┃└─╂─┘┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▏
160 ╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ ▗▄▖▛▀▜ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█
161 ▝▀▘▙▄▟
163 https://mirrors.zju.edu.cn/CTAN/fonts/gofonts/doc/gofonts.pdf (page 2)
165 DIN Legibility Standard
167 The recent German DIN 1450 legibility standard
168 recommends several features for font legibility, including
169 differentiation of letter shapes to reduce confusion. The Go fonts
170 conform to the 1450 standard by carefully differentiating zero from
171 capital O; numeral 1 from capital I (eye) and lowercase l (ell);
172 numeral 5 from capital S; and numeral 8 from capital B. The shapes of
173 bowls of b d p q follow the natural asymmetries of legible Renaissance
174 handwriting, aiding differentiation to reduce confusion. [5]
177 (https://en.wikipedia.org/wiki/Jabberwocky
178 Idea from the aforementioned gofonts paper)
180 Бе сгладне и честлинните комбурси Það leið að stekju, og slýgir greðlar
181 търляха се и сврецваха във плите; sig snældu og böluðu um slöffruna,
182 съвсем окласни бяха тук щурпите og angurvært sungu sópfiðrungar
183 и отма равапсатваха прасурси. við sífgelt týðmana svíræna.
185 (https://en.wikipedia.org/wiki/Typeface)
187 For the rational mind, type design can be a maddening game
188 of drawing things differently in order to make them appear the
189 same.
190 </pre>
194 maketext() {
195 # https://github.com/react-boilerplate/react-boilerplate/issues/1340
196 test -d "$cachedir/fonts" || mkdir "$cachedir/fonts"
197 filename="$(basename "$1")"
198 textfilename="$2"
199 cat >"$cachedir/fonts/text.html" <<EOF
200 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
201 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
202 <html>
203 <head>
204 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
205 <title>$filename</title>
206 <style type="text/css">
207 @font-face { font-family: moo; src: url('$1'); }
208 pre { font-family: moo; }
209 </style>
210 </head>
211 $filename
212 <body>
214 for size in 6 8 10 12 4 2; do
215 text $size $textfilename >>"$cachedir/fonts/text.html"
216 done
217 cat >>"$cachedir/fonts/text.html" <<EOF
218 <br/>
219 $(fc-scan -f '%{fullname} %{style} %{slant} %{file} %{fontversion} %{capability} %{lang}' "$1" || file "$1")
220 </body>
221 </html>
225 trap 'test -n "$casp" && rm -f "$casp"' 0
227 while getopts s:c:m:t:fu opt; do
228 case $opt in
229 m) mime=$OPTARG;;
230 t) type=$OPTARG;;
231 f) force=true;;
232 c) css="-s $OPTARG";;
233 s) textfilename="$OPTARG";;
234 ?) die "usage: $0 [-c css] [-m mime/type] [-t filter] [-f] [-s textfile] [path|url]";;
235 esac
236 done
237 shift $(($OPTIND - 1))
238 test -z "$1" && die "usage $0: path"
240 origin="$1"
241 if ${force-test ! -e "$1"} && expr >/dev/null "$1" : "\(ftp\|https\?\)://"; then
242 if executable_p wget; then
243 dl() { wget -q $1 -O $2; }
244 elif executable_p curl; then
245 dl() { curl -L $1 -o $2; }
246 else
247 die "no program to fetch remote urls found"
250 hashof="$cachedir/$(basename "$1")"
251 dl "$1" "$hashof" || test -e "$md5of"
252 shift
253 set -- "$hashof" "$@"
254 else
255 hashof="$1"
258 test -z "$type" && { ft=$(file -L --mime-type -b "$1") || die "$ft"; }
260 case $ft in
261 application/x-gzip | application/x-compress) dc=zcat;;
262 application/x-xz) dc=xzcat;;
263 application/x-bzip2) dc=bzcat;;
264 *) unset dc || true;;
265 esac
267 filt='"${dc-cat}" "$1" |'
269 typeofmime() {
270 case "$1" in
271 application/postscript) type=ps;;
272 application/pdf) type=pdf;;
273 image/vnd.djvu) type=djvu;;
274 text/html) type=html;;
275 text/plain) type=text;;
276 application/msword) type=word;;
277 application/vnd.openxmlformats-officedocument.* \
278 | application/vnd.ms-powerpoint \
279 | application/vnd.ms-excel \
280 | application/vnd.oasis.opendocument.*) type=uno;;
281 image/svg+xml) type=svg;;
282 image/png | image/jpeg) test -n "$dc" && type="image" || type="image2";;
283 image/*) type=image;;
284 application/x-dvi) type=dvi;;
285 application/x-font-ttf \
286 | application/vnd.ms-opentype \
287 | application/font-sfnt) type=font;;
288 *) return 1;;
289 esac
290 return 0
293 if test -z "$type"; then
294 test -z "$mime" && \
295 mime=$(file -L --mime-type -b "$1" || die "$mime") || \
296 $(file -L --mime-type -bz "$1" || die "$mime")
297 typeofmime "$mime" || die "unhandled file type: '$mime'"
300 caspsuf=".pdf"
301 case $type in
302 ps) conv='ps2pdf - "$casp"';;
303 image2|pdf) test -z "$dc" && exec llpp "$@" || conv='cat >"$casp"';;
304 texi) {
305 missing texi2html "texi2html(http://www.nongnu.org/texi2html/)"
306 missing prince "PrinceXML(http://www.princexml.com/)"
307 conv='texi2html - -o - | prince $css - -o "$casp"'
309 djvu) {
310 missing ddjvu "ddjvu(http://djvu.sourceforge.net/doc/man/ddjvu.html)"
311 conv='ddjvu -format=pdf - "$casp"'
313 html) {
314 missing prince "Prince(http://www.princexml.com/)"
315 conv='prince $css - -o "$casp"'
317 html2epub) {
318 missing pandoc "pandoc(http://pandoc.org)"
319 caspsuf=".epub"
320 conv='pandoc -r html - -w epub2 -o "$casp"'
322 word) {
323 if executable_p unoconv && test -z "$dc"; then
324 unset filt
325 conv='unoconv -o "$casp" "$1"'
326 else
327 missing antiword "antiword or unoconv"
328 conv='antiword -m 8859-1.txt -a a4 - >"$casp"'
331 uno) {
332 test -n "$dc" && die "cannot convert compressed '$mime'"
333 unset filt
334 missing unoconv "unoconv(http://dag.wiee.rs/home-made/unoconv/)"
335 conv='unoconv -o "$casp" "$1"'
337 svg) {
338 if executable_p inkscape && test -z "$dc"; then
339 unset filt
340 conv='inkscape -z -A "$casp" "$1"'
341 else
342 if executable_p rsvg-convert; then
343 conv='rsvg-convert -f pdf -o "$casp"'
344 else
345 test -n "$dc" && die "cannot convert compressed '$mime'"
346 unset filt
347 missing unoconv "unoconv(http://dag.wiee.rs/home-made/unoconv/)"
348 conv='unoconv -o "$casp" "$1"'
352 font) {
353 maketext "$1" "$textfilename"
354 exec llpp -origin $1 -layout-height 0 "$cachedir/fonts/text.html"
356 image) {
357 missing convert "convert(http://www.imagemagick.org/script/convert.php)"
358 conv='convert - pdf:"$casp"'
360 dvi) {
361 test -n "$dc" && die "cannot convert compressed '$mime'"
362 unset filt
363 missing dvipdf "dvipdf(http://ghostscript.com/)"
364 conv='dvipdf "$1" "$casp"'
366 text) {
367 missing pandoc "pandoc(http://pandoc.org/)"
368 conv='pandoc -t epub2 - -o "$casp"'
369 caspsuf=.epub
371 *) die "unhandled filter type: '$type'";;
372 esac
374 hash=$(cksum "$hashof") || die "$hash"
375 casp=$cachedir/${hash%% *}$caspsuf
377 { test -n "$force" || test ! -e "$casp"; } && eval "$filt" "$conv"
378 shift
380 exec llpp -origin $origin "$@" "$casp"