Bug 158989 - FILEOPEN: Light text color in textbox instead of dark, until RT
Summary: FILEOPEN: Light text color in textbox instead of dark, until RT
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
24.8.0.0 alpha0+
Hardware: All All
: medium minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected, regression
: 159983 160719 (view as bug list)
Depends on:
Blocks: DOCX-Textbox
  Show dependency treegraph
 
Reported: 2024-01-02 18:04 UTC by Xisco Faulí
Modified: 2024-08-30 06:09 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
Comparsion LibreOffice 24.8 master vs MSO (135.10 KB, image/png)
2024-01-03 09:55 UTC, Xisco Faulí
Details
Test document (14.64 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2024-01-04 10:59 UTC, Heiko Tietze
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Xisco Faulí 2024-01-02 18:04:30 UTC
Steps to reproduce:
1. Open attachment 91446 [details] from bug 73247

-> Text is white. It should be black instead

Reproduced in

Version: 24.2.0.0.beta1+ (X86_64) / LibreOffice Community
Build ID: 0034d2ab9382da86340738137218791a4ccc9c90
CPU threads: 8; OS: Linux 6.1; UI render: default; VCL: gtk3
Locale: fr-FR (es_ES.UTF-8); UI: en-US
Calc: threaded

[Bug found by office-interoperability-tools]
Comment 1 Xisco Faulí 2024-01-02 18:04:59 UTC
Regression introduced by:

author	Heiko Tietze <heiko.tietze@documentfoundation.org>	2023-07-12 12:52:39 +0200
committer	Heiko Tietze <heiko.tietze@documentfoundation.org>	2023-07-15 08:33:55 +0200
commit ddb483509113e469b771320fea52f1b089574021 (patch)
tree fea1e840da8295bde9eeb7d1b58817a41cbad08e
parent 693411e60c6bbd1c2ef25490cc3902f6b2461682 (diff)
Resolves tdf#156182 - Automatic text color unreadable with darker cells
Comment 2 Heiko Tietze 2024-01-03 09:07:34 UTC Comment hidden (obsolete)
Comment 3 Xisco Faulí 2024-01-03 09:55:15 UTC
Created attachment 191724 [details]
Comparsion LibreOffice 24.8 master vs MSO
Comment 4 Xisco Faulí 2024-01-03 09:56:59 UTC
(In reply to Heiko Tietze from comment #2)
> It's an intentional consequence of the new contrast calculation. The first
> color in the gradient #956748 vs. #FFFFFF is 4.87:1 while vs. #000000 it was
> 4.31:1. => NAB

then the intentional consequence is wrong. The text in MSO is black and the same should be in LibreOffice since it's a DOCX file
Comment 5 Heiko Tietze 2024-01-03 10:05:58 UTC
We likely do not use the same calculation in case of automatic colors. But I wonder how things work for solid colors (the automatic apparently takes just the first color into account).
Comment 6 Xisco Faulí 2024-01-04 10:49:12 UTC
Same issue with attachment 98729 [details] from bug 78469
Comment 7 Heiko Tietze 2024-01-04 10:59:59 UTC
Created attachment 191753 [details]
Test document

But previously we used black font on the default Tango Sky Blue background which is now calculated as white, the same on MSO.
Comment 8 Michael Weghorn 2024-01-10 09:16:42 UTC
Without any formal spec/definition of when to consider a color light or dark, I don't see a way to say for sure what's the "correct" behavior, since that's basically undefined.

Some questions to which I don't have an answer:

Should LO always do the same as MSO? (And does MSO even do the same across different versions?)
Or just when using OOXML docs? (I'd personally tend to be in favor of consistency across file formats.)
Or should LO use an algorithm that tries to ensure a proper contrast ratio, as Heiko's commit does?

tdf#61993 looks related and has some notes on what formula MSO might be using.
Comment 9 Heiko Tietze 2024-01-10 10:53:19 UTC
(In reply to Luke Deller from bug 61993 comment 3)
> Word 2010 appears to treat a background colour as "dark" if:
> 130*red + 255*green * 51*blue < 105*255

My first patch used the w3 algorithm from https://www.w3.org/TR/AERT/#color-contrast
return sal_uInt8((R * 299UL + G * 587UL + B * 114UL) / 1000);

with IsDark() GetRelativeLuminance() <= 128; and IsBright() GetRelativeLuminance() >= 200;

Don't remember why I rejected this solution, maybe because of this reply:
(In reply to Myndex from comment #6)
> Case 5 is an obsolete and incorrect WCAG 1.0 attempt at something...

The alleged MSO function makes no difference to what we had in the past. But if I use a black cell background in Excel 365 the automatic font color is still black. Don't want to fix their problems, though.

By the way, the default color Tango Sky Blue / 0x729fcf is calculated extra with the legacy calculation.
Comment 10 Mike Kaganski 2024-06-01 12:30:14 UTC
*** Bug 159983 has been marked as a duplicate of this bug. ***
Comment 11 Mike Kaganski 2024-06-01 12:30:19 UTC
*** Bug 160719 has been marked as a duplicate of this bug. ***
Comment 12 Mike Kaganski 2024-06-01 12:36:50 UTC
To comment 8:

When opening MS Office documents, it is *definitely* a valid assumption that we must show the same as MSO. We need a very good reason to deliberately decide to differ.

When opening *own* existing files, we may want to consider the fact, that such changes are in fact *breaking* changes, i.e. they break someone's existing document. So one option is a compat flag, even if the changed algorithm will break less existing documents.
Comment 13 Eyal Rozenberg 2024-06-01 16:40:13 UTC
(In reply to Mike Kaganski from comment #12)
> When opening MS Office documents, it is *definitely* a valid assumption that
> we must show the same as MSO. We need a very good reason to deliberately
> decide to differ.

Well, suppose there's a bug in MSO, which causes a calculated color to be black rather than white... 

But I do agree that, when it's not too much trouble, we should by default aim for "bug-to-bug compatibility" with MSO when opening DOCX files.
Comment 14 Eyal Rozenberg 2024-06-01 16:42:07 UTC
(In reply to Eyal Rozenberg from comment #13)

... but also note that our current behavior is wrong also in the absolute sense, as pointed out in my dupe bug 160719.
Comment 15 Timur 2024-08-30 06:08:49 UTC
In 25.2 text is still white on open, but dark on RT (save, reopen).