--- fontconfig-2.13.0/src/fcmatch.c.orig 2018-03-08 16:45:52.377939235 +0000 +++ fontconfig-2.13.0/src/fcmatch.c 2018-03-08 16:47:13.473464653 +0000 @@ -50,6 +50,15 @@ return -1.0; } v = v2 - v1; + + /* + * Hack to allow bitmap fonts to equal requested font if it is close + */ + if ( v > -.5 && v <= .5 ) + { + v = 0; + } + if (v < 0) v = -v; *bestValue = FcValueCanonicalize (value2); @@ -754,6 +763,46 @@ return new; } +static void +FcChangeFormat ( FcPattern *p ) +{ + int i; + FcPatternElt *pe = FcPatternElts(p); + + /* + * Hack. If user want monochrome mode, then try to pick bitmaps over + * outlines. + */ + for ( i = 0; i < p->num; i++ ) + { + if ( !strcmp(&pe[i].object, "antialias" )) + { + int aa = (int) &pe[i].values->value.u.b; + int j; + int done = 0; + FcValue v; + + v.type = FcTypeBool; + v.u.b = aa; + + for ( j = 0; j < p->num; j++ ) + { + if ( !strcmp(&pe[j].object, "outline" )) + { + done = 1; + break; + } + } + if ( !done ) + { + FcPatternObjectAddWithBinding (p, "outline", v, + FcValueBindingStrong, 1); + } + break; + } + } +} + static FcPattern * FcFontSetMatchInternal (FcFontSet **sets, int nsets, @@ -767,6 +816,8 @@ int i; int set; + FcChangeFormat ( p ); + for (i = 0; i < PRI_END; i++) bestscore[i] = 0; best = 0; @@ -1048,6 +1099,8 @@ FcBool *patternLangSat; FcValue patternLang; + FcChangeFormat ( p ); + assert (sets != NULL); assert (p != NULL); assert (result != NULL);