Skip to content

feat: add inkml parser and writer #1320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Doublonmousse
Copy link
Collaborator

@Doublonmousse Doublonmousse commented Dec 8, 2024

Related to #744 (import of selected onenote strokes, but exclusive to that. No text nor images are read).

As I'm on windows, I'm using #1282 for now.
The parser/writer crate is on a separate repository here https://github.com/Doublonmousse/writer_reader_inkml

Export and import are supported (from the clipboard).

  • I think it would make sense to move some of the import code inside the engine (conversion from inkml to stroke ?)
  • The export part is only for brush strokes (I could extend it to shapes with lines being the easiest to do, and other shapes would have to be discretized)
  • I'm using the windows equivalent of the mime type for the inkml clipboard export part
  • The crate still needs some polishing (better error message and removing some potentially panic inducing unwrap with error propagation instead).

I've encountered a weird behavior with clipboards in gtk and windows (that ofc I can't reproduce today ...). Copying ink content then an image from a source application wouldn't work as somehow gtk would think the inkml format was still present before failing with a gio quark error.

@Doublonmousse Doublonmousse changed the title add inkml parser feat: add inkml parser and writer Dec 13, 2024
@Doublonmousse
Copy link
Collaborator Author

Doublonmousse commented Dec 30, 2024

It's starting to look somewhat reasonable. I'm still not fully sure the modifications are done in the right place.

And I've encountered again a gtk bug with the clipboard (this time I could reproduce)
Recording 2024-12-30 171734_compress.webm

56.954780700s ERROR rnote::appwindow::actions: Failed to read clipboard data while pasting as inkml, Err: Error { domain: g-io-error-quark, code: 0, message: "Cannot get clipboard data. No compatible transfer format found." }

I wonder if it's possible to refactor the code to try the next mimetype if the first one failed. Though that's ultimately a workaround for a gtk/gio bug (I'll probably try to open a bug report on the gtk or gio gitlab later)

Upstream tracking issue here : https://gitlab.gnome.org/GNOME/gtk/-/issues/7233

@Doublonmousse
Copy link
Collaborator Author

Doublonmousse commented Jul 1, 2025

The issue I had was fixed upstream, so this should be working for gtk 4.20

@Doublonmousse Doublonmousse marked this pull request as ready for review July 18, 2025 13:04
@Doublonmousse Doublonmousse marked this pull request as draft July 18, 2025 13:05
Doublonmousse and others added 3 commits July 18, 2025 15:07
Moving some of the methods closer to the engine for pasting.
Though maybe we should `cfg` between the two ?
- erroneous pressure conversion with unneeded factor
- brush stroke in cm
- ignore pressure correctly (no pressure needed for the const mode)
@Doublonmousse
Copy link
Collaborator Author

One passing though on conversions: I feel like an interface/trait for general conversion could be done.

Also, if it'd be possible to have a minimal rnote library that's just big enough to load rnote files but also create elements and push to the store then save to a rnote file that'd facilitate how to do conversions (and also embed the reader in other contexts)

limitations
- no fill support (not planned)
- moveto should create a new stroke but it doesn't for now
@Doublonmousse
Copy link
Collaborator Author

Implemented shapes export ("rasterized" to lines) using the outline_path method + a couple of fixes
I need to retest on windows to verify everything is fine with import/export from/to onenote/journal/office.

I'm also encountering some weird behavior for rendering. When doing a roundtrip (copy from rnote, then modify the clipboard to only keep the inkml content then pasting again), the arrow should not display correctly (as I'm currently doing it in one stroke vs taking into account the MoveTo as an indication to do a new stroke) but it does
image
If I remove the start,
image

A pasted polygon (so represented as a brushstroke here !) can "lose" a side when seen from further away
image
image

@Doublonmousse
Copy link
Collaborator Author

Doublonmousse commented Jul 22, 2025

Re tested on windows with journal/onenote/word and everything works as expected (including shapes).

Export to journal doesn't take the inkml format but prefers the png (edit: retested and it outputs inkml but the reverse is false, only ISF would work on implrt).

Now there may also be some annoyances here (if I prefer inkml over other clipboard format, I may miss on images ..). Though apart from a copy as/paste as function I'm not sure it can be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant