w:color='auto'

J

Jialiang Ge [MSFT]

Hello Dave,

It's hard to tell how Word picks the color when w:color val is set to
"auto". I will consult the corresponding developers and get back to you
soon. But why don't you set val="auto" in your program and leave the job to
Word?

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 
J

Jialiang Ge [MSFT]

Hello Dave,

Based on my further tests, I find Word uses one of the following two system
colors for "auto":

SystemColors.Window
SystemColors.WindowText

Word choses one that is more visible according to the background color. I
am asking the product team for more information about how Word makes the
choice. I will get back to you as soon as possible.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 
J

Jialiang Ge [MSFT]

Hello Dave,

Word's algorithm is that if the calculated luminance value is less than
approximately 30% of maximum, we consider it to be a "dark" color and use
the lighter text color "SystemColors.Window" to contrast with it.

RGB Luminance value = 0.3 R + 0.59 G + 0.11 B

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 
J

Jialiang Ge [MSFT]

Hello Dave,

I think the test still fits the rule in my last reply:

1. if background's luminance < 30%, the background is considered as dark,
and the fore text color will be white
Thus, w:fill="cb0000" is considered as a dark color, and the text color is
shown in white.

2. if background's luminance > 30%, the background is considered as light,
and the fore text color will be black
Thus, w:fill="cc0000" is considered as a light color, and the text color is
shown in black.

Why do you think it should stay white up to w:fill="ff0000"? ff0000 is a
light background, and the text color should be black then.

Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 
T

Tony Jollans

That is very interesting. I have often wondered about Word's algorithms.

That formula is a very poor one for determining luminance, but even if it
were good, 30% luminace is a low value for switching to a dark text - if,
indeed, checking luminance alone is really sufficient.

Also the threshold appears to be around 25% rather than 30%. Of course, I
could be somehow misinterpreting the formula - it is strange that 0.3 + 0.59
+ 0.11 = exactly 1.

Regardless of my interpretations, Word makes a poor choice on many
backgrounds.
 
J

Jialiang Ge [MSFT]

Hello Dave,

The Word team told me that they cannot share the internal algorithms/codes
about how Word determines if the backcolor is dark or light, but we can
adjust the threshold luminance to get closer to the internal number. Based
on our further tests, we find a cutoff of 25% rather than the 30% will be
proper:

0.299 0.587 0.114 0.25
Color R G B Y Pred Actual
Red 255 0 0 0.299 Black Black
DRed 192 0 0 0.225 White White
LGreen 146 208 80 0.686 Black Black
Green 0 176 80 0.441 Black Black
Blue 0 112 192 0.344 Black Black
DBlue 0 32 96 0.117 White White
Purple 112 48 160 0.313 Black Black
Cust 203 0 0 0.238 White White

The CB0000 case is the last one shown, with a calculated luminance of .238,
less than the threshold 0.25, so Word switches to White.

If you have any other concerns or questions, feel free to let me know.

Have a nice weekend!

Regards
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 
T

Tony Jollans

I would have to disagree that this should be in the spec. This is a
presentation issue, rather than a document content one.

In the absence of a formal definition of "automatic", it is reasonable to
take it to mean contrasting. Defining it more specifically would mean that
every consumer of OXML documents would be obliged to use Word's algorithms
and there ought to be scope for another application to use a better one -
and even perhaps for future applications to be free to use different colours
for different media.

Incidentally, I'm going to write up a bit about this because Word seems to
get thoroughly confused if Windows colours are changed.
 
D

David Thielen

I agree that auto can mean contrast it and in that respect it should be open
to implementation.

With that said, for many large organizations, governments as well as
companies, what is critical is that programs can read the file and produce
the exact same document. Now granted, white vs black text is a very minor
detail in that - but it is part of that requirement.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
T

Tony Jollans

... what is critical is that programs can read the file and produce
the exact same document.

That is never going to happen with auto as it depends on Windows colours. If
an explicit colour is wanted, an explicit colour should be used. However ...

.... the same holds true for all sorts of aspects of Word documents
(templates, styles, new themes, printer drivers) that affect the
presentation - if precise replication is required, Word is not the consumer
tool to use - and, indeed, OXML is probably not the format.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top