This ;) (Comments on my comments welcome -- still not sure what to do
about e.g. the color-balancing formula)

2015-11-26 20:54 GMT+01:00 Werner LEMBERG <w...@gnu.org>:
>>> This sounds like a good compromise, thanks.
>>>
>>> Can we all agree on this filter as the default for `light_filter'?
>>>
>>> Alexei, what value should `default_filter' have?
>>
>> Please leave the light one alone. Dave's filter should be default.
>
> So *what* shall I change?
>
>
>     Werner
>
> _______________________________________________
> Freetype-devel mailing list
> Freetype-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/freetype-devel
From e9b3098dbbcfe7a313982cb47ab8689eb331e2df Mon Sep 17 00:00:00 2001
From: Nikolaus Waxweiler <madig...@gmail.com>
Date: Thu, 26 Nov 2015 22:52:19 +0100
Subject: [PATCH] Change default LCD filter to normalized, color-balanced

---
 include/freetype/ftlcdfil.h | 39 +++++++++++++++++++++++++--------------
 src/base/ftlcdfil.c         |  6 ++----
 2 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/include/freetype/ftlcdfil.h b/include/freetype/ftlcdfil.h
index 3a62528..eb48513 100644
--- a/include/freetype/ftlcdfil.h
+++ b/include/freetype/ftlcdfil.h
@@ -69,28 +69,28 @@ FT_BEGIN_HEADER
    *   linear color space, then alpha blended in that space, and transformed
    *   back to the output color space.
    *
-   *   When linear light blending is used, the default FIR5 filtering
-   *   weights (as given by FT_LCD_FILTER_DEFAULT) are no longer optimal, as
-   *   they have been designed for black on white rendering while lacking
-   *   gamma correction.  To preserve color neutrality, weights for a FIR5
-   *   filter should be chosen according to two free parameters `a' and `c',
-   *   and the FIR weights should be
+   *   To preserve color neutrality and reduce color fringing to a
+   *   minimum, weights for a FIR5 filter should be chosen according to
+   *   two free parameters `a' and `c', and the FIR weights should be
    *
    *   {
    *     [a - c, a + c, 2 * a, a + c, a - c]    .
    *   }
    *
    *   This formula generates equal weights for all the color primaries
-   *   across the filter kernel, which makes it colorless.  One suggested
-   *   set of weights is
+   *   across the filter kernel, which makes it colorless or
+   *   color-balanced.  One possible set of weights is
    *
    *   {
    *     [0x10, 0x50, 0x60, 0x50, 0x10]    ,
    *   }
    *
-   *   where `a' has value 0x30 and `c' value 0x20.  The weights in filter
-   *   may have a sum larger than 0x100, which increases coloration slightly
-   *   but also improves contrast.
+   *   where `a' has value 0x30 and `c' value 0x20, however the sum goes
+   *   above 0x100, leading to non-linearities and increased
+   *   color-fringing. This can be used to increase contrast at the cost
+   *   of colorfulness, but stem darkening achieves contrast much better if
+   *   the rendering system can do linear alpha blending and gamma
+   *   correction.
    */
 
 
@@ -111,10 +111,21 @@ FT_BEGIN_HEADER
    *     The default filter reduces color fringes considerably, at the cost
    *     of a slight blurriness in the output.
    *
+   *     It is a normalized and color-balanced five-tap filter that is more
+   *     forgiving to screens with non-ideal gamma curves and viewing
+   *     angles. Note that while color-fringing is reduced, it can only be
+   *     minimized by using linear alpha blending and gamma correction to
+   *     render glyphs onto surfaces.
+   *
    *   FT_LCD_FILTER_LIGHT ::
-   *     The light filter is a variant that produces less blurriness at the
-   *     cost of slightly more color fringes than the default one.  It might
-   *     be better, depending on taste, your monitor, or your personal vision.
+   *     The light filter is a variant that is sharper at the cost of
+   *     slightly more color fringes than the default one.
+   *
+   *     It is a normalized and color-balanced three-tap filter that is less
+   *     forgiving to screens with non-ideal gamma curves and viewing
+   *     angles. This filter works best when the rendering system uses
+   *     linear alpha blending and gamma correction to render glyphs onto
+   *     surfaces.
    *
    *   FT_LCD_FILTER_LEGACY ::
    *     This filter corresponds to the original libXft color filter.  It
diff --git a/src/base/ftlcdfil.c b/src/base/ftlcdfil.c
index b50383c..5ee7e0a 100644
--- a/src/base/ftlcdfil.c
+++ b/src/base/ftlcdfil.c
@@ -305,12 +305,10 @@
   FT_Library_SetLcdFilter( FT_Library    library,
                            FT_LcdFilter  filter )
   {
+    static const FT_Byte  default_filter[5] =
+                            { 0x08, 0x4d, 0x56, 0x4d, 0x08 };
     static const FT_Byte  light_filter[5] =
                             { 0x00, 0x55, 0x56, 0x55, 0x00 };
-    /* the values here sum up to a value larger than 256, */
-    /* providing a cheap gamma correction                 */
-    static const FT_Byte  default_filter[5] =
-                            { 0x10, 0x40, 0x70, 0x40, 0x10 };
 
 
     if ( !library )
-- 
2.5.0

_______________________________________________
Freetype-devel mailing list
Freetype-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel

Reply via email to