简体   繁体   English

如何在 pyfiglet python3 中获取所有可用的 fonts

[英]How To Get all the usable fonts in pyfiglet python3

I am using a library called pyfiglet which i installed using pip3 install pyfiglet i want to know if there is a way through which i can get a list of all the fonts which i can use in pyfiglet.figlet_format() like i want to get a list list_of_fonts = [] and in the list i want to get all of the fonts which i can use or which are installed.我正在使用一个名为pyfiglet的库pyfiglet.figlet_format()我使用pip3 install pyfiglet了它列表list_of_fonts = []并在列表中我想获取我可以使用或已安装的所有 fonts。

I am using Debian Linux with Python 3.9我正在使用 Debian Linux 和 Python 3.9

Thanks for answering in advance.感谢您提前回答。

Type this in terminal, it will show all the fonts you can use.在终端中输入这个,它将显示您可以使用的所有 fonts。

pyfiglet -l  

or或者

pyfiglet --list_fonts

In a python file, you can get a fonts list:在 python 文件中,您可以获得 fonts 列表:

import pyfiglet
print(pyfiglet.FigletFont.getFonts())

Adding to @Jacky's answer, if you'd want to visualize how each fonts look, you can run the below for loop.添加到@Jacky 的答案,如果您想可视化每个 fonts 的外观,您可以运行以下 for 循环。

for FONTS in `pyfiglet -l`; do echo $FONTS; pyfiglet $FONTS -f $FONTS; done;

You can pipe the output to a file for later references.您可以将 pipe 和 output 保存到一个文件中以供以后参考。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM