Skip to content

Commit

Permalink
Fall back to ASCII output if needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilk committed Feb 6, 2024
1 parent 726791e commit 1594b3b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ubanner
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import argparse
import bisect
import itertools
import locale
import shutil
import signal
import sys
Expand Down Expand Up @@ -62,7 +63,6 @@ def pango_render(text, size=(76, 24), font=None, font_size=None):
PangoCairo.show_layout(ctx, layout)
data = surface.get_data()
stride = surface.get_stride()
charset = ' ░▒█'
cdiv = 512 // len(charset)
for y in range(ht // 2):
s = ''
Expand Down Expand Up @@ -93,6 +93,13 @@ class act_list_fonts(argparse.Action):
seen.add(descr)
sys.exit()

encoding = locale.nl_langinfo(locale.CODESET)
charset = ' ░▒█'
try:
charset.encode(encoding, 'strict')
except UnicodeError:
charset = ' +*#'

def main():
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
ap = argparse.ArgumentParser()
Expand Down

0 comments on commit 1594b3b

Please sign in to comment.