docs.rs failed to build poster_generator-0.1.2
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Poster Generator
一个基于 Rust 和 Skia Safe 的海报生成库,支持 RTL (从右到左) 文本渲染,适用于阿拉伯语、希伯来语、波斯语和维吾尔语等语言。
A poster generation library based on Skia Safe with RTL (Right-to-Left) text support for Arabic, Hebrew, Persian, and Uyghur languages.
特性 Features
- ✅ 创建可配置宽高的海报 / Customizable canvas size
- ✅ 背景元素(颜色或图片),支持圆角 / Background with colors, images, and rounded corners
- ✅ 图片元素:
- 位置设置(x, y 坐标)/ Positioning (x, y coordinates)
- 尺寸设置(宽度,高度)/ Sizing (width, height)
- 圆角 / Rounded corners
- 图片适应模式(cover, contain, stretch)/ Object fit modes
- z-index 层级 / Z-index layering
- ✅ 文本元素:
- 位置和尺寸设置 / Positioning and sizing
- 字体样式(大小,颜色,加粗)/ Font styling (size, color, bold)
- 文本对齐方式(左对齐,居中,右对齐)/ Text alignment (left, center, right)
- 多行文本自动换行和行高控制 / Multi-line text with automatic wrapping
- 最大行数限制,超出自动添加省略号 / Max lines with ellipsis
- 文本背景色,内边距和圆角 / Text background with padding and border radius
- z-index 层级 / Z-index layering
- 支持从右往左(RTL)的文本渲染 / RTL text rendering support
- ✅ 输出为 PNG 文件或 base64 编码字符串 / Export as PNG file or base64 string
安装 Installation
作为库使用 As a Library
将以下内容添加到你的 Cargo.toml:
[]
= "0.1"
或使用 cargo add:
命令行工具 CLI Tool
使用方法 Usage
作为库 As a Library
use ;
RTL 文本示例 RTL Text Example
use ;
命令行使用 CLI Usage
# 从 JSON 配置文件生成海报
# 生成 base64 输出
# 运行示例
JSON 配置格式 JSON Configuration
RTL 文本支持 RTL Text Support
本库自动检测并支持以下语言的 RTL 文本渲染:
This library automatically detects and supports RTL text rendering for:
- 阿拉伯语 Arabic: مرحبا بالعالم
- 波斯语 Persian: سلام دنیا
- 维吾尔语 Uyghur: ئۇيغۇر تىلى، سالام دۇنيا
- 希伯来语 Hebrew: שלום עולם
RTL 配置要点 RTL Configuration Tips
- 自动检测 Auto-detection: 系统会自动检测文本中的 RTL 字符 / System automatically detects RTL characters
- 手动指定 Manual specification: 可通过
direction: "rtl"手动指定 / Usedirection: "rtl"to manually specify - 字体选择 Font selection: 系统自动选择支持的字体,也可通过
font_family指定 / System auto-selects fonts, or specify viafont_family - 对齐方式 Alignment: RTL 文本通常使用
align: "right"或align: "center"/ RTL text usually uses right or center alignment
依赖 Dependencies
- skia-safe: Skia 图形库的 Rust 绑定 / Rust bindings for Skia graphics library
- serde/serde_json: JSON 序列化支持 / JSON serialization
- base64: Base64 编码支持 / Base64 encoding
- anyhow/thiserror: 错误处理 / Error handling
文档 Documentation
完整 API 文档请访问 docs.rs
For complete API documentation, visit docs.rs
许可证 License
MIT License - 详见 LICENSE 文件
MIT License - See LICENSE file for details
贡献 Contributing
欢迎贡献!请随时提交 Pull Request。
Contributions are welcome! Feel free to submit a Pull Request.