Antialias line drawing characters
ClosedPublic

Authored by pbraun on Oct 3 2018, 9:54 AM.

Details

Summary

BUG: 397985

Use antialiasing when drawing unicode box characters to improve the
rendering of rounded corners.

Test Plan
  1. Execute echo -e '\u256d\u256e\n\u2570\u256f'
  2. The box should have rounded corners

Before fix:

After fix:

Diff Detail

Repository
R319 Konsole
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
pbraun created this revision.Oct 3 2018, 9:54 AM
Restricted Application added a subscriber: konsole-devel. · View Herald TranscriptOct 3 2018, 9:54 AM
pbraun requested review of this revision.Oct 3 2018, 9:54 AM

Could you add a screenshot to the Test Plan section?

I suspect that the test fix should be done in a separate patch, too.

pbraun edited the summary of this revision. (Show Details)Oct 3 2018, 3:42 PM
pbraun updated this revision to Diff 42801.Oct 3 2018, 3:45 PM

@ngraham Sure, I added screenshots of the change and removed the unit test fix. Will create a separate patch for that.

pbraun edited the summary of this revision. (Show Details)Oct 3 2018, 3:46 PM
pbraun edited the test plan for this revision. (Show Details)
pbraun edited the summary of this revision. (Show Details)

Thanks, looks great! Can confirm the fix myself. Nice work.

hindenburg accepted this revision.Oct 6 2018, 4:31 PM

Thanks

This revision is now accepted and ready to land.Oct 6 2018, 4:31 PM
hindenburg edited the summary of this revision. (Show Details)Oct 6 2018, 4:33 PM
This revision was automatically updated to reflect the committed changes.
cfeck added a subscriber: cfeck.Oct 7 2018, 12:24 AM

Kurt, please use 'git commit --author=...' to give proper attribution to patches from contributors.

The lines look blurred, are they rendered using integer coordinates? If yes, they end up between pixels, instead of centered in a pixel.

pbraun added a comment.Oct 7 2018, 8:19 AM

Yes, it looks like integers are used to draw line chars: https://cgit.kde.org/konsole.git/tree/src/TerminalDisplay.cpp#n613

Let me try to change it float and see if that fixes the blurriness.

Kurt, please use 'git commit --author=...' to give proper attribution to patches from contributors.

Thanks for the reminder. I wish arc had a way to notify me when landing that the author isn't correct.

sandsmark added a subscriber: sandsmark.EditedOct 8 2018, 12:35 PM

there's some new ugly artifacts between linechars now:

seems to still appear if I change to float.

this is how it looks without enabling antialiasing:

and this shouldn't be enabled if TerminalDisplay::antialias() is false anyways, I guess.

cfeck added a comment.Oct 8 2018, 1:26 PM

Converting int to float does not make lines appear at pixel centers. They need to be shifted by 0.5 pixels in each direction.

I tried a few more things. Unfortunately i've not been able to get rid of the blurriness, even when shifting by 0.5 pixels. To avoid the ugly artifacts i'm now only using antialiasing to draw the rounded corner characters and shift them by 1 pixel. It's still not pretty though:

Also, i will enable this only when the antialiasing() property is set. Let me know what you think. Alternatively we could also revert this change and live with the ugly but at least sharp corners on smaller font sizes.

I think it makes sense to revert to drawing the box chars without anti-aliasing. using the box chars in the font itself is supposed to be the right and pretty way, so I think it's a fair tradeoff to let the built-in box chars look a bit uglier but more correct. or something like that.