On Sun, Nov 20, 2011 at 11:29 AM, Infinality <[email protected]> wrote:> I second the idea of adding configurable LCD filter settings to fontconfig! So I wrote the attached patch for fontconfig, that I will submit to the fontconfig ML. With the patch and freetype2, lcdfilter=lcddefault would correspond to: <match target="font"> <edit mode="assign" name="lcdfilter"> <const>lcdcustom</const> </edit> </match> <match target="font"> <edit mode="assign" name="lcdfiltercustom"> <string>.0625 .25 .4375 .25 .0625</string> </edit> </match> But it's not perfect, as users of the fontconfig API would have to parse the lcdfiltercustom string themselves. I will ask if the fontconfig developers see a better way of specifying a list of double.
Questions:- Would there ever be a good reason to not have a symmetric FIR? Should be the option be specified as ".4375 .25 .0625" (first half, reverse order) and assume symmetry for the other weights?- Could the size of the filter be different? Or is 5 likely to be fairly universal, even for other renderers? - When specified from the center value ".4375 .25 .0625", missing values can be assumed to be 0, and extra values can be ignored. I'm tempted to specify the option this way instead, unless asymmetric filters are useful. Thanks.
From 45a2a330fbf3da0667c0f891b605df276d23963d Mon Sep 17 00:00:00 2001 Message-Id: <45a2a330fbf3da0667c0f891b605df276d23963d.1321828468.gi...@nanocritical.com> From: Eric Rannaud <[email protected]> Date: Sun, 20 Nov 2011 14:21:06 -0800 Subject: [PATCH 1/1] Add lcdfiltercustom option: controls the filter individual weights When lcdfilter is set to "lcdcustom", use lcdfiltercustom to retrieve a string containing a space-separated list of double values between 0.0 and 1.0 and configure the rendered LCD filter (e.g. for freetype2, this is done with FT_Library_SetLcdFilterWeights()). If lcdfiltercustom is empty or is malformed, assume lcddefault. With freetype2 as renderer, when fontconfig's FT_LCD_DEFAULT is mapped to freetype2's FT_LCD_FILTER_DEFAULT, the configuration <match target="font"> <edit mode="assign" name="lcdfilter"> <const>lcddefault</const> </edit> </match> corresponds to setting <match target="font"> <edit mode="assign" name="lcdfilter"> <const>lcdcustom</const> </edit> </match> <match target="font"> <edit mode="assign" name="lcdfiltercustom"> <string>.0625 .25 .4375 .25 .0625</string> </edit> </match> --- doc/fontconfig-user.sgml | 5 +++++ fontconfig/fontconfig.h | 2 ++ src/fcname.c | 4 +++- 3 files changed, 10 insertions(+), 1 deletions(-) diff --git a/doc/fontconfig-user.sgml b/doc/fontconfig-user.sgml index 217feb9..ef34254 100644 --- a/doc/fontconfig-user.sgml +++ b/doc/fontconfig-user.sgml @@ -122,6 +122,10 @@ convenience for the applications' rendering mechanism. rgba Int unknown, rgb, bgr, vrgb, vbgr, none - subpixel geometry lcdfilter Int Type of LCD filter + lcdfiltercustom String Weights for the custom LCD filter, enabled by setting + lcdfilter to lcdcustom. Example: + ".0625 .25 .4375 .25 .0625" corresponds to + setting the option lcdfilter to lcddefault. minspace Bool Eliminate leading from line spacing charset CharSet Unicode chars encoded by the font lang String List of RFC-3066-style languages this @@ -494,6 +498,7 @@ symbolic names for common font values: lcddefault lcdfilter 1 lcdlight lcdfilter 2 lcdlegacy lcdfilter 3 + lcdcustom lcdfilter 4 hintnone hintstyle 0 hintslight hintstyle 1 hintmedium hintstyle 2 diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h index db26b97..f05f570 100644 --- a/fontconfig/fontconfig.h +++ b/fontconfig/fontconfig.h @@ -111,6 +111,7 @@ typedef int FcBool; #define FC_EMBEDDED_BITMAP "embeddedbitmap" /* Bool - true to enable embedded bitmaps */ #define FC_DECORATIVE "decorative" /* Bool - true if style is a decorative variant */ #define FC_LCD_FILTER "lcdfilter" /* Int */ +#define FC_LCD_FILTER_CUSTOM "lcdfiltercustom" /* String. Space separated list of double */ #define FC_CACHE_SUFFIX ".cache-"FC_CACHE_VERSION #define FC_DIR_CACHE_FILE "fonts.cache-"FC_CACHE_VERSION @@ -177,6 +178,7 @@ typedef int FcBool; #define FC_LCD_DEFAULT 1 #define FC_LCD_LIGHT 2 #define FC_LCD_LEGACY 3 +#define FC_LCD_CUSTOM 4 typedef enum _FcType { FcTypeVoid, diff --git a/src/fcname.c b/src/fcname.c index d77eff6..0697d10 100644 --- a/src/fcname.c +++ b/src/fcname.c @@ -75,7 +75,8 @@ static const FcObjectType _FcBaseObjectTypes[] = { { FC_EMBOLDEN, FcTypeBool }, { FC_EMBEDDED_BITMAP, FcTypeBool }, { FC_DECORATIVE, FcTypeBool }, - { FC_LCD_FILTER, FcTypeInteger }, /* 41 */ + { FC_LCD_FILTER, FcTypeInteger }, + { FC_LCD_FILTER_CUSTOM, FcTypeString }, /* 42 */ }; #define NUM_OBJECT_TYPES (sizeof _FcBaseObjectTypes / sizeof _FcBaseObjectTypes[0]) @@ -454,6 +455,7 @@ static const FcConstant _FcBaseConstants[] = { { (FcChar8 *) "lcddefault", "lcdfilter", FC_LCD_DEFAULT }, { (FcChar8 *) "lcdlight", "lcdfilter", FC_LCD_LIGHT }, { (FcChar8 *) "lcdlegacy", "lcdfilter", FC_LCD_LEGACY }, + { (FcChar8 *) "lcdcustom", "lcdfilter", FC_LCD_CUSTOM }, }; #define NUM_FC_CONSTANTS (sizeof _FcBaseConstants/sizeof _FcBaseConstants[0]) -- 1.7.6.4
_______________________________________________ Freetype-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/freetype-devel
