Make Mojave custom dictionaries work better

It’s wonderful when you moan about something here, and someone very kindly comes along and fixes it. That has just happened with the black-and-white patchwork seen in Dark Mode when running custom dictionaries, in the Dictionary app in Mojave.



It turns out that there is a fix for this, although it uses some CSS which is currently private to Apple. In the Finder, open your custom dictionary’s bundle, locate the file DefaultStyle.css, and open it in a text editor. Append to the file’s code the following:
@media (prefers-dark-interface)
html {
-apple-color-filter: apple-invert-lightness();
a {
-apple-color-filter: none;
color: -webkit-link;
img {
filter: invert(100%);


Save that file, and try your custom dictionary again, in Dark Mode.


You should see a more consistent appearance, which switches back properly when you return to Light Mode.


The snag with this code is that it can’t yet be used more widely. This is because it relies on the ‘media query’ of prefers-dark-interface. When Dark Mode is active, this is true, and the style is then set to match that mode. It happens that this media query works with Mojave’s Dictionary app.

I also tried it with HelpViewer, in the hope that this might allow Help books to switch mode properly too, but I couldn’t get it to work there. It is also not supposed to work – yet – with Safari 12. Frank Lämmer discusses it here in more detail.

My other bug-bear is with reading coloured logs and parsed text in Rich Text. Like almost every other RTF viewer/editor, TextEdit displays all documents on a paper-white background. For coloured RTF generated by Consolation 3 from log extracts, and by Nalaprop from parsed texts, there is currently no obvious option to view them in the same Dark Mode in which those apps display them.

I fear that I can feel an RTF viewer app which does switch to Dark Mode properly coming soon in Xcode.

Thanks to Garland who very generously provided this excellent tip.