Created attachment 76135 [details]
The text in the attached document shows as white in Word 2010, but black in LibreOffice.
The text's colour is set to "automatic". Both Word and LibreOffice interpret this by setting the colour to white on a dark background, and to black on a light background. However they differ in what is considered to be a dark background. This example has a background of dark grey (#333333) which is treated as dark by Word by not by LibreOffice.
Putting compatibility aside, Word's choice just looks better - subjectively this background looks dark, and the white text looks clearer on it than the black text.
I can see from LibreOffice source code that it considers the background to be dark if its luminance is <= 38.
I checked the ECMA-376 specification (4th edition) to see if this defines how automatic font colour should be shown for docx, but all it says is that the consumer can "automatically determine the run color as appropriate", "for example, in order to ensure that the run contents can be distinguished against the page's background color" (from 188.8.131.52).
Created attachment 76136 [details]
matching docx example
Created attachment 76137 [details]
doc example (fixed mime type)
Word 2010 appears to treat a background colour as "dark" if:
130*red + 255*green * 51*blue < 105*255
Where red, green, blue are the RGB components of the background colour as 8-bit integers (ie in the range 0 to 255).
(I arrived at this formula by:
- collecting some data points by experimentation with Word 2010
- guessing the form of this formula
- using linear algebra with the data points to work out the coefficients
- double-checking using more data points)
By comparison, LibreOffice treats a background colour as "dark" if:
28*red + 151*green + 77*blue <= 38*256
(see Color::IsDark() in tools/source/generic/color.cxx, called from SwDrawTextInfo::ApplyAutoColor in sw/source/core/txtnode/fntcache.cxx)
Correction, the LibreOffice formula (from code) is:
77*red + 151*green + 28*blue <= 38*256
I notice that both Word and LibreOffice formulae use weights proportional to the "Rec. 601" coefficients for Luma shown here:
ie Luma = 0.299 R' + 0.587 G' + 0.114 B'
(Actually LibreOffice would match these coefficients more accurately if it used
76*red + 151*green + 29*blue)
Anyway the main difference is that LibreOffice considers Luma <= 38 (out of 255) to be dark, whereas Word considers Luma < about 61 (out of 255) to be dark.
The formula I put forward earlier for Word is very slightly off, because of the following data points:
(red=61, green=61, blue=60) is not dark
(red=60, green=61, blue=61) is dark
Mark it as NEW to 'delete' it from our UNCONFIRMED-list :).
Created attachment 76263 [details]
examples of what is considered "dark" across a range of colours
Adding an example showing visually what is considered "dark" across a range of colours
Luke Deller committed a patch related to this issue.
It has been pushed to "master":
Change definition of "dark" colour for fdo#61993
The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
Affected users are encouraged to test the fix and report feedback.
@Luke: I assume this one can be closed as RESOLVED/FIXED?
Yes thanks Björn, closing it now.