diff options
Diffstat (limited to 'src/ui/text.c')
-rw-r--r-- | src/ui/text.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/ui/text.c b/src/ui/text.c index 66231348..3fe56b59 100644 --- a/src/ui/text.c +++ b/src/ui/text.c | |||
@@ -697,6 +697,25 @@ struct Impl_AttributedRun { | |||
697 | 697 | ||
698 | static iColor fgColor_AttributedRun_(const iAttributedRun *d) { | 698 | static iColor fgColor_AttributedRun_(const iAttributedRun *d) { |
699 | if (d->fgColor_.a) { | 699 | if (d->fgColor_.a) { |
700 | /* Ensure legibility if only the foreground color is set. */ | ||
701 | if (!d->bgColor_.a) { | ||
702 | iColor fg = d->fgColor_; | ||
703 | const iHSLColor themeBg = get_HSLColor(tmBackground_ColorId); | ||
704 | const float bgLuminance = luma_Color(get_Color(tmBackground_ColorId)); | ||
705 | if (bgLuminance > 0.4f) { | ||
706 | float dim = (bgLuminance - 0.4f); | ||
707 | fg.r *= 0.5f * dim; | ||
708 | fg.g *= 0.5f * dim; | ||
709 | fg.b *= 0.5f * dim; | ||
710 | } | ||
711 | if (themeBg.sat > 0.15f && themeBg.lum >= 0.5f) { | ||
712 | iHSLColor fgHsl = hsl_Color(fg); | ||
713 | fgHsl.hue = themeBg.hue; | ||
714 | fgHsl.lum = themeBg.lum * 0.5f; | ||
715 | fg = rgb_HSLColor(fgHsl); | ||
716 | } | ||
717 | return fg; | ||
718 | } | ||
700 | return d->fgColor_; | 719 | return d->fgColor_; |
701 | } | 720 | } |
702 | if (d->attrib.fgColorId == none_ColorId) { | 721 | if (d->attrib.fgColorId == none_ColorId) { |