`space` not working for some fonts
sadrasabouri opened this issue · comments
Description
It seems that newly added feature, sapce
, is not working with some specific fonts.
Steps/Code to Reproduce
>>> Art = text2art("test", "block", space=2)
>>> print(Art)
Expected Behavior
.----------------. .----------------. .----------------. .----------------.
| .--------------. | | .--------------. | | .--------------. | | .--------------. |
| | _________ | | | | _________ | | | | _______ | | | | _________ | |
| | | _ _ | | | | | |_ ___ | | | | | / ___ | | | | | | _ _ | | |
| | |_/ | | \_| | | | | | |_ \_| | | | | | (__ \_| | | | | |_/ | | \_| | |
| | | | | | | | | _| _ | | | | '.___`-. | | | | | | | |
| | _| |_ | | | | _| |___/ | | | | | |`\____) | | | | | _| |_ | |
| | |_____| | | | | |_________| | | | | |_______.' | | | | |_____| | |
| | | | | | | | | | | | | | | |
| '--------------' | | '--------------' | | '--------------' | | '--------------' |
'----------------' '----------------' '----------------' '----------------'
Actual Behavior
.----------------. .----------------. .----------------. .----------------.
| .--------------. || .--------------. || .--------------. || .--------------. |
| | _________ | || | _________ | || | _______ | || | _________ | |
| | | _ _ | | || | |_ ___ | | || | / ___ | | || | | _ _ | | |
| | |_/ | | \_| | || | | |_ \_| | || | | (__ \_| | || | |_/ | | \_| | |
| | | | | || | | _| _ | || | '.___`-. | || | | | | |
| | _| |_ | || | _| |___/ | | || | |`\____) | | || | _| |_ | |
| | |_____| | || | |_________| | || | |_______.' | || | |_____| | |
| | | || | | || | | || | | |
| '--------------' || '--------------' || '--------------' || '--------------' |
'----------------' '----------------' '----------------' '----------------'
@sadrasabouri You can start to work on this issue.
The first step is to find the fonts with this problem and list them.
First I write the below scripts to find out fonts which have problems with space
parameter:
>>> from art import *
>>> for font_name in FONT_NAMES:
... if text2art("test", font_name, space=2) == text2art("test", font_name):
... print(font_name)
...
block
danc4
nvscript
Then I checked them in text_dic*.py
files to find out the problem. It turned out that (' ' - spce) is mapped to ('' - empty string), as it can be seen in from the below script's results:
>>> from art.art_param import FONT_MAP
>>> for font_name, font in FONT_MAP.items():
... if font[0][' '] == '':
... print(font_name)
...
block
danc4
nvscript
So for solving this issue we can fill up the space character's mapping for these fonts {block
, danc4
, nvscript
}.
So for solving this issue we can fill up the space character's mapping for these fonts {
block
,danc4
,nvscript
}.
@sadrasabouri Nice approach 🔥
سلام. چطور میتونم به شما پی ام بدم سوالی درباره یکی از کد هاتون داشتم