File: bdf2code.sh

package info (click to toggle)
finalcut 0.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,832 kB
  • sloc: cpp: 90,264; makefile: 546; sh: 412
file content (85 lines) | stat: -rwxr-xr-x 1,927 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash

function create_code_file ()
{
  ucs2any -d "$FONTFILE" "$MAP" "${REGISTRY}-${ENCODING}"

  (
    echo -e "// ${1}\\n"
    echo -e "#ifndef ${INCLUDE_GUARD}"
    echo -e "#define ${INCLUDE_GUARD}\\n"
    echo -e "namespace finalcut\\n{\\n"
    echo -e "namespace fc\\n{\\n"
    echo -e "constexpr unsigned char ${NAME}[] =\\n{"

    grep -A"${HEIGHT}" "^BITMAP" "$NEWFONTFILE" \
    | tr '\n' ',' \
    | sed -e 's/BITMAP,//g' \
    | sed -e 's/--,/\n/g' \
    | tr '[:upper:]' '[:lower:]' \
    | sed -e 's/,/, /g' \
    | sed -e 's/\([0-9a-f][0-9a-f]\)/0x\1/g' \
    | sed -e 's/^0/  0/g' \
    | sed -e '$s/, $/  \n/' \
    | while IFS=$'\n'; read -r LINE
    do
      echo "$LINE /* $N */"
      (( N++ ))
    done

    echo -e "};"
    echo -e "\\n}  // namespace fc"
    echo -e "\\n}  // namespace finalcut"
    echo -e "\\n#endif  // ${INCLUDE_GUARD}"
  ) > "${1}"

  rm -f "$NEWFONTFILE"
}

#------------------------------#
# Convert newfont 8x16 to code #
#------------------------------#
N=0
HEIGHT=16
FONTFILE="8x16graph.bdf"
MAP="map-newfont"
REGISTRY="nf"
ENCODING="fontspecific"
INCLUDE_GUARD="FNEWFONT_8x16_H"
NAME="F_8x16graph"
NEWFONTFILE="8x16graph-nf-fontspecific.bdf"

create_code_file "newfont_8x16.h"

#------------------------------#
# Convert newfont 9x16 to code #
#------------------------------#
N=0
HEIGHT=16
FONTFILE="9x16graph.bdf"
MAP="map-newfont"
REGISTRY="nf"
ENCODING="fontspecific"
INCLUDE_GUARD="FNEWFONT_9x16_H"
NAME="F_9x16graph"
NEWFONTFILE="9x16graph-nf-fontspecific.bdf"

./bdfmerge.sh 8x16graph.bdf 9x16graph_patch.bdf >9x16graph.bdf
create_code_file "newfont_9x16.h"
rm -f 9x16graph.bdf

#--------------------------#
# Convert VGA font to code #
#--------------------------#
N=0
HEIGHT=16
FONTFILE="8x16graph.bdf"
MAP="map-vga"
REGISTRY="cp437"
ENCODING="1"
INCLUDE_GUARD="FVGAFONT_H"
NAME="F_8x16std"
NEWFONTFILE="8x16graph-cp437-1.bdf"

create_code_file "vgafont.h"