Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
ab01fa0
feat(crates/panache-mcp): 在原纸上等比排字并对照字体和图文笔迹
SXP-Simon Nov 27, 2026
f6e761a
feat(crates/handwriting-core): 让流程图标签和线框使用正文字体与笔宽
SXP-Simon Nov 27, 2026
e04015e
feat(crates/panache-mcp): 建稿与预览时提示原纸清晰度和笔画复核
SXP-Simon Nov 27, 2026
498d347
docs(crates/panache-mcp): 提醒在照片横线上核对流程图箭杆
SXP-Simon Nov 27, 2026
bc03690
feat(crates/handwriting-core): 让跨越纸面深浅区域的笔迹逐渐过渡
SXP-Simon Nov 27, 2026
a08ab26
feat(crates/panache-mcp): 支持原尺寸预览与 PNG 导出柔化
SXP-Simon Nov 27, 2026
ecf319c
fix(crates/panache-mcp): 核对照片页首和过渡行的局部墨色
SXP-Simon Nov 27, 2026
761a081
feat(crates/panache-mcp): 按照片上的两个位置渐变柔化 PNG
SXP-Simon Nov 27, 2026
9fd58c6
feat(app/widgets): 在纸张面板配置并预览 PNG 成稿柔化
SXP-Simon Nov 27, 2026
95a95c0
feat(crates/panache-mcp): 在纸面复查中给出两处清晰与渐变预览
SXP-Simon Nov 27, 2026
3c2fa8f
fix(app/models): 比较 PNG 柔化时固定清晰档笔迹
SXP-Simon Nov 27, 2026
8128c20
fix(app/screens): 精修 PDF 直接使用当前稿件导出
SXP-Simon Nov 27, 2026
071f5f3
feat(crates/panache-mcp): 按原纸透视复查并整体定位图形
SXP-Simon Nov 27, 2026
3ff79f2
docs: 展示 MCP 在实拍白纸上的手写作业
SXP-Simon Nov 27, 2026
7a24c94
docs: 调整模拟理工科作业的展示文案
SXP-Simon Nov 27, 2026
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## 未发布

- 工作台切换清晰、均匀和渐变 PNG 时复用相同笔迹,方便在原位置比较柔化效果。
- 精修后的 PDF 可直接导出并保留字形调整,即使 PNG 渐变的起点和终点暂时重合。

- Linux x64 桌面包固定在 Ubuntu 24.04 构建,修复随包渲染服务与 MCP 在 Debian 13 上因要求 GLIBC_2.43 而无法启动的问题。

- 上传底纸后,纸张设置会直接显示从照片读到的制造商、设备型号、镜头和 ISO,缺少的项目仍可手动补填。
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ For text alone, paste the passage and say whether you want a printable page, wri

[Handwritten poem](assets/examples/spring-at-qiantang-lake-6806782d66f9.webp)

### Handwriting on photographed paper

Panache's MCP server laid out a sample STEM assignment on two photos of unruled paper. Select a page to open the full-resolution PNG.

| Unruled paper on a wooden desk | Paper in shadow beside a flower |
| --- | --- |
| [![Handwritten code, basic blocks and a flowchart aligned with a tilted sheet on a wooden desk](assets/examples/angled-sheet-5ad065421e7c.webp)](https://raw.githubusercontent.com/SXP-Simon/Panache/922b6c7303c6a1d86271e42929bb316eb9c953bb/screenshots/worksheet-lettering/round-7/worksheet.png) | [![Handwritten assignment and flowchart on a shaded sheet with a flower overlapping the right edge](assets/examples/flower-shadow-a07835481c3a.webp)](https://raw.githubusercontent.com/SXP-Simon/Panache/1aea40070e551868368842392ca349a823d95de0/screenshots/worksheet-lettering/round-8/worksheet.png) |

Original photographs · [Kaboompics](https://www.pexels.com/photo/empty-paper-sheet-on-wooden-table-4207708/) · [Andrzej Gdula](https://www.pexels.com/photo/white-printer-paper-on-brown-wooden-table-11485123/)

## Contributing

Report bugs in [GitHub Issues](https://github.com/SXP-Simon/Panache/issues). For local setup, tests, and pull requests, see [CONTRIBUTING.md](CONTRIBUTING.md).
Expand Down
10 changes: 10 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ Windows、macOS 和 Linux 桌面版随附本地 MCP 服务。在 **应用设置

[《钱塘湖春行》](assets/examples/spring-at-qiantang-lake-6806782d66f9.webp)

### 在纸张照片上排版手写作业

一道模拟理工科作业,分别用 MCP 排在两张无横线的纸张照片上。点击成稿可查看原尺寸 PNG。

| 斜拍的无横线白纸 | 花影下的白纸 |
| --- | --- |
| [![木桌上的斜拍白纸,手写代码、基本块与流程图沿纸边排列](assets/examples/angled-sheet-5ad065421e7c.webp)](https://raw.githubusercontent.com/SXP-Simon/Panache/922b6c7303c6a1d86271e42929bb316eb9c953bb/screenshots/worksheet-lettering/round-7/worksheet.png) | [![花头遮住部分右侧纸边,手写作业与流程图避开花头](assets/examples/flower-shadow-a07835481c3a.webp)](https://raw.githubusercontent.com/SXP-Simon/Panache/1aea40070e551868368842392ca349a823d95de0/screenshots/worksheet-lettering/round-8/worksheet.png) |

底图摄影 · [Kaboompics](https://www.pexels.com/photo/empty-paper-sheet-on-wooden-table-4207708/) · [Andrzej Gdula](https://www.pexels.com/photo/white-printer-paper-on-brown-wooden-table-11485123/)

## 参与贡献

遇到问题可以到 [GitHub Issues](https://github.com/SXP-Simon/Panache/issues) 反馈。本地开发、测试和提交 PR 的说明见[贡献指南](CONTRIBUTING.md#中文贡献指南)。
Expand Down
13 changes: 13 additions & 0 deletions app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
{
"@@locale": "en",
"pngBlur": "PNG finish",
"pngBlurHint": "Soften the paper and ink together in previews, single PNGs and ZIP exports.",
"pngBlurOff": "Off",
"pngBlurUniform": "Uniform",
"pngBlurGradient": "Two-point gradient",
"pngBlurFrom": "Start A",
"pngBlurTo": "End B",
"pngBlurStrength": "Blur strength",
"pngBlurX": "Horizontal position",
"pngBlurY": "Vertical position",
"pngBlurTap": "Tap the page to move the selected point.",
"pngBlurDistinct": "Choose different start and end positions.",
"pngBlurFineHint": "To move or resize a letter, select Off above, then choose Fine edit in the preview.",
"pdfImport": "Import PDF",
"pdfText": "Extract plain text",
"pdfTextHint": "Open selectable text in the workbench editor and reflow it on the current paper.",
Expand Down
13 changes: 13 additions & 0 deletions app/lib/l10n/app_zh.arb
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
{
"@@locale": "zh",
"pngBlur": "PNG 成稿柔化",
"pngBlurHint": "柔化合成后的纸张与笔迹,适用于预览、单页 PNG 和 ZIP。",
"pngBlurOff": "关闭",
"pngBlurUniform": "均匀",
"pngBlurGradient": "两点渐变",
"pngBlurFrom": "起点 A",
"pngBlurTo": "终点 B",
"pngBlurStrength": "柔化强度",
"pngBlurX": "横向位置",
"pngBlurY": "纵向位置",
"pngBlurTap": "点按纸面可移动选中的点。",
"pngBlurDistinct": "起点和终点需要分开。",
"pngBlurFineHint": "想移动某个字或改它的大小?先在上方选「关闭」,再到预览区点「精细编辑」。",
"pdfImport": "导入 PDF",
"pdfText": "提取纯文字",
"pdfTextHint": "把可复制的文字放入工作台编辑器,使用当前纸张重新排版。",
Expand Down
64 changes: 64 additions & 0 deletions app/lib/models/png_blur.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import 'dart:convert';

enum PngBlurMode { off, uniform, gradient }

class BlurAnchor {
BlurAnchor(this.x, this.y, this.sigma);
double x, y, sigma;

Map<String, double> toJson() => {'x': x, 'y': y, 'sigma_px': sigma};

static BlurAnchor? parse(Object? value) {
if (value case {'x': num x, 'y': num y, 'sigma_px': num sigma}
when x >= 0 && x <= 1 && y >= 0 && y <= 1 && sigma >= 0 && sigma <= 2) {
return BlurAnchor(x.toDouble(), y.toDouble(), sigma.toDouble());
}
return null;
}
}

class PngBlur {
PngBlurMode mode = PngBlurMode.off;
double uniform = .6;
BlurAnchor from = BlurAnchor(.5, 0, 1.2), to = BlurAnchor(.5, 1, 0);

bool get valid =>
mode != PngBlurMode.gradient || from.x != to.x || from.y != to.y;
bool get active => switch (mode) {
PngBlurMode.off => false,
PngBlurMode.uniform => uniform > 0,
PngBlurMode.gradient => from.sigma > 0 || to.sigma > 0,
};

Map<String, Object> toJson() => {
'mode': mode.name,
'uniform': uniform,
'from': from.toJson(),
'to': to.toJson(),
};

static PngBlur restore(Object? data) {
final blur = PngBlur();
if (data is! Map) return blur;
blur.mode =
PngBlurMode.values.where((m) => m.name == data['mode']).firstOrNull ??
PngBlurMode.off;
if (data['uniform'] case num v when v >= 0 && v <= 2) {
blur.uniform = v.toDouble();
}
blur.from = BlurAnchor.parse(data['from']) ?? blur.from;
blur.to = BlurAnchor.parse(data['to']) ?? blur.to;
return blur;
}

Map<String, String> get fields => switch (mode) {
PngBlurMode.off => {},
PngBlurMode.uniform => {'export_blur_px': '$uniform'},
PngBlurMode.gradient => {
'export_blur_gradient': jsonEncode({
'from': from.toJson(),
'to': to.toJson(),
}),
},
};
}
6 changes: 6 additions & 0 deletions app/lib/models/settings.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'ink_page.dart';
import 'png_blur.dart';
import 'render_parameter.dart';

export 'render_parameter.dart';
Expand All @@ -7,6 +8,7 @@ enum PaperStyle { blank, ruled, grid, dots }

class Settings {
Settings();
PngBlur pngBlur = PngBlur();

/// A portrait exercise-book page sized for comfortable mobile previews.
/// The usable area targets about twenty CJK characters and sixteen lines;
Expand Down Expand Up @@ -104,6 +106,7 @@ class Settings {
Map<String, dynamic> toJson() => {
...values,
...camera,
'pngBlur': pngBlur.toJson(),
'fill': fill,
'layoutStyle': layoutStyle,
'font_option': font,
Expand All @@ -126,6 +129,7 @@ class Settings {
for (final entry in legacyFields.entries)
if (json.containsKey(entry.key)) entry.value: json[entry.key],
};
pngBlur = PngBlur.restore(json['pngBlur']);
_restoreCamera(json);
for (final p in [...parameters, ...inkParameters]) {
final value = p.valueFromDraft(json[p.key]);
Expand Down Expand Up @@ -197,7 +201,9 @@ class Settings {
String text, {
required bool preview,
required bool pdf,
bool supportsPngBlur = true,
}) => {
if (!pdf && supportsPngBlur) ...{'seed': '0', ...pngBlur.fields},
...values,
...camera,
if (!strikethroughEnabled) 'strikethrough_probability': '0',
Expand Down
14 changes: 10 additions & 4 deletions app/lib/screens/workbench.dart
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,9 @@ class _WorkbenchState extends State<Workbench> with WidgetsBindingObserver {

void notify(String message) {
if (mounted) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(message)));
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text(message)));
}
}

Expand Down Expand Up @@ -447,7 +448,8 @@ class _WorkbenchState extends State<Workbench> with WidgetsBindingObserver {
return;
}
w.text = editor.text;
if (!preview && w.finePreviewNeedsRefresh) {
// PDF renders the current layout and its keyed fine edits in one request.
if (!preview && !pdf && w.finePreviewNeedsRefresh) {
livePreview.markSubmitted(w.editRevision);
final refreshed = await w.generate();
if (!mounted || !refreshed || w.previewStale) return;
Expand Down Expand Up @@ -767,6 +769,7 @@ class _WorkbenchState extends State<Workbench> with WidgetsBindingObserver {
fontFile: w.fontFile,
background: w.background,
settingsRevision: settingsRevision,
supportsPngBlur: w.api.supportsPngBlur,
locked: editingLocked,
activeSection: settingsSection,
onSectionChanged: wide ? null : selectSettingsSection,
Expand Down Expand Up @@ -873,7 +876,10 @@ class _WorkbenchState extends State<Workbench> with WidgetsBindingObserver {
pages: w.pages,
inkPages: w.inkPages,
inkLook: w.settings.inkLook,
onFineEdit: w.api.supportsFineEdit && editor.text.trim().isNotEmpty
onFineEdit:
!w.pngBlurActive &&
w.api.supportsFineEdit &&
editor.text.trim().isNotEmpty
? enterFineEdit
: null,
fineAdjustments: w.fineAdjustments,
Expand Down
5 changes: 5 additions & 0 deletions app/lib/services/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,16 @@ class HandwritingApi {
bool get supportsCancel => _supportsCancel;
bool supportsLocalFonts = false;
bool supportsFineEdit = false;
bool supportsPngBlur = false;
void configureCapabilities(dynamic info) {
supportsLocalFonts =
info is Map &&
info['capabilities'] is Map &&
info['capabilities']['local_fonts'] == true;
supportsPngBlur =
info is Map &&
info['capabilities'] is Map &&
info['capabilities']['export_blur'] == true;
supportsFineEdit =
info is Map &&
info['capabilities'] is Map &&
Expand Down
4 changes: 3 additions & 1 deletion app/lib/services/engine_contract.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ class EngineInfo {
required this.canCancel,
required this.canChooseTaskId,
this.canFineEdit = false,
this.canBlurPng = false,
this.canListLocalFonts = false,
});
final String version;
final bool canCancel, canChooseTaskId;
final bool canFineEdit, canListLocalFonts;
final bool canFineEdit, canListLocalFonts, canBlurPng;
factory EngineInfo.fromJson(Map<String, dynamic> value) {
final capabilities = value['capabilities'];
return EngineInfo(
Expand All @@ -77,6 +78,7 @@ class EngineInfo {
capabilities is Map && capabilities['task_submission_id'] == true,
canListLocalFonts:
capabilities is Map && capabilities['local_fonts'] == true,
canBlurPng: capabilities is Map && capabilities['export_blur'] == true,
canFineEdit: capabilities is Map && capabilities['fine_edit'] == true,
);
}
Expand Down
1 change: 1 addition & 0 deletions app/lib/services/engine_gateway.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ApiEngineGateway implements EngineGateway, EngineCatalog {
'capabilities': {
'task_cancellation': info.canCancel,
'task_submission_id': info.canChooseTaskId,
'export_blur': info.canBlurPng,
'fine_edit': info.canFineEdit,
'local_fonts': info.canListLocalFonts,
},
Expand Down
7 changes: 5 additions & 2 deletions app/lib/services/workspace.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Workspace extends ChangeNotifier {
Settings settings;
String text = '', version = '';
bool fineEnabled = false;
bool get pngBlurActive => api.supportsPngBlur && settings.pngBlur.active;
final _fineHistory = FineEditHistory();
String? get _finePageKey => inkPages.elementAtOrNull(page)?.fine?.key;
bool get canFineUndo => _fineHistory.canStep(text, _finePageKey, redo: false);
Expand Down Expand Up @@ -285,7 +286,7 @@ class Workspace extends ChangeNotifier {

void edit({bool inkOnly = false}) {
if (disposed) return;
if (!inkOnly || !initialized) ++_editRevision;
if (!inkOnly || pngBlurActive || !initialized) ++_editRevision;
if (inkOnly) exportBytes = null;
saveTimer?.cancel();
saveTimer = Timer(const Duration(milliseconds: 400), persist);
Expand Down Expand Up @@ -384,6 +385,7 @@ class Workspace extends ChangeNotifier {
}
if (text.trim().isEmpty ||
!settings.valid ||
(!pdf && api.supportsPngBlur && !settings.pngBlur.valid) ||
(fontFile == null && settings.font == null)) {
if (!live) {
error = 'validation';
Expand All @@ -396,12 +398,13 @@ class Workspace extends ChangeNotifier {
expandImages(text, images),
preview: preview,
pdf: pdf,
supportsPngBlur: api.supportsPngBlur,
);
if (fineEnabled && api.supportsFineEdit) {
fields['fine_edit'] = 'true';
fields['seed'] = '0';
final fineEdits = _fineHistory.forText(text);
if (!preview && fineEdits != null) {
if ((!preview || pngBlurActive) && fineEdits != null) {
fields['fine_edits'] = jsonEncode(fineEdits.toJson());
}
}
Expand Down
6 changes: 6 additions & 0 deletions app/lib/widgets/settings/paper_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import '../../models/upload.dart';
import '../../utils/paper_exif.dart';
import '../paper_style_picker.dart';
import 'settings_fields.dart';
import 'png_blur_settings.dart';

List<Widget> paperSettings(
AppLocalizations l,
SettingsFields fields, {
required Upload? background,
required bool supportsPngBlur,
required VoidCallback onUploadBackground,
required VoidCallback onRemoveBackground,
required VoidCallback onDetectBackground,
Expand Down Expand Up @@ -78,6 +80,10 @@ List<Widget> paperSettings(
),
if (background != null) _paperCamera(l, fields, background),
], collapsible: false),
if (supportsPngBlur)
settingsGroup('png-blur', l.pngBlur, Icons.blur_on, [
PngBlurSettings(fields: fields, background: background),
], collapsible: false),
settingsGroup('dimensions', l.paperSizeAndMargins, Icons.space_bar, [
fields.parameterGrid(
parameters.where(
Expand Down
Loading
Loading