Skip to content

Draw the mark under a misspelled word instead of Qt. - #346

Open
ilya-fedin wants to merge 1 commit into
desktop-app:masterfrom
ilya-fedin:spellcheck-mark
Open

Draw the mark under a misspelled word instead of Qt.#346
ilya-fedin wants to merge 1 commit into
desktop-app:masterfrom
ilya-fedin:spellcheck-mark

Conversation

@ilya-fedin

Copy link
Copy Markdown
Contributor

The mark under a misspelled word is drawn by Qt today, and only looks the way it
should because the official builds patch drawTextItemDecoration() to replace
QTextCharFormat::SpellCheckUnderline with the mark Chrome draws. On an
unpatched Qt - which is what distribution builds use - the same code gives a
plain wave, and the platform theme has nothing better to offer either: the base
implementation answers WaveUnderline and only cocoa overrides it.

So the field draws the mark itself now. A range is marked with a new format
property, InputField::kMisspelledProperty, and paintMisspelled() walks the
visible blocks, finds those ranges in QTextLayout::formats() and fills the
descender under them with a tile taken from QPixmapCache. The tile is the same
one the patch generated - a wave elsewhere, a row of dots on macOS.

One difference from the patch is deliberate: the tile is made for the device
pixel ratio of the widget, while the patch always made it for a ratio of one and
let the painter scale it up. Measured in a field with the default style, against
the patched Qt drawing the same mark:

  • at a ratio of 1 the two are the same - 28 pixels, ink 15.32 against 15.30;
  • at a ratio of 2 this one is one device row taller and denser (175 pixels
    against 156), because it is rasterized at the resolution of the screen instead
    of being stretched from half of it.

Needs desktop-app/lib_spellcheck#35, which marks the ranges with the property
instead of the underline style.

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