font模块
font¶
get_chinese_font_path_random
¶
随机获取一个中文字体文件路径, 优先songti
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
字体类型关键字,默认是 "song",可以是 "song" 或 "hei" 等 |
'song'
|
Returns:
| Type | Description |
|---|---|
Optional[Path]
|
Optional[Path]: 随机中文字体文件路径,如果没有找到则返回 None |
Example
Source code in src/cfun/font.py
get_chinese_font_paths
¶
获取当前系统中的中文字体文件路径(支持 Windows、Linux、macOS,自动判断是否可用 fc-list 命令来查找字体
Returns:
| Type | Description |
|---|---|
Dict[str, object]
|
Dict[str, object]: 包含平台、系统类型与字体路径 |
Source code in src/cfun/font.py
get_fixed_fonts
¶
获取固定的中英文字体路径, 根据系统平台自动选择合适的字体路径。 Args: chinese (str): 中文字体关键字, 默认是 "song" (包含 song 的字体, 不区分大小写) english (str): 英文字体关键字, 默认是 "arial" (包含 arial 的字体, 不区分大小写)
Returns:
| Type | Description |
|---|---|
Dict[str, Optional[Path]]
|
Dict[str, Optional[Path]]: 包含中文和英文字体路径的字典 { "chinese": Path对象或None, "english": Path对象或None } |