3 # Script to generate gcc/text-art/box-drawing-chars.inc
5 # This file is part of GCC.
7 # GCC is free software; you can redistribute it and/or modify it under
8 # the terms of the GNU General Public License as published by the Free
9 # Software Foundation; either version 3, or (at your option) any later
12 # GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 # You should have received a copy of the GNU General Public License
18 # along with GCC; see the file COPYING3. If not see
19 # <http://www.gnu.org/licenses/>.
23 def get_box_drawing_char_name(up
: bool,
47 for dir_name
in ('up', 'down', 'vertical', 'left', 'right', 'horizontal'):
48 val
= locals()[dir_name
]
50 dirs
.append(dir_name
.upper())
56 #print(f'{light=} {heavy=}')
61 def weights_frag(weight
: str, dirs
: list, prefix
: bool):
63 Generate a fragment where all directions share the same weight, e.g.:
67 'HEAVY DOWN AND RIGHT'
72 return f
' {weight} ' + (' AND '.join(dirs
))
74 return ' ' + (' '.join(dirs
)) + f
' {weight}'
76 assert(len(dirs
) >= 1 and len(dirs
) <= 2)
77 name
+= weights_frag('LIGHT', dirs
, True)
81 print('/* Generated by contrib/unicode/gen-box-drawing-chars.py. */')
88 name
= get_box_drawing_char_name(up
, down
, left
, right
)
93 unichar
= unicodedata
.lookup(name
)
94 print(f
'0x{ord(unichar):04X}{trailing_comma} /* "{unichar}": U+{ord(unichar):04X}: {name} */')