Files
cadcraft/docs/plotters.md
T
midasdfandmidasdf 758dc4e805 Plot: JIS B4/B5/B6 and Japanese paper sizes (はがき・封筒・四六判) (#1810)
* Plot: JIS B4/B5/B6 and Japanese paper sizes

Japanese drafting uses the JIS B series: B4 257×364 mm, B5 182×257 mm and
B6 128×182 mm. The paper table only had the ISO sizes, so a JIS B5 drawing
plotted about 7 mm short in each direction. B4/B5/B6 are now the JIS sizes (the
names Japanese Excel and drawings use) and the ISO ones stay reachable as
`B4 (ISO)`/`B5 (ISO)`; a drawing that stored the ISO sheet keeps its stored
size, and a caller that means ISO B5 says so.

Adds the Japanese papers the table lacked: Japanese Postcard (はがき,
100×148 mm), Japanese Double Postcard (往復はがき, 148×200 mm), Japanese
Envelope #3 (長形3号, 120×235 mm), Japanese Envelope Kaku #2 (角形2号,
240×332 mm) and 四六判 (127×188 mm). A6 was already an ISO sheet.

Paper names resolve case-insensitively and ignore spaces, hyphens, underscores
and parentheses (`B5 (JIS)`, `b5-jis`, `b5jis`), with the Japanese spellings as
aliases too (`はがき`, `往復はがき`, `長形3号`, `角形2号`, `四六判`). The
built-in plotters and the Page Setup/Plot paper combo pick the new sizes up
from PAPER_SIZES, and the PDF plot's MediaBox and the plot preview use them.

Tests: the render paper test pins every new size and alias, the ISO sizes keep
their values and the unknown-name fallback is unchanged; a new io test pins the
PDF MediaBox for each new paper (JIS B5 515.91×728.50 pt, はがき 283.46×419.53 pt,
ISO B4/B5 and the rest), and the plot-preview test checks that `B5` resolves to
JIS B5 and `B5 (ISO)` to ISO B5.

Docs: docs/plotters.md standard sizes and the `pagesetup`/PDFBOOK parameter
notes, and ROADMAP.md progress log + revision history, dated 2026-10-21.

* Plot: B4/B5/B6 stay ISO; JIS sizes by explicit name

Review follow-up: making the bare names mean JIS changed the ISO sizes for
every user. `B4`/`B5` are the ISO sizes again, an ISO B6 row (125×176 mm)
completes the bare series, and the JIS sheets (JIS P 0138, 257×364,
182×257 and 128×182 mm) are reachable only as `B4 (JIS)`/`JIS B4`,
`B5 (JIS)`/`JIS B5` and `B6 (JIS)`/`JIS B6`.

Drop the ambiguous bare `Postcard` and `Double Postcard` aliases; the name
and はがき/往復はがき say which postcard is meant. Drop the ROADMAP.md edit
(ROADMAP.md stays at origin/main's content).

The render and io paper tests, the plot-preview test and docs/plotters.md
follow the new mapping; the Japanese stationery sizes and their はがき/
往復はがき/長形3号/角形2号/四六判 spellings are unchanged.

Still safe for stored papers: a page setup keeps the canonical paper name
with its width/height, DXF groups 44/45 round-trip those sizes, and the ISO
canonical names (and the JIS rows by name) did not change.

* Plot: full-width paper names resolve like their ASCII forms

A Japanese keyboard or IME gives B5 (JIS); fold U+FF01..U+FF5E to ASCII (and the
ideographic space to a space) before the existing normalisation, with a test.

---------

Co-authored-by: midasdf <midasdf@tutamail.com>
2026-11-30 03:40:20 +01:00

144 lines
6.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Plotters
A plotter (output device) decides what a plot writes and on which paper sizes. Page setups
and plots pick a device and one of its papers. Each paper carries margins, which bound its
printable area. Layouts show the printable area as a dashed outline on the sheet.
## Devices
The built-in devices come first:
| Device | Output |
|---|---|
| `CADCraft PDF` | vector PDF |
| `CADCraft PNG` | raster PNG on white paper at the device resolution (300 dpi) |
| `CADCraft SVG` | vector SVG |
They offer the standard sizes:
- ISO 216 A0–A6 and B0–B6
- JIS B4–B6 (JIS P 0138) by explicit name: `B4 (JIS)`/`JIS B4`, `B5 (JIS)`/`JIS B5` and
`B6 (JIS)`/`JIS B6` (257×364, 182×257 and 128×182 mm). The bare `B4`/`B5`/`B6` stay the ISO
sizes (250×353, 176×250 and 125×176 mm)
- Japanese stationery: Japanese Postcard (はがき, 100×148 mm), Japanese Double Postcard (往復はがき,
148×200 mm), Japanese Envelope #3 (長形3号, 120×235 mm), Japanese Envelope Kaku #2 (角形2号,
240×332 mm) and 四六判 (127×188 mm)
- ANSI A–E and Legal
- ARCH A–E and E1
Metric sheets (ISO and JIS) have 5 mm margins, inch sheets have quarter-inch (6.35 mm) margins.
A page setup with the device `None` plots to PDF on the page setup's paper, as before. Paper names
resolve case-insensitively and ignore spaces, hyphens and parentheses (`B5 (JIS)`, `b5-jis`,
`はがき`).
`B4`/`B5` keep meaning the ISO sizes, so a drawing or caller that used them doesn't change; a plot
that means JIS B4/B5 says `B4 (JIS)`/`B5 (JIS)`. A drawing keeps the sheet size it stored.
User devices are files in our own format, kept in the `plotters` folder of the CADCraft
settings directory:
| System | Folder |
|---|---|
| Linux and FreeBSD | `$XDG_CONFIG_HOME/cadcraft/plotters` or `~/.config/cadcraft/plotters` |
| macOS | `~/Library/Application Support/CADCraft/plotters` |
| Windows | `%APPDATA%\CADCraft\plotters` |
`CADCRAFT_CONFIG_DIR` replaces the settings directory; empty means none (`cadcraft-cli`:
`--config-dir`, which falls back to the same variable). On the web, devices last for the
session unless the host provides storage (`cmd::plotters::set_plotter_store`). Binary `.pc3`
files are not read; we haven't found a public specification of that format.
## Files
`<name>.plotter.json`, UTF-8 JSON with a format marker:
```json
{
"cadcraftPlotter": 1,
"name": "Office A3",
"description": "Raster proofs",
"output": "png",
"resolution": 150,
"orientation": "landscape",
"defaultPaper": "A3 borderless",
"papers": [
{ "name": "A3 borderless", "width": 297, "height": 420, "margins": [0, 0, 0, 0] },
{ "name": "ISO A4 (210.00 x 297.00 MM)", "width": 210, "height": 297, "margins": [5, 5, 5, 5] }
]
}
```
- `output` is `pdf`, `png` or `svg`.
- `resolution` is in dots per inch (50–2400) and applies to PNG.
- `orientation` (`portrait` or `landscape`) is used when a page setup switches to the device.
- Paper sizes are in millimetres on the portrait sheet. `margins` are left, bottom, right and
top, in mm.
Reading fixes hostile values:
- Sizes are kept within 1–5080 mm, and width and height are swapped to portrait.
- Margins are kept within 0–1000 mm. Margins that leave no printable area are dropped.
- Paper names are unique, and a device keeps at most 512 papers.
- A missing or unknown `defaultPaper` becomes the first paper.
- Files over 1 MB are refused.
In the file name, characters other than letters, digits, spaces and `-_()+,` become `_`.
## Commands
- `plottermanager {action, …}` (also **File ▸ Plotter Manager...**) manages the devices:
- `list` (the default) shows the built-in devices first.
- `get {name}` returns a device.
- `new {name, from?, output?, …}` copies `from`, or the built-in device for `output` with
the standard papers.
- `set {name, description?, output?, resolution?, orientation?, defaultPaper?, paper?: {name,
width, height, margins?}, removePaper?}` edits a device. `paper` adds a paper or replaces
the one of that name.
- `delete {name}` removes a device.
- `load {text, name?}` stores a device file's contents.
- `save {name, path?}` writes the file to `path`, or returns it as `text`.
Built-in devices can't be edited or deleted.
- Typed `PLOTTERMANAGER` or `-PLOTTERMANAGER` prompts for an option:
- `?` lists the devices.
- `New` asks for a name and an output (`Pdf`, `PNg`, `Svg`).
- `Delete` asks for a device.
- `Paper` asks for a device, a paper name and `width,height` in mm, and adds that paper.
- `pagesetup {layout, device, paper?}` sets the layout's device. `paper` names one of the
device's papers, or a standard size by its short name (`A3`, `Letter`). The paper's
margins become the layout's printable area. Without `paper`, a device change keeps the
current paper if the device has it, else takes the device's default paper. A device change
also takes the device's orientation unless `landscape` is given. `device: "None"` clears it.
- `plot {device?, paper?, …}` plots with `device`, or with the layout's page setup device.
- The device sets the output and resolution.
- `paper` (one of the device's papers) sets the size and margins for this plot.
- A model-space plot without `paper` uses the device's default paper and orientation.
- For Model plots, `center` defaults to `true`, preserving the existing centered output. Set
`center: false` with `offset: [x, y]` to place the plotted bounds' lower-left corner from the
printable area's lower-left origin; offsets are millimetres, default to `[0, 0]`, and are
bounded to ±100,000 mm. PDF and PNG support these controls. SVG plots keep their extents view;
an active offset is rejected rather than ignored. Layout plots do not use model offsets.
- `exportpdf` takes the same options and always writes PDF.
Model-space PDF plots apply the device paper's margins as the printable area (#633; `io/src/pdf.rs`),
as PNG plots do. SVG plots show a layout's whole sheet, or the model-space extents.
## Plot transparency
Objects plot with their transparency (their own, their layer's when ByLayer, the block
reference's when ByBlock) only when asked, as in AutoCAD:
- `pagesetup {layout, plotTransparency: bool}` stores the layout's "Plot transparency" (off by
default). The Page Setup Manager and the Plot dialog have the checkbox.
- `plot {plotTransparency?: bool}` (and `exportpdf`, `preview`) overrides it for one plot.
Model-space plots have it off unless asked.
- `PLOTTRANSPARENCYOVERRIDE` decides first: 0 never plots transparency, 1 (default) uses the
setting above, 2 always plots it.
PDF plots write it as alpha (`/ExtGState` with `/ca` and `/CA`), PNG plots blend it, SVG plots use
`opacity`. A plot without transparency is written exactly as before. The DXF plot layout flags
have no bit for the option, so it isn't saved in DXF or DWG files.
On screen, `TRANSPARENCYDISPLAY` (on by default; the status bar's Transparency button) shows
transparency; PNG and SVG exports of a drawing always draw it.