pwaller/pyfiglet

Fonts without lower case are rendered as random

jneb opened this issue · 5 comments

jneb commented

If you use a font that does not have support for lower case, the output appears random.

         ...: f = Figlet(font='ugalympi')
         ...: print(f.renderText('this appears weird'))
   #     #    # #  #     # # ##
## #      #       # #  #      ##
    #### # ###  #  #    ## # #  # #
# ## # #   #### # # #  # #  #   # #
# ####   # # ## #  #    #    ###
  ###     ## #  # ####     #### # #
###  # #              # ## ##   #
 #   #   #    # # ##  #  # ##  #  #
## #         # #      # #   ###     ## #     # #   #  # ##
### ##       # #      # #  # #  ### ### ##        # #    ##
# # #  #  ## #  #  ## #  # # #### # # # #  # # ## # # # #  # #
  ###       # # #    # # #  ## # ##   ###    # ## #    #   # #
#  # # # #    # # #    # # # #  ### #  # # # ####       ###
##  # #   #   # #  #   # # #    # # ##  # #     ###   #### # #
# ####   # ####   # ####    #    ## # ####   ##  #  # ##   #
    ##    ## # ##  ## # ## ##   ##      ##       # ## ##  #  #
 #    #   ###      #     # # #   #  # # ## #
# #  ##  # #  ### # #  #        # #  #######
  #####  # #### #  #    ## # ## # #  # ##  #
 #  ##    ## # ## # #  # # # ## #     # #  #
 # #  ## # #  ###  #    #  ####           ##
   #  ## #    # # ####        ###   ## #
# #   #   #    ##     # ## ##  #  #       ##
   #   # ##   ##  ##  #  #     # ## ## ####

Of course, using upper case is a workaround:

         ...: f = Figlet(font='ugalympi')
         ...: print(f.renderText('this appears weird'.upper()))

 ###### ##   #
 # ##   ##  ##  #####
   #    ######   ##     ####
   ##   #   ##   ##    ###
   ##   ##  ##  ###     ####
  ###           #####     ##
                       ####

  ####              #####  ####   #####
  #  ## ####  ####  ###    #  ## ##  ##
 ##  ## #  ## #  ## ####  ##  ## ##   #   ####
 ###### #   # #   # ##    ###### #####   ###
 #   ## ##### ##### ## ## #   ## ##  ##   ####
 ##  ## ##    ##    ##### ##  ## ##  ##     ##
        ###   ###                        ####

        #####         #####  ####
 ##   # ###    ##### ##  ##  ##  #
 ##   # ####    ##   ##   #   #  #
 #    # ##      ##   #####   ##  #
 # ## # ## ##  ###   ##  ##  #####
 ###### #####  ##### ##  ##
  #  #```

Is there a way for the user to detect that the font doesn't support lower case? Or even better, can Figlet automatically convert to upper case when lower isn't supported?
- jneb
jneb commented

I had a good look at this, and the problem is with the font files.
If a font name is exactly 8 characters and has a _ in it, it is pretty likely to have been ported from a font that precedes the ASCII standard, and it ported from a Commodore 64. Hence, no lower case, and the conversion program just took whatever was in memory. Sometimes, this was useful, but not always.

Hi, Sorry it's been a while since I've had any bandwidth for this. I see that we have such fonts. If anyone is reading this, do you think there is a straightfoward solution in pyfiglet?

Should we delete the broken fonts? Anyone got a quick method to identify the broken fonts?

If the fonts simply doesn't have the lower case forms, would it be reasonable to first conver the input to upper case and render that?

It's the font file at fault. They must contain definitions for a standard set of ASCIi characters, but the original source didn't have them all and so the font has been populated with random garbage.

You could create a new file format (to allow you to remove the garbage and then handle missing letter in a graceful manner), try to define the missing letters in the same style, or just accept that this font is broken and live with the limitations, or use a different one.

Figlet produces the same output. Since pyfiglet aims to reproduce what figlet would do, I think we should live with this feature.

👍