Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
The FarsiWordCloud
class is a specialized extension of the Fonts
class designed to generate word clouds in Farsi (Persian) text. It handles text reshaping and bidirectional text rendering to ensure that Farsi text is correctly displayed in the word cloud.
To use the FarsiWordCloud
class, you need to have the following libraries installed:
matplotlib
wordcloud
arabic_reshaper
bidi
You can install these libraries using pip:
pip install matplotlib wordcloud arabic-reshaper python-bidi
Here is an example of how to use the FarsiWordCloud
class:
from FarsiWordCloud import FarsiWordCloud
# Sample text in Farsi
text = "سلام این یک تست برای ایجاد واژهابری است."
# Create an instance of FarsiWordCloud
wordcloud = FarsiWordCloud(
text=text,
font_name="BYekan", # Specify the font name from the available fonts
width=800,
height=400,
background_color='white',
max_font_size=250,
min_font_size=10
)
# Generate the word cloud
wordcloud.generate_wordcloud()
# Display the word cloud
wordcloud.show_wordcloud()
# Save the word cloud to a file
wordcloud.save_wordcloud(filename='farsi_wordcloud.png')
info.json
file.reshape_text(self)
Reshapes and reorders the Farsi text to ensure correct display. This method uses the arabic_reshaper
library to reshape the text and the bidi
library to handle bidirectional text.
generate_wordcloud(self)
Generates the word cloud from the reshaped text. This method creates a WordCloud
object with the specified parameters and generates the word cloud image.
show_wordcloud(self)
Displays the generated word cloud using matplotlib
. If the word cloud has not been generated yet, this method will call generate_wordcloud()
first.
save_wordcloud(self, filename='wordcloud.png')
Saves the generated word cloud to a file. The default filename is wordcloud.png
, but you can specify a different filename if desired.
The FarsiWordCloud
class relies on a set of fonts specified in the fonts/info.json
file. Ensure that the font files listed in this file are available in the fonts/files/
directory.
This project is licensed under the MIT License. See the LICENSE file for details.
FAQs
A package to generate Farsi word clouds with proper text rendering.
We found that farsi-wordcloud demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.