pyfiglet icon indicating copy to clipboard operation
pyfiglet copied to clipboard

Fonts without lower case are rendered as random

Open jneb opened this issue 5 years ago • 1 comments

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 avatar May 07 '19 09:05 jneb

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.

jneb avatar May 10 '19 11:05 jneb

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?

pwaller avatar Aug 18 '23 21:08 pwaller

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.

peterbrittain avatar Aug 19 '23 23:08 peterbrittain

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

peterbrittain avatar Aug 23 '23 07:08 peterbrittain

:+1:

pwaller avatar Aug 23 '23 07:08 pwaller