Repository navigation
feat(tools): Annotate tool - #1024
lightscape-jm wants to merge 2 commits into
Conversation
Pen lines, arrows, boxes, highlights, text labels and numbered callouts
drawn on pictures, saved as "{name} Annotated" through an ordinary
conversion in the picture's own format. One SkiaSharp painter draws the
marks for the window and the file, so the preview is the file. In the
palette only; settings schema 59.
Closes KnifeLemon#877
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Skia's Linux build here finds fonts by family name but never by letter: MatchCharacter returns null even with a Korean font installed, so a label in Korean was drawn in the default font as empty boxes (CI on Ubuntu 24.04: 85.96 px against 48.96 px for "Save" alone). When MatchCharacter finds nothing, the installed families are looked through for one that has the letter, sans-serif first, and the answer is kept. The yellow number's check looks for dark ink across the whole circle, not one row: DejaVu Serif Bold, Linux's default bold here, has a thin diagonal in its 7 that the middle row crossed at 137. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Linux CI failure: cause and fix (commit The Ubuntu 24.04 jobs failed on Cause: with
Fix: when With that passing, the same test reached a check of the yellow number's dark ink, which sampled one row. On Linux the default bold font is DejaVu Serif Bold, whose "7" has a thin diagonal that row crossed at 137 (the bar is < 80). The check now looks across the whole circle, with the same bar. Annotate's engine tests (7) and window and palette tests (20) pass in the container, and on macOS. Possibly affected elsewhere (not changed in this PR):
Happy to open an issue for the PDF one if it's useful. |
What does this change?
Closes #877. Adds Annotate, a palette tool that draws pen lines, arrows, boxes, highlights, text labels and numbered callouts on pictures, as planned in #856 (step 4, after the preview fix in #987). It is in the palette's Edit tab for pictures, not on a default donut.
How it's built (also in
docs/ARCHITECTURE.md→ Annotate tool):Engines/Annotations/AnnotationPainter(SkiaSharp) draws the marks in the window, on Avalonia's own Skia canvas throughISkiaSharpApiLeaseFeature, and in the file, whereAnnotatorpaints a layer the size of the picture inImageEncoder.ApplyOptions, after hidden areas. So the preview is the file.ImageOptions.Annotations: points are parts of the picture and sizes parts of its shorter side, so marks look the same at any size. The enums read leniently. The marks count inReworksPixels, so they are applied once, in the first transform step.AnnotationSetkeeps the marks, the selection and undo / redo, with a drag as one step.AnnotationCanvasdoes the drawing, hit testing and handles.Compatibility: the built-in
tool-annotatecomes with settings schema 59 (UserDataStoreadds it to existing libraries, in the palette only). I can renumber it if another change takes 59 first. An older Filee doesn't know the tool and opens nothing for it, as thePreset.Toolnote says. SkiaSharp is already a dependency, so nothing new is added.Type of change
How was it tested?
dotnet format --verify-no-changesdotnet test: Core, Cli and Platform pass, and all the Annotate tests in App, Core and Engines pass. On my Mac, 6 Engines tests (FFmpeg without some encoders, LibreOffice) and 10 App tests (engine-page renders andA_lost_animation_frame_does_not_keep_the_slice_dark) fail the same way on unmodifiedmain. I didn't run the Windows installer (Setup) tests.main, from the palette's Edit tab on a screenshot of a statement:New tests:
AnnotationTests(6)AnnotateToolTests(1)AnnotateWindowTests(8)Screenshots (UI changes)
The window with a mark from each tool, and the saved file (the same as in #877):
Checklist
src/Filee.App/Assets/i18n/*.jsonfiles (24 strings, translated in every language)THIRD-PARTY-NOTICES.md(none: SkiaSharp is listed already)🤖 Generated with Claude Code