mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-15 22:05:24 -05:00
script: generate-unicode-precompose: generate a complete header file
This commit is contained in:
parent
5a5b8140c4
commit
a24a3520c7
1 changed files with 27 additions and 2 deletions
|
|
@ -1,8 +1,33 @@
|
|||
#!/usr/bin/sh
|
||||
|
||||
cut - -d ";" -f 1,6 |
|
||||
unicodedata_txt="${1}"
|
||||
output="${2}"
|
||||
|
||||
cat <<EOF > "${output}"
|
||||
#pragma once
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
static const struct {
|
||||
wchar_t replacement;
|
||||
wchar_t base;
|
||||
wchar_t comb;
|
||||
} precompose_table[] = {
|
||||
EOF
|
||||
|
||||
# extract canonical decomposition data from UnicodeData.txt,
|
||||
# - pad hex values to 5 digits,
|
||||
# - sort numerically on base character, then combining character,
|
||||
# - then reduce to 4 digits again where possible
|
||||
#
|
||||
# "borrowed" from xterm/unicode/make-precompose.sh
|
||||
|
||||
cut "${unicodedata_txt}" -d ";" -f 1,6 |
|
||||
grep ";[0-9,A-F]" | grep " " |
|
||||
sed -e "s/ /, 0x/;s/^/{ 0x/;s/;/, 0x/;s/$/},/" |
|
||||
sed -e "s,0x\(....\)\([^0-9A-Fa-f]\),0x0\1\2,g" |
|
||||
(sort -k 3 || sort +2) |
|
||||
sed -e "s,0x0\(...[0-9A-Fa-f]\),0x\1,g"
|
||||
sed -e "s,0x0\(...[0-9A-Fa-f]\),0x\1,g" |
|
||||
sed 's/^/ /' >> "${output}"
|
||||
|
||||
echo "};" >> "${output}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue