nb-codeoutline
nb-codeoutline copied to clipboard
Improve scaling quality for files with many lines
Currently (v1.3), text in different text lines appear to have a different height -- probably an artifact of the scaling algorithm used. It would be nice if the font size could be configured such that each text lines takes up an equal integral number of pixels in height (like for example 2 pixels or 3 pixels). Or else use a "smoother" scaling algorithm (e.g. bicubic).
fixed in 1.3.1
@nmatt: Try 1.3.1 and give me feedback https://github.com/markiewb/nb-codeoutline/releases/tag/v1.3.1
It's improved, but there is still some strange moiréing going on. To illustrate, here is an example with 300 identical lines filled with "M":
It looks a bit like the scaling is skipping certain rendered text pixel lines, so sometimes it only picks up the middle of the text line (=black) and sometimes only the space between text lines (=white).
Here is the same content scaled with Gimp to the same height (using "Cubic" interpolation):
Strange. I will have a look. Perhaps I should disable anti-aliasing before scaling
Yes it looks strange. I can reproduce it. There is some logic regarding height.
If you like, you can debug it and fix it. https://github.com/markiewb/nb-codeoutline/blob/master/src/main/java/bluej/editor/moe/NaviView.java
Did you tried http://docs.oracle.com/javase/tutorial/2d/advanced/quality.html ?
Ok, the way it is currently implemented, i.e. rendering the text at a very small size into a buffer with the same height as the target area, probably can't ever look right. This is because the text rendering logic will render the text line by line into the buffer, where each line has only a fractional pixel height. This can't possibly produce high-quality results.
What needs to be done is to render the text into a much larger buffer, so that each text line is rendered with multiple pixels in height (preferably an integral (non-fractional) number of pixels to avoid aliasing differences between lines), and then scale this buffer down into the target graphics context. For very large files (10.000's of lines or more), this probably should be done in chunks to avoid out-of-memory due to buffer size.
Perhaps that is the reason, why Sublime only shows font-size=1 lines?
@p2rkw: Thanks for the note. It is already used - see https://github.com/markiewb/nb-codeoutline/blob/master/src/main/java/bluej/editor/moe/NaviView.java#L627
I won't invest time to fix this issue. I am not using this plugin that often. Thank you for your understanding.
If you like to get it fixed, please provide a pullrequest! I would be happy to integrate it!
The relevant source file is https://github.com/markiewb/nb-codeoutline/blob/master/src/main/java/bluej/editor/moe/NaviView.java