TL;DR: This patch allows users to use subpixel antialiasing/lcd filter
on openbsd, like on FreeBSD/most Linux distributions.  It does not
change the defaults. For full use, see my other patch at [7].


Dear all,

this patch enables subpixel rendering, which is disabled by default in
freetype (due to software patents), and enables users to use RGB
Antialiasing, which is a big improvements for low-DPI displays (e.g.
with a DPI of 96).

The current default ist greyscale AA (and no lcd filter), which is not
changed by this patch.  To use subpixel AA/lcd filter, you have to
manually enable it (see my config below).

>From [1]:

  By default, FreeType's scan-line converter returns "gray" sub-pixel
  images, where for each pixel the color components are equal (this is,
  R=G=B). The result is visually identical to gray anti-aliasing and
  cannot infringe any of the ClearType patents.

  Similarly, the LCD-specific filtering API is disabled by default,
  which means that it returns an error and doesn't alter sub-pixel
  images.

  You can override these limitations by activating option
  FT_CONFIG_OPTION_SUBPIXEL_RENDERING in FreeType's ftoption.h
  configuration file, but you should do that at your own risk.

Other Linux/BSD systems have this option enabled for a long time now,
under them Ubuntu, Debian [2], Freebsd [3], Arch Linux [4] and more.

There has been a privious discussion on this list on this topic [5]
where tedu@ mentions, that this issue is irrelevant once you get a
decent display with a higher DPI (or use bitmap fonts), which is of
course true [6].  But at least for me, at work we still have (and buy)
new monitors that have a DPI of 96 (e.g. Dell U2412M).  On these
displays, bitmap fonts are too tiny for me and don't scale well, so
subpixel rendering with enabled lcd filter really makes a difference.

For this patch, hinting should be set to "slight".  This is also
upstreams default, but unfortunately, openbsd forgot to merge the
relevant changes, so for now, unless the user does not change the
settings, it is hintfull.  See my patch at [7], which make slight
hinting the default.  More information from the freetype page at [8].

Once you recompile freetype with the patch, you can enable subpixel
hinting by adding the following snipped to your .config/fontconfig/fonts.conf:

  <?xml version="1.0"?>
  <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
  <fontconfig>
    <match target="font">
      <edit mode="assign" name="rgba">
        <const>rgb</const>
      </edit>
      <edit mode="assign" name="lcdfilter">
        <const>lcddefault</const>
      </edit>
    </match>
  </fontconfig>

Is there a chance to get this enabled in xenocara?

Regards
Nils

[1] https://www.freetype.org/patents.html
[2] 
http://metadata.ftp-master.debian.org/changelogs/main/f/freetype/freetype_2.5.2-3+deb8u1_changelog
[3] http://www.freshports.org/print/freetype2/
[4] 
https://git.archlinux.org/svntogit/packages.git/tree/trunk/0002-Enable-subpixel-rendering.patch?h=packages/freetype2
[5] http://marc.info/?l=openbsd-misc&m=146065800429682&w=2
[6] http://marc.info/?l=openbsd-misc&m=146315386122046&w=2
[7] http://marc.info/?l=openbsd-tech&m=148353268331986&w=2
[8] 
https://www.freetype.org/freetype2/docs/text-rendering-general.html#slight-hinting-invokes-the-native-hinter-if-possible


Index: lib/freetype/include/freetype/config/ftoption.h
===================================================================
RCS file: /cvs/xenocara/lib/freetype/include/freetype/config/ftoption.h,v
retrieving revision 1.19
diff -u -p -r1.19 ftoption.h
--- lib/freetype/include/freetype/config/ftoption.h     28 Oct 2016 21:41:15 
-0000      1.19
+++ lib/freetype/include/freetype/config/ftoption.h     9 Jan 2017 13:55:13 
-0000
@@ -122,7 +122,7 @@ FT_BEGIN_HEADER
   /* This is done to allow FreeType clients to run unmodified, forcing     */
   /* them to display normal gray-level anti-aliased glyphs.                */
   /*                                                                       */
-/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
+#define FT_CONFIG_OPTION_SUBPIXEL_RENDERING
 
 
   /*************************************************************************/

Reply via email to