Skip to content

Feature: Highlighter that works on PDFs#1602

Open
Keschler wants to merge 13 commits into
flxzt:mainfrom
Keschler:copilot-highlighter
Open

Feature: Highlighter that works on PDFs#1602
Keschler wants to merge 13 commits into
flxzt:mainfrom
Keschler:copilot-highlighter

Conversation

@Keschler

Copy link
Copy Markdown
Contributor

Creates a new type of brush: Highlighter

Addresses: #449

I added a new Highlighter brush designed for highlighting text on PDFs or notes. It features a pipeline to handle transparency correctly and includes an auto-straightening helper for cleaner lines.

Technical Implementation:

  • New Layering: Added a PDFHighlighter layer to StrokeLayer
  • Auto-Straighten: Added logic to detect roughly straight strokes and replace them with a single straight line automatically.

To fix Alpha-Accumulation

  1. Stroke is first drawn at 100% opacity
  2. Once the stroke is rasterized into an image, the alpha is applied

Demo:
Highlighter rnote

Disclaimer: This implementation was primarily generated with the assistance of GitHub Copilot.

@Keschler

Keschler commented Dec 3, 2025

Copy link
Copy Markdown
Contributor Author

I just realized a similar highlighter exists #1210, but my implementation still seems useful, because it is easier to find and usable as a pen instead of a shape.

An useful addition could be to modify the transparency/opacity

@NXTler

NXTler commented Dec 9, 2025

Copy link
Copy Markdown

I agree. Although the shape is nice, the pen is what I'm most likely to use. Is the Auto-Straighten feature for all pens, or just for the highlighter?

@Keschler

Keschler commented Dec 9, 2025

Copy link
Copy Markdown
Contributor Author

Just for the highlighter right now

self.brush_config.solid_options.stroke_color = Some(stroke_color);
self.brush_config.textured_options.stroke_color = Some(stroke_color);
let mut highlight_color = stroke_color;
highlight_color.a = 0.2;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of hardcoding this value, please put it into a descriptively named associated constant of PensConfig and use it here

@Keschler

Keschler commented Feb 9, 2026

Copy link
Copy Markdown
Contributor Author

@flxzt Is it now ready to get merged?

@Xyndra

Xyndra commented Feb 9, 2026

Copy link
Copy Markdown

I also have a branch with a highlighter and other features here: https://github.com/Xyndra/rnote/tree/highlighter that I have simply used for myself, maybe that could be interesting to look at. It would also be nice if you could send a screenshot of how it looks when things overlap, either in the same or multiple strokes

@evanwporter

Copy link
Copy Markdown

Does this lock onto text automatically if the pdf encoding allows that?

@Keschler

Copy link
Copy Markdown
Contributor Author

No, not yet

@Keschler
Keschler requested a review from flxzt March 10, 2026 19:54
@Patrice115

Copy link
Copy Markdown

hi, i would like to use your addon. I missing a Highlighter since switching from GoodNotes to Rnote. The Problem is, my Knowledge about Rust is close 2 zero. Would you be so kind to help me, install your addon?

@Kneemund

Kneemund commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator

What is the difference between the added PDFHighlighter and the existing Highlighter (Marker)?

As far as I can tell, the PDFHighlighter is the same thing with a workaround for transparent stroke rendering, line straightening, and a hardcoded alpha value. I believe that we should fix transparent stroke rendering everywhere, not just here.

EDIT: I've created #1729 with a fix for transparent strokes, and #1730 that makes strokes with the existing Highlighter/Marker multiplicative.

@Keschler

Keschler commented Apr 9, 2026

Copy link
Copy Markdown
Contributor Author

You're right. #1730 already looks really good and we could just use your #1729 so no new pen must be added

@Karuto2k7

Karuto2k7 commented Apr 12, 2026

Copy link
Copy Markdown

You're right. #1730 already looks really good and we could just use your #1729 so no new pen must be added

I think the highlighter as pen fixed the transparency than brushes, For me, fixed the transparency on brushes can make easier than custom something
(something can change: add the highlighter and brushes out side the box (It's easier and faster to use))

@Xyndra

Xyndra commented Apr 12, 2026

Copy link
Copy Markdown

yeah I would strongly prefer a seperate highlighter tool, otherwise it's terrible UX

@evanwporter

evanwporter commented Apr 12, 2026 via email

Copy link
Copy Markdown

@Kneemund

Kneemund commented Apr 12, 2026

Copy link
Copy Markdown
Collaborator

yeah I would strongly prefer a seperate highlighter tool, otherwise it's terrible UX

I disagree, the semantic difference is not that large (assuming that you mean a tool in the bottom bar). Most of the UI in the sidebar would be exactly the same.

I would simply expand the brush style menu into linked GtkToggleButtons, so that it looks like the selector/eraser style picker. But that should probably be done in a separate PR.

EDIT: It could look something like this.

grafik

Splitting up the highlighter and regular brush styles could make sense if we had more than three... But even then, we could simply use a separator in the sidebar.

@Xyndra

Xyndra commented Apr 13, 2026

Copy link
Copy Markdown

I implore you to take a look at my fork where I also have a highlighter tool in a branch

@Kneemund

Copy link
Copy Markdown
Collaborator

I did take a look, and I'm not really convinced. In terms of input (and concept), the highlighter fits very well into the existing brush tool. In your branch, the UI elements in the sidebar of the highlighter and brush are pretty much identical.

The only advantage of a separate tool that I can think of is that you can register a shortcut for it. And I guess you'd need marginally less time when you have to switch both the tool and the brush style. In my opinion, both things currently don't justify duplicating the UI

@Xyndra

Xyndra commented Apr 13, 2026

Copy link
Copy Markdown

It isn't about the timing, it's about me wanting to have different sizes for my highlighter, wanting some options about transparency and corner shapes, wanting some other colors and generally highlighters and pens are in fact not used for the same stuff. A pen is for thin lines, a marker is for large areas. If you look at any other drawing application, they all also have them separate, because for that reasoning you could just as well have the eraser be part of the pen as well

@Kneemund

Kneemund commented Apr 13, 2026

Copy link
Copy Markdown
Collaborator

it's about me wanting to have different sizes for my highlighter

You can, the size is already tied to the brush style.

wanting some options about transparency and corner shapes

There is already a configuration menu with options specific to the brush style. It even has the same position as the one in your branch :P

pens are in fact not used for the same stuff. A pen is for thin lines, a marker is for large areas. If you look at any other drawing application, they all also have them separate, because for that reasoning you could just as well have the eraser be part of the pen as well

The difference between highlighters and other brush styles is certainly not as big as between the other tools. Besides that, wouldn't a very similar reasoning also apply to the textured brush style? In my opinion, the similarities significantly outweigh the differences, but I've already explained why I think so in my previous comments.

@Karuto2k7

Karuto2k7 commented Apr 17, 2026

Copy link
Copy Markdown

@Keschler This brush have something issue when my computer render this line (Something slowly, and sometimes rnote crash when I use that)

Screencast.From.2026-04-17.23-38-31.mp4

@Ringbaer

This comment has been minimized.

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.

10 participants