Repository: shenxiangzhuang/zhplot

Issue:
支持wordcloud显示中文
https://github.com/amueller/word_cloud/blob/ec24191c64570d287032c5a4179c38237cd94043/wordcloud/wordcloud.py#L34

```
os.environ['FONT_PATH'] = f"{os.path.dirname(zhplot.__file__)}/fonts/NotoSansSC-Regular.ttf"
```

Discussion:
coderabbitai[bot]: <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- This is an auto-generated comment: review in progress by coderabbit.ai -->

> [!NOTE]
> Currently processing new changes in this PR. This may take a few minutes, please wait...
> 
> <details>
> <summary>📥 Commits</summary>
> 
> Reviewing files that changed from the base of the PR and between 22bbc7ffd45bc635b4b827adc1d5d46a0adbda98 and f464f2c0466a900f2f2155fbfe0c9f68887ac8ad.
> 
> </details>
> 
> <details>
> <summary>📒 Files selected for processing (3)</summary>
> 
> * `tests/test_wordcloud.py` (1 hunks)
> * `zhplot/__init__.py` (1 hunks)
> * `zhplot/wordcloud.py` (1 hunks)
> 
> </details>
> 
> ```ascii
>  _______________________________________
> < Execute order 66...to purge the bugs. >
>  ---------------------------------------
>   \
>    \   \
>         \ /\
>         ( )
>       .( o ).
> ```

<!-- end of auto-generated comment: review in progress by coderabbit.ai -->

<!-- tips_start -->

---

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Generate unit testing code for this file.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai generate unit testing code for this file.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and generate unit testing code.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR. ([Beta](https://docs.coderabbit.ai/early-access#beta))
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/shenxiangzhuang/zhplot/pull/15?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mathew+Shen) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 100.00%. Comparing base [(`22bbc7f`)](https://app.codecov.io/gh/shenxiangzhuang/zhplot/commit/22bbc7ffd45bc635b4b827adc1d5d46a0adbda98?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mathew+Shen) to head [(`f464f2c`)](https://app.codecov.io/gh/shenxiangzhuang/zhplot/commit/f464f2c0466a900f2f2155fbfe0c9f68887ac8ad?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mathew+Shen).

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff            @@
##            master       #15   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         3    +1     
  Lines           21        28    +7     
=========================================
+ Hits            21        28    +7     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/shenxiangzhuang/zhplot/pull/15?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mathew+Shen).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mathew+Shen).


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 40467b6..81f593f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,10 @@
 
 ## [Unreleased]
 
+### Added
+- Support chinese display in `wordcloud`
+
+
 ## [0.1.1] - 2024-12-01
 
 ### Changed
diff --git a/README.md b/README.md
index b10da4a..16ee578 100644
--- a/README.md
+++ b/README.md
@@ -39,6 +39,10 @@ uv add zhplot
 import matplotlib.pyplot as plt
 ```
 
+### 支持的框架
+- [x] [matplotlib](https://github.com/matplotlib/matplotlib)
+- [x] [wordcloud](https://github.com/amueller/word_cloud)
+
 ### 一个简单的例子
 <div align="center">
     <img src="https://github.com/shenxiangzhuang/zhplot/blob/7569552e07a8b4de7afd8c9df5cbcb154a349e97/docs/images/zhplot_demo.png?raw=true" width="500"/>
@@ -56,6 +60,7 @@ plt.ylabel('纵坐标')
 plt.show()
 ```
 
+
 ## 相似项目
 - [japanize-matplotlib](https://github.com/uehara1414/japanize-matplotlib)
 - [chineseize-matplotlib](https://github.com/cndeng/chineseize-matplotlib)
diff --git a/zhplot/__init__.py b/zhplot/__init__.py
index f754475..f74e3a3 100644
--- a/zhplot/__init__.py
+++ b/zhplot/__init__.py
@@ -1,5 +1,7 @@
 from .matplotlib import matplotlib_chineseize
+from .wordcloud import wordcloud_chineseize
 
 __all__ = [
     "matplotlib_chineseize",
+    "wordcloud_chineseize",
 ]
diff --git a/zhplot/wordcloud.py b/zhplot/wordcloud.py
new file mode 100644
index 0000000..b1152a3
--- /dev/null
+++ b/zhplot/wordcloud.py
@@ -0,0 +1,10 @@
+import os
+from pathlib import Path
+
+
+def wordcloud_chineseize():
+    font_ttf: str = "NotoSansSC-Regular.ttf"
+    os.environ["FONT_PATH"] = f"{Path(__file__).parent}/fonts/{font_ttf}"
+
+
+wordcloud_chineseize()


Test patch:
diff --git a/tests/test_wordcloud.py b/tests/test_wordcloud.py
new file mode 100644
index 0000000..7c87f6d
--- /dev/null
+++ b/tests/test_wordcloud.py
@@ -0,0 +1,10 @@
+import os
+
+import zhplot  # noqa
+
+
+def test_chinese_font_config():
+    """Test if wordcloud is configured to use Chinese fonts."""
+    font_path_env = os.getenv("FONT_PATH")
+    assert font_path_env is not None
+    assert "NotoSansSC-Regular" in font_path_env