Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slant front weird rendering #61

Closed
jcubic opened this issue Jul 22, 2020 · 13 comments
Closed

Slant front weird rendering #61

jcubic opened this issue Jul 22, 2020 · 13 comments

Comments

@jcubic
Copy link
Contributor

jcubic commented Jul 22, 2020

I've just got weird rendering of text "Terminal Chess" in Slant font when wrapping.

  ______                    _             __
 /_  __/__  _________ ___  (_)___  ____ _/ /
  / / / _ \/ ___/ __ `__ \/ / __ \/ __ `/ / 
 / / /  __/ /  / / / / / / / / / / /_/ / /  
/_/__\\\\\\/  /_/ /_/ /_/_/_/ /_/\__,_/_/   
  / ____/ /_  ___  __________               
 / /   / __ \/ _ \/ ___/ ___/               
/ /___/ / / /  __(__  |__  )                
\____/_/ /_/\___/____/____/                 

See the "e" letter. Reproducing demo https://codepen.io/jcubic/pen/JjGxvMY?editors=0010

@jcubic
Copy link
Contributor Author

jcubic commented Jul 22, 2020

It's not about wrapping it's about merging lines same can be observed at demo when type two lines

http://patorjk.com/software/taag/#p=display&f=Slant&t=Terminal%0AChess .

@patorjk
Copy link
Owner

patorjk commented Jul 22, 2020

Thank you for the report. This looks like a bug in the vertical smushing. Unfortunately I’m on mobile right now and won’t be able to take a closer look until tonight.

@patorjk
Copy link
Owner

patorjk commented Jul 23, 2020

So it looks like this isn't a bug, but rather a consequence of the font author not setting good layout parameters for the font. The Slant font has a full_layout value of 18319 [1]. This means it's layout options are: [2]

  • Vertical smushing by default
  • Apply vertical smushing rule 3 when smushing
  • Apply vertical smushing rule 2 when smushing
  • Apply vertical smushing rule 1 when smushing
  • Horizontal smushing by default
  • Apply horizontal smushing rule 4 when smushing
  • Apply horizontal smushing rule 1 when smushing
  • Apply horizontal smushing rule 2 when smushing
  • Apply horizontal smushing rule 3 when smushing

It's "Apply vertical smushing rule 2 when smushing" that is causing this effect. My guess, from the comment at the top of the font file, is that Paul Burton just copied the layout parameter from another font. Changing the full_layout parameter to 17807 (which will exclude that rule), should fix this issue.

[1] https://github.com/patorjk/figlet.js/blob/master/fonts/Slant.flf
[2] https://github.com/patorjk/figlet.js/blob/master/doc/figfont.txt

@jcubic
Copy link
Contributor Author

jcubic commented Jul 23, 2020

Great, investigation. Will you publish to npm version 1.5.1 with the fix?

@jcubic
Copy link
Contributor Author

jcubic commented Jul 23, 2020

Can you create the branch with the fix where I can test? I wanted to test master branch from https://cdn.jsdelivr.net/gh/patorjk/figlet.js@master/fonts/ but it seems that there was no commit.

@jcubic
Copy link
Contributor Author

jcubic commented Jul 23, 2020

Or maybe you will not update the Font because it's someone else document?

@jcubic
Copy link
Contributor Author

jcubic commented Jul 23, 2020

I've checked linux figlet and it seems that it don't work like this, maybe there is layout mode that allow this but it's not documented (I was not able to find it):
this it the output:

$ echo -e "Terminal Chess" | figlet -f slant -w 71
  ______                    _             __
 /_  __/__  _________ ___  (_)___  ____ _/ /
  / / / _ \/ ___/ __ `__ \/ / __ \/ __ `/ / 
 / / /  __/ /  / / / / / / / / / / /_/ / /  
/_/  \___/_/  /_/ /_/ /_/_/_/ /_/\__,_/_/   
                                            
   ________                  
  / ____/ /_  ___  __________
 / /   / __ \/ _ \/ ___/ ___/
/ /___/ / / /  __(__  |__  ) 
\____/_/ /_/\___/____/____/

If you know how to enable same behavior in original figlet it can be reported as a bug.

@patorjk
Copy link
Owner

patorjk commented Jul 23, 2020

I will take a closer look at this - at first I thought it was because the linux figlet didn't support full_layout, but it may be an issue with vertical underscore smushing.

I've updated the font in master, and it looks like it works - but I may revert that change if I find the bug is actually in the underscore smushing (I have to run some errands but I should be able to tackle this this afternoon).

@patorjk
Copy link
Owner

patorjk commented Jul 23, 2020

So there was a bug, I've updated master. Can you confirm that it works correctly? Here's what the output should be based on the layout rules:

  ______                    _             __
 /_  __/__  _________ ___  (_)___  ____ _/ /
  / / / _ \/ ___/ __ `__ \/ / __ \/ __ `/ / 
 / / /  __/ /  / / / / / / / / / / /_/ / /  
/_/__\___/_/  /_/ /_/ /_/_/_/ /_/\__,_/_/   
  / ____/ /_  ___  __________               
 / /   / __ \/ _ \/ ___/ ___/               
/ /___/ / / /  __(__  |__  )                
\____/_/ /_/\___/____/____/                 
                                            

This is different than the linux version because the linux version doesn't support the full_layout parameter and instead uses the old_layout parameter. Full_layout was added when the figlet creators released FigWin, though that version has long since died and for whatever reason they never updated their linux app (the figlet spec mentions this - that FigWin implements the full spec and the figlet linux app does not. I think maybe they thought FigWin would replace the command line app).

Also, if you want to avoid vertical smushing, you can manually set the vertical layout with verticalLayout (just set it to "fitted" or "full"). Most fonts default to using one of those two values.

@jcubic
Copy link
Contributor Author

jcubic commented Jul 23, 2020

There is one inconsistency maybe another bug you can see in latest code from master https://codepen.io/jcubic/pen/JjGxvMY
I've added few underscores to be sure if it merged (smushed) those lines correctly:

  ______                    _             __         
 /_  __/__  _________ ___  (_)___  ____ _/ /         
  / / / _ \/ ___/ __ `__ \/ / __ \/ __ `/ /          
 / / /  __/ /  / / / / / / / / / / /_/ / /           
/_/  \___/_/  /_/ /_/ /_/_/_/_/_/\__,_/_/            
                          / ____/ /_  ___  __________
                         / /   / __ \/ _ \/ ___/ ___/
                        / /___/ / / /  __(__  |__  ) 
 _______________________\____/_/ /_/\___/____/____/  
/_____/_____/_____/_____/                            
  ______                    _             __               
 /_  __/__  _________ ___  (_)___  ____ _/ /               
  / / / _ \/ ___/ __ `__ \/ / __ \/ __ `/ /                
 / / /  __/ /  / / / / / / / / / / /_/ / /                 
/_/  \___/_/  /_/ /_/ /_/_/_/ /_/\__,_/_/                  
                                 ________                  
                                / ____/ /_  ___  __________
                               / /   / __ \/ _ \/ ___/ ___/
                              / /___/ / / /  __(__  |__  ) 
 _____________________________\____/_/ /_/\___/____/____/  
/_____/_____/_____/_____/_____/

I think that the issue is with a letter in slant font

    _             __                    
   (_)___  ____ _/ /                    
  / / __ \/ __ `/ /                     
 / / / / / /_/ / /                      
/_/_/_/_/\__,_/_/_______________________
  / ____/ /_  _/_____/_____/_____/_____/
 / /   / __ \/ _ \/ ___/ ___/           
/ /___/ / / /  __(__  |__  )            
\____/_/ /_/\___/____/____/

    _             __                    
   (_)___  ____ _/ /                    
  / / __ \/ __ `/ /                     
 / / / / / /_/ / /                      
/_/_/ /_/\__,_/_/_______________________
         ______/_____/_____/_____/_____/
        / ____/ /_  ___  __________     
       / /   / __ \/ _ \/ ___/ ___/     
      / /___/ / / /  __(__  |__  )      
 _____\____/_/ /_/\___/____/____/       
/_____/                   

o looks better then underscore
    _             __                      
   (_)___  ____ _/ /___  ____  ____  ____ 
  / / __ \/ __ `/ / __ \/ __ \/ __ \/ __ \
 / / / / / /_/ / / /_/ / /_/ / /_/ / /_/ /
/_/_/_/_/\__,_/_/\____/\____/\____/\____/ 
  / ____/ /_  ___  __________             
 / /   / __ \/ _ \/ ___/ ___/             
/ /___/ / / /  __(__  |__  )              
\____/_/ /_/\___/____/____/               
                                          
    _             __                      
   (_)___  ____ _/ /___  ____  ____  ____ 
  / / __ \/ __ `/ / __ \/ __ \/ __ \/ __ \
 / / / / / /_/ / / /_/ / /_/ / /_/ / /_/ /
/_/_/ /_/\__,_/_/\____/\____/\____/\____/ 
         ________                         
        / ____/ /_  ___  __________       
       / /   / __ \/ _ \/ ___/ ___/       
      / /___/ / / /  __(__  |__  )        
 _____\____/_/ /_/\___/____/____/         
/_____/                                   

@patorjk
Copy link
Owner

patorjk commented Jul 23, 2020

This looks to be expected. For "Terminal Chess" with 5 underscores, it doesn't merge the lines because the full_layout parameter specifies that it's to use rules 1-3 for vertical smushing:

    Rule 1: EQUAL CHARACTER SMUSHING (code value 1)

        Two sub-characters are smushed into a single sub-character
        if they are the same.  This rule does not smush
        hardblanks.  (See "Hardblanks" below.)

    Rule 2: UNDERSCORE SMUSHING (code value 2)

        An underscore ("_") will be replaced by any of: "|", "/",
        "\", "[", "]", "{", "}", "(", ")", "<" or ">".

    Rule 3: HIERARCHY SMUSHING (code value 4)

        A hierarchy of six classes is used: "|", "/\", "[]", "{}",
        "()", and "<>".  When two smushing sub-characters are
        from different classes, the one from the latter class
        will be used.

A "," plus an "_" doesn't meet any rules for smushing, so the line can't be smushed.

@jcubic
Copy link
Contributor Author

jcubic commented Jul 23, 2020

What about this:

    _             __                      
   (_)___  ____ _/ /___  ____  ____  ____ 
  / / __ \/ __ `/ / __ \/ __ \/ __ \/ __ \
 / / / / / /_/ / / /_/ / /_/ / /_/ / /_/ /
/_/_/_/_/\__,_/_/\____/\____/\____/\____/ 
  / ____/ /_  ___  __________             
 / /   / __ \/ _ \/ ___/ ___/             
/ /___/ / / /  __(__  |__  )              
\____/_/ /_/\___/____/____/               
                                          
    _             __                      
   (_)___  ____ _/ /___  ____  ____  ____ 
  / / __ \/ __ `/ / __ \/ __ \/ __ \/ __ \
 / / / / / /_/ / / /_/ / /_/ / /_/ / /_/ /
/_/_/ /_/\__,_/_/\____/\____/\____/\____/ 
         ________                         
  ____  / ____/ /_  ___  __________       
 / __ \/ /   / __ \/ _ \/ ___/ ___/       
/ /_/ / /___/ / / /  __(__  |__  )        
\____/\____/_/ /_/\___/____/____/         

I've edited previous comment multiple times, one the example show same code but with _ before chess with o it's the same.

@patorjk
Copy link
Owner

patorjk commented Jul 23, 2020

That case is the same as the previous one. "," can take the place of " " with no problem, but "," and "_" can't be smushed together. That's why the first case smushes together a line closer than the second case.

@patorjk patorjk closed this as completed Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants