Skip to content

Draw emoji in colour in the clip list - #1162

Open
pasharm wants to merge 1 commit into
sabrogden:masterfrom
pasharm:feat/list-colour-emoji
Open

pasharm wants to merge 1 commit into
sabrogden:masterfrom
pasharm:feat/list-colour-emoji

Conversation

@pasharm

@pasharm pasharm commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

This is the first part of #251: emoji in the clip list are drawn in colour. The second part of the issue (rule-based colouring of single-colour characters) is not covered.

Problem

The clip list draws its rows with GDI DrawText. GDI has no colour font support, so emoji from Segoe UI Emoji come out as black-and-white outlines, while the same text is shown in colour in Notepad, the browser or the terminal.

Fix

  • New src/ColorEmojiText.*: ColorEmojiText::DrawColorText draws a row through an ID2D1DCRenderTarget bound to the list DC and DirectWrite with D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT. Font and text colour are taken from the DC, so themes and the list font setting work as before.
  • Only rows that contain emoji-like characters (surrogate pairs, VS16, ZWJ and the BMP emoji ranges) take this path. All other rows, and any DirectWrite failure, keep the existing DrawText call, so ordinary rows look exactly the same.
  • To make an emoji row look like its GDI neighbours, the text layout is GDI-compatible (whole-pixel advances, same line height and tab stops as DrawText with DT_EXPANDTABS) and rendered with DWRITE_RENDERING_MODE_GDI_CLASSIC. The DirectWrite family name is resolved through IDWriteGdiInterop, so faces like "Segoe UI Semibold" map correctly.
  • The render target is software and created once; the text format is cached for the current font and recreated when the font changes.
  • QListCtrl.cpp only gets the call before the existing DrawText.

Not changed: rows drawn by the RichEdit control when "Draw RTF text in list" is on, rows with search highlight (DrawHTML), and the description window. They still show emoji in black and white.

Testing

  • Built with MSBuild CP_Main_10.sln /p:Configuration=Release /p:Platform=x64.
  • The same code has been in my daily build since 2026-09-26 (list of ~5000 clips, dark theme, one and several lines per row): emoji rows are coloured, letters in them match the neighbouring rows, scrolling speed is unchanged, rows without emoji are unchanged.

GDI DrawText renders colour fonts (Segoe UI Emoji) black and white.
Rows whose text contains emoji-like characters are now drawn through an
ID2D1DCRenderTarget + DirectWrite with ENABLE_COLOR_FONT, using a
GDI-compatible layout and GDI classic rendering so ordinary letters in
the row match the GDI rows next to it. Rows without emoji and any
DirectWrite failure keep the old DrawText path.

Not covered: rows drawn by the RichEdit control ("Draw RTF text in
list"), search highlight (DrawHTML), the description window.

Part of sabrogden#251.

This branch has not been deployed

No deployments
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