Bug 27386

Summary: FIR filters with custom constants from fontconfig
Product: fontconfig Reporter: Robin Johnson <robbat2>
Component: libraryAssignee: fontconfig-bugs
Status: RESOLVED MOVED QA Contact: Behdad Esfahbod <freedesktop>
Severity: enhancement    
Priority: medium CC: akira, dirtyepic, freddie, freedesktop, pva
Version: 2.8   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Robin Johnson 2010-03-30 19:59:10 UTC
There have been a number of subjective patches around for altering the FIR constants used in ./freetype-2.3.12/src/base/ftlcdfil.c
I've seen at least 4 different sets of values:
light: { 0, 85, 86, 85, 0 }
default: { 0x10, 0x40, 0x70, 0x40, 0x10 }
gentoo-bug306053:{ 0x1C, 0x38, 0x55, 0x38, 0x1C }
russian forum: {8, 28, 100, 80, 40};

Here was the Gentoo bug:
http://bugs.gentoo.org/show_bug.cgi?id=306053
We told the user to take it upstream, he never did, but it came up again.

Here's the google cache of Russian forum post, as the original seems to have gone:
http://tinyurl.com/yl5kyup

Can we please introduce a way to set the constants from fontconfig, and let the users duke it out amongst themselves?
Comment 1 Werner Lemberg 2010-03-30 21:48:41 UTC
I'm not very font of changing the filter values directly in ftlcdfil.c; however, I rather like the set of patches to change the filter at runtime, and I'll add them to FreeType (as soon as time permits, which can take some time unfortunately).

Indeed, this particular problem was, as far as I can remember, never reported to one of the FreeType lists.
Comment 2 Behdad Esfahbod 2010-03-31 08:21:30 UTC
IIRC, the early versions of the lcdfilter API from David did take the vector from the user.
Comment 3 Werner Lemberg 2010-04-04 23:51:23 UTC
The new function is now in the git.  Will update the demo programs as soon as time permits.  Please test.
Comment 4 Werner Lemberg 2010-04-04 23:54:07 UTC
Umm, I'm only handling the FreeType side, so I change the bug status back.
Comment 5 Freddie Witherden 2010-04-05 11:02:22 UTC
> gentoo-bug306053:{ 0x1C, 0x38, 0x55, 0x38, 0x1C }
These coefficients roughly correspond to 1/9, 2/9, 3/9, 2/9, 1/9 and are better known as the Gibson coefficients --- being popularised in Steve Gibson's 1998 article on sub-pixel rendering. Some of the early patch sets to Cairo used these coefficients.

> russian forum: {8, 28, 100, 80, 40};
Interesting, I've never come across these before. The lack of symmetry is somewhat noteworthy --- on account that I can think of no reason to bias the right side of a glyph as opposed to the left.

If anyone is interested in the differences between the light, gibson and default coefficients a comparison can be found here: http://freddie.witherden.org/pages/font-rasterisation/images/fir-filtered.png [light, gibson, default, regular AA].

I'd be interested if anyone had any suggestions for a syntax for this configuration. As currently so far as LCD filtering goes we have two different kinds of filter: intra-pixel (legacy) and inter-pixel (FIR, default and light) which will soon include customisable coefficients.

Currently, I think the best course of action so far as fontconfig goes is to use this new found FT functionality to define a couple more pre-sets namely gibson (see above) and whatever we think Microsoft uses for ClearType.
Comment 6 Robin Johnson 2010-04-05 17:16:59 UTC
(In reply to comment #5)
> > gentoo-bug306053:{ 0x1C, 0x38, 0x55, 0x38, 0x1C }
> These coefficients roughly correspond to 1/9, 2/9, 3/9, 2/9, 1/9 and are better
> known as the Gibson coefficients ...
Hah, I knew in the back of my head I'd seen them somewhere before, but couldn't place them. My distant past playing with the VGA demoscene :-)

> > russian forum: {8, 28, 100, 80, 40};
> Interesting, I've never come across these before. The lack of symmetry is
> somewhat noteworthy --- on account that I can think of no reason to bias the
> right side of a glyph as opposed to the left.
Maybe readability on bad fonts?

> If anyone is interested in the differences between the light, gibson and
> default coefficients a comparison can be found here:
> http://freddie.witherden.org/pages/font-rasterisation/images/fir-filtered.png
> [light, gibson, default, regular AA].
Thanks for the nice image :-)

> I'd be interested if anyone had any suggestions for a syntax for this
> configuration. As currently so far as LCD filtering goes we have two different
> kinds of filter: intra-pixel (legacy) and inter-pixel (FIR, default and light)
> which will soon include customisable coefficients.
Extend the matrix element attributes for size and type, add a element to represent uint8, allow matrix to have int/double/uint8 child elements?

> Currently, I think the best course of action so far as fontconfig goes is to
> use this new found FT functionality to define a couple more pre-sets namely
> gibson (see above) and whatever we think Microsoft uses for ClearType.
+1
Comment 7 Behdad Esfahbod 2010-04-08 16:26:39 UTC
(In reply to comment #3)
> The new function is now in the git.  Will update the demo programs as soon as
> time permits.  Please test.

Is it?  I don't see it.
Comment 8 Behdad Esfahbod 2010-04-08 16:28:40 UTC
(In reply to comment #5)

> Currently, I think the best course of action so far as fontconfig goes is to
> use this new found FT functionality to define a couple more pre-sets namely
> gibson (see above) and whatever we think Microsoft uses for ClearType.

Nope.  Fontconfig should simply allow specifying a custom filter.
Comment 9 Werner Lemberg 2010-04-09 01:22:18 UTC
It's git commit 460d23f1.
Comment 10 Behdad Esfahbod 2010-04-09 22:19:40 UTC
I see.  Thanks.
Comment 11 Akira TAGOH 2012-04-26 01:26:41 UTC
any operator to access the byte array may be required in fontconfig:

<edit name="lcdcustomfilter" mode="assign">
  <array>
    <int>0x1C</int>
    <int>0x38</int>
    <int>0x55</int>
    <int>0x38</int>
    <int>0x1C</int>
  </array>
</edit>
Comment 12 GitLab Migration User 2018-08-20 21:51:40 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/90.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.