0

I want to determine if a given font colour is unreadable against a given background colour.

Supposed a given background color and foreground colours of #000000. It is trivial to do an equality check. However, the human eye is capable of determining if a range of background colors will make a black font unreadable.

One way of doing this is by using OCR simply by relying if the exact text is extracted. The logic is that if the OCR can read it, so can a human eye.

Is there a faster alternative?

I have tried using OCR but this method is not as efficient.

  • Depends on who is doing the reading and how large the font is. [WCAG](https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html) sets out color contrast guidelines for different font sizes. You might also be interested in this [web site](https://webaim.org/resources/contrastchecker/) that has a tool that will do the check for you. – John Wu Nov 18 '22 at 23:07
  • @JohnWu Thanks for the reply but I am actually asking how to detect it programmatically. –  Nov 19 '22 at 10:24
  • https://stackoverflow.com/a/50541212/14171304 – dr.null Nov 19 '22 at 12:07
  • @kylie I understand. The point of my comment is that your requirement is unclear, since the legibility of something depends on external factors. Until you define an unambiguous requirement, a code solution is not possible. – John Wu Nov 20 '22 at 00:54

0 Answers0