Repository: microsoft/terminal (language: cpp)

Issue:
[1.17] Tab text may be illegible if you switch to light theme 



Discussion / hints:
Did you have a sample theme that repro's this? It's probably dependent on the tab color, the tab row colow, if Mica is being used...
```js
{
            "name": "custom",
            "tab": 
            {
                "background": "#00000000",
                "showCloseButton": "always",
                "unfocusedBackground": null
            },
            "tabRow": 
            {
                //"background": "#00000000",
                "unfocusedBackground": null
            },
            "window": 
            {
                "applicationTheme": "system",
                "useMica": false
            }
        }
```

<img width="209" alt="image" src="https://user-images.githubusercontent.com/11050425/207922269-6c7f6bdc-13c3-4c92-9725-4dc8bbf32c49.png">

OS theme: light

Fix patch:
diff --git a/src/cascadia/TerminalApp/TabBase.cpp b/src/cascadia/TerminalApp/TabBase.cpp
index 6fd1e365910..52734c9f31e 100644
--- a/src/cascadia/TerminalApp/TabBase.cpp
+++ b/src/cascadia/TerminalApp/TabBase.cpp
@@ -356,16 +356,12 @@ namespace winrt::TerminalApp::implementation
         Media::SolidColorBrush hoverTabBrush{};
         Media::SolidColorBrush subtleFillColorSecondaryBrush;
         Media::SolidColorBrush subtleFillColorTertiaryBrush;
+
         // calculate the luminance of the current color and select a font
         // color based on that
         // see https://www.w3.org/TR/WCAG20/#relativeluminancedef
         if (TerminalApp::ColorHelper::IsBrightColor(color))
         {
-            fontBrush.Color(winrt::Windows::UI::Colors::Black());
-            auto secondaryFontColor = winrt::Windows::UI::Colors::Black();
-            // For alpha value see: https://github.com/microsoft/microsoft-ui-xaml/blob/7a33ad772d77d908aa6b316ec24e6d2eb3ebf571/dev/CommonStyles/Common_themeresources_any.xaml#L269
-            secondaryFontColor.A = 0x9E;
-            secondaryFontBrush.Color(secondaryFontColor);
             auto subtleFillColorSecondary = winrt::Windows::UI::Colors::Black();
             subtleFillColorSecondary.A = 0x09;
             subtleFillColorSecondaryBrush.Color(subtleFillColorSecondary);
@@ -375,11 +371,6 @@ namespace winrt::TerminalApp::implementation
         }
         else
         {
-            fontBrush.Color(winrt::Windows::UI::Colors::White());
-            auto secondaryFontColor = winrt::Windows::UI::Colors::White();
-            // For alpha value see: https://github.com/microsoft/microsoft-ui-xaml/blob/7a33ad772d77d908aa6b316ec24e6d2eb3ebf571/dev/CommonStyles/Common_themeresources_any.xaml#L14
-            secondaryFontColor.A = 0xC5;
-            secondaryFontBrush.Color(secondaryFontColor);
             auto subtleFillColorSecondary = winrt::Windows::UI::Colors::White();
             subtleFillColorSecondary.A = 0x0F;
             subtleFillColorSecondaryBrush.Color(subtleFillColorSecondary);
@@ -388,6 +379,25 @@ namespace winrt::TerminalApp::implementation
             subtleFillColorTertiaryBrush.Color(subtleFillColorTertiary);
         }
 
+        // The tab font should be based on the evaluated appearance of the tab color layered on tab row.
+        const auto layeredTabColor = til::color{ color }.layer_over(_tabRowColor);
+        if (TerminalApp::ColorHelper::IsBrightColor(layeredTabColor))
+        {
+            fontBrush.Color(winrt::Windows::UI::Colors::Black());
+            auto secondaryFontColor = winrt::Windows::UI::Colors::Black();
+            // For alpha value see: https://github.com/microsoft/microsoft-ui-xaml/blob/7a33ad772d77d908aa6b316ec24e6d2eb3ebf571/dev/CommonStyles/Common_themeresources_any.xaml#L269
+            secondaryFontColor.A = 0x9E;
+            secondaryFontBrush.Color(secondaryFontColor);
+        }
+        else
+        {
+            fontBrush.Color(winrt::Windows::UI::Colors::White());
+            auto secondaryFontColor = winrt::Windows::UI::Colors::White();
+            // For alpha value see: https://github.com/microsoft/microsoft-ui-xaml/blob/7a33ad772d77d908aa6b316ec24e6d2eb3ebf571/dev/CommonStyles/Common_themeresources_any.xaml#L14
+            secondaryFontColor.A = 0xC5;
+            secondaryFontBrush.Color(secondaryFontColor);
+        }
+
         selectedTabBrush.Color(color);
 
         // Start with the current tab color, set to Opacity=.3


Test patch: