Bug 159541 - Dark background colour ignores fix font color
Summary: Dark background colour ignores fix font color
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: UI (show other bugs)
Version:
(earliest affected)
24.2.0.3 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected
: 159582 159628 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-02-03 14:55 UTC by zaakari
Modified: 2024-02-19 16:20 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
Font effect Outline (8.96 KB, application/vnd.oasis.opendocument.spreadsheet)
2024-02-19 16:20 UTC, raal
Details

Note You need to log in before you can comment on or make changes to this bug.
Description zaakari 2024-02-03 14:55:07 UTC
In the theme colours, changing the font colour doesn't do anything if the background colour is darker than "Light Gray 2". Instead, the font colour is always white.

Steps to reproduce:
1 - Choose: Tools > Options
2 - Under the first list "LibreOffice", select the "Application Colors" set
3 - Under General, change "Document background" to black, and "Font color" to red.
5 - Click "Apply" -> Nothing changes
6 - Change "Document background" to "Light Gray 2" (or higher) -> font colour changes.


I encountered this issue in LibreOffice 24.2.0.3 under Linux. But I also tested it in 24.2.0.3 and 24.8.0.0 under Windows, and it had the same effect (font colour against dark themed background is always white).

Obviously LibreOffice can still be used with this bug, but I find it rather uncomfortable on the eyes given the very high contrast--which leads to making the background colour brighter, which negates the purpose of a dark theme.
Comment 1 zaakari 2024-02-03 14:59:46 UTC
I also tried resetting my profile, but it made no difference.
Comment 2 raal 2024-02-03 17:41:47 UTC
Confirm in Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: b39c6082aa975ed8e5696c3dc24c3025ed07bbb6
CPU threads: 4; OS: Linux 6.5; UI render: default; VCL: gtk3
Locale: cs-CZ (cs_CZ.UTF-8); UI: en-US
Calc: threaded Jumbo


Works in Version: 7.3.7.2 / LibreOffice Community
Build ID: 30(Build:2)
CPU threads: 4; OS: Linux 6.5; UI render: default; VCL: gtk3
Locale: cs-CZ (cs_CZ.UTF-8); UI: cs-CZ
Ubuntu package version: 1:7.3.7-0ubuntu0.22.04.4
Calc: threaded
Comment 3 raal 2024-02-03 17:43:59 UTC
Setting black background and red font doesn't works. Font is white. But for instance setting black background and lime color for font works.
Comment 4 raal 2024-02-03 17:53:00 UTC
This seems to have begun at the below commit in bibisect repository/OS linux-64-24.2.
Adding Cc: to Heiko Tietze ; Could you possibly take a look at this one?
Thanks
 c360bb4042d85a453b2cf898bf815aafb6afd4ad is the first bad commit
commit c360bb4042d85a453b2cf898bf815aafb6afd4ad
Author: Jenkins Build User <tdf@pollux.tdf>
Date:   Sat Jul 15 09:22:37 2023 +0200

    source ddb483509113e469b771320fea52f1b089574021

154352: Resolves tdf#156182 - Automatic text color unreadable with darker cells | https://gerrit.libreoffice.org/c/core/+/154352
Comment 5 Heiko Tietze 2024-02-05 13:58:03 UTC
The default font color is automatic and depend on the background. The mentioned patch changed the calculation when the color is considered to be dark, an improvement for accessibility. You can change the font color in the same dialog or you define it on the paragraph/character style level.

Is there any issue beyond the observation that something has changed?
Comment 6 zaakari 2024-02-06 11:38:52 UTC
Yes, I understand that the automatic font colour adjusts itself based on the background colour--that is definitely a good thing. But I am referring to non-automatic colours getting changed: if you put the background to a dark colour, then change the theme's font colour to a dark or semi-dark colour (non-automatic), then it just gets switched to white anyway (even if you chose blue or red, etc.). Not only is this strange (given that a non-automatic colour whas chosen), it is also inconsistent with how light colours are handled, as one can set the themed font and background colour both to "Light Gray 2" (or higher) and then the text cannot be seen. This however, makes sense to me as the user specifically chose both colours (if he doesn't want the text to be visible, so be it).

But if you just see this as a preference issue, then I can live with changing the font colour at the character level--I just liked to be able to view the document in a different theme without modifying its content (that, and I don't understand why a non-automatic colour is being modified).
Comment 7 Heiko Tietze 2024-02-06 12:33:00 UTC
The actual patch is https://gerrit.libreoffice.org/c/core/+/158024 (the mentioned was reverted). It changed the calculation when a color is treated as dark moving the threshold from black or very dark towards the middle values.

The issue with the font color has always been there and is also present in Calc: if the background is treated as dark and the font color is dark it becomes white, and vice versa, ignoring whether the font color is defined as automatic or a fix value.

For example sc/source/core/data/patattr.cxx ScPatternAttr::fillColor()
Comment 8 Heiko Tietze 2024-02-06 12:37:26 UTC
We have two functions, IsDark() and IsBright() with thresholds of <=156 (62 before) and >=245. Meaning below a contrast of about 60% (25% before) or above 95% we use the defined font color.
Comment 9 Heiko Tietze 2024-02-06 12:44:29 UTC
Tomaz, you made some changes for the mentioned Calc method in https://gerrit.libreoffice.org/c/core/+/154061. Please advise how to proceed.
Comment 10 Tomaz Vajngerl 2024-02-07 07:04:09 UTC
(In reply to Heiko Tietze from comment #9)
> Tomaz, you made some changes for the mentioned Calc method in
> https://gerrit.libreoffice.org/c/core/+/154061. Please advise how to proceed.

I didn't look into this issue - yet. 

My change here was mostly refactoring as we called one GetFont method, which does 2 things - prepares the font and color. But in some cases we only cared about the font and in other cases only about the font color. When we were only interested about the font we called GetFont with SC_AUTOCOL_BLACK (which always changed AUTO to black). I changed this to 2 methods fillFontOnly and fillColor (and fillFont that does both) and then call fillFontOnly() when we were not interested in the color.

Maybe I did a mistake at refactoring? It is possible...
Comment 11 raal 2024-02-07 16:44:07 UTC
*** Bug 159582 has been marked as a duplicate of this bug. ***
Comment 12 ady 2024-02-07 21:46:03 UTC
*** Bug 159628 has been marked as a duplicate of this bug. ***
Comment 13 raal 2024-02-19 16:20:50 UTC
Created attachment 192641 [details]
Font effect Outline

Another problem with the commit is Font effect - outline. See testcase and printscreen from 7.6 and 24.2