Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ CLI notes
- `render-svg --stdout`: write SVG documents to stdout instead of files; status messages go to stderr.
- `--help`: show supported options and whether the current build uses embedded fonts.
- `--color` / `--background-color` accept named colors (for example `black`, `red`, `teal`), 3- or 6-digit hex (`#f00`, `#ff0000`), and KaTeX / MathJax-style color model values (`[RGB]255,0,0`, `[rgb]1,0,0`, `[HTML]B22222`, `[gray]0.5`, `[cmyk]0,1,1,0`).
- `--padding <SIZE>` sets the base padding on each side for PNG and SVG output. The effective padding is scaled by `--dpr`.
- `render-svg --office-compatible-colors`: emit SVG paint colors as `rgb(...)` plus opacity attributes instead of the default `rgba(...)`, for Office versions that do not understand `rgba(...)` in SVG.
- `ratex-render --background-color transparent` produces a transparent PNG.

Expand Down
1 change: 1 addition & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ CLI 说明
- `render-svg --stdout`:将 SVG 文档写到 stdout,而不是文件;状态信息写到 stderr。
- `--help`:查看当前二进制支持的选项,以及当前构建是否启用了嵌入字体。
- `--color` / `--background-color` 支持命名颜色(如 `black`、`red`、`teal`)、三位或六位十六进制(如 `#f00`、`#ff0000`)、以及 KaTeX / MathJax 风格的颜色模型写法(如 `[RGB]255,0,0`、`[rgb]1,0,0`、`[HTML]B22222`、`[gray]0.5`、`[cmyk]0,1,1,0`)。
- `--padding <SIZE>`:设置 PNG 和 SVG 输出四周的基础空白边距。实际边距会随 `--dpr` 缩放。
- `render-svg --office-compatible-colors`:将 SVG 颜色写成 `rgb(...)` 加 opacity 属性,而不是默认的 `rgba(...)`,用于不识别 SVG `rgba(...)` 的 Office 版本。
- `ratex-render` 的 `--background-color transparent` 可输出透明背景 PNG。

Expand Down
10 changes: 9 additions & 1 deletion crates/ratex-render/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ fn main() {
.and_then(|s| s.parse::<f32>().ok())
.unwrap_or(40.0);

let padding = args
.iter()
.position(|a| a == "--padding")
.and_then(|i| args.get(i + 1))
.and_then(|s| s.parse::<f32>().ok())
Comment thread
Tao-Boy marked this conversation as resolved.
Comment thread
Tao-Boy marked this conversation as resolved.
.unwrap_or(10.0);

let color = args
.iter()
.position(|a| a == "--color")
Expand Down Expand Up @@ -81,7 +88,7 @@ fn main() {

let options = RenderOptions {
font_size,
padding: 10.0,
padding,
background_color,
font_dir,
device_pixel_ratio,
Expand Down Expand Up @@ -204,6 +211,7 @@ Options:
{font_dir_option} --output-dir <DIR> Write PNGs to this directory [default: output]
--dpr <FACTOR> Render scale factor [default: 1.0]
--font-size <SIZE> Base font size in pixels [default: 40.0]
--padding <SIZE> Base padding on each side in pixels [default: 10.0]
--color <COLOR> Formula color: named, #rgb, #rgba, #rrggbb,
#rrggbbaa, or [MODEL]value
[default: black]
Expand Down
10 changes: 9 additions & 1 deletion crates/ratex-svg/src/bin/render_svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ fn main() {
.and_then(|s| s.parse::<f64>().ok())
.unwrap_or(40.0);

let padding = args
.iter()
.position(|a| a == "--padding")
.and_then(|i| args.get(i + 1))
.and_then(|s| s.parse::<f64>().ok())
Comment thread
Tao-Boy marked this conversation as resolved.
Comment thread
Tao-Boy marked this conversation as resolved.
.unwrap_or(10.0);

let color = args
.iter()
.position(|a| a == "--color")
Expand All @@ -80,7 +87,7 @@ fn main() {
let dpr = device_pixel_ratio.clamp(0.01, 16.0) as f64;
let svg_opts = SvgOptions {
font_size: font_size * dpr,
padding: 10.0 * dpr,
padding: padding * dpr,
stroke_width: 1.5 * dpr,
embed_glyphs: true,
font_dir,
Expand Down Expand Up @@ -218,6 +225,7 @@ Options:
--stdout Write SVGs to stdout instead of files
--dpr <FACTOR> Scale font size, padding, and stroke width [default: 1.0]
--font-size <SIZE> Base SVG font size in user units [default: 40.0]
--padding <SIZE> Base padding on each side in user units [default: 10.0]
--color <COLOR> Formula color: named, #rgb, #rgba, #rrggbb, #rrggbbaa,
or [MODEL]value
[default: black]
Expand Down
Loading