From: handa Date: Tue, 14 Sep 2010 11:13:19 +0000 (+0000) Subject: (ft_check_otf): Fix handling of negative features. X-Git-Tag: REL-1-6-2~17 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ff27d27e08439b899268a024af6321a16213301;p=m17n%2Fm17n-lib.git (ft_check_otf): Fix handling of negative features. --- diff --git a/src/font-ft.c b/src/font-ft.c index dd62e6e..79d6bbe 100644 --- a/src/font-ft.c +++ b/src/font-ft.c @@ -2142,6 +2142,8 @@ ft_close (MRealizedFont *rfont) free (rfont); } +/* See the comment of parse_otf_command (m17n-flt.c). */ + static int ft_check_otf (MFLTFont *font, MFLTOtfSpec *spec) { @@ -2149,34 +2151,57 @@ ft_check_otf (MFLTFont *font, MFLTOtfSpec *spec) OTF_Tag *tags; int i, n, negative; OTF *otf = get_otf (font, NULL); + + if (spec->features[0] && spec->features[0][0] ==0 + && spec->features[1] && spec->features[1][0] ==0) + /* Return 1 iff any of GSUB or GPOS support the script (and language). */ + return (otf + && (OTF_check_features (otf, 0, spec->script, spec->langsys, + NULL, 0) > 0 + || OTF_check_features (otf, 1, spec->script, spec->langsys, + NULL, 0) > 0)); - if (! otf) - goto not_otf; for (i = 0; i < 2; i++) - { - if (! spec->features[i]) - continue; - for (n = 0; spec->features[i][n]; n++); - tags = alloca (sizeof (OTF_Tag) * n); - for (n = 0, negative = 0; spec->features[i][n]; n++) - { - if (spec->features[i][n] == 0xFFFFFFFF) - negative = 1; - else if (negative) - tags[n - 1] = spec->features[i][n] | 0x80000000; - else - tags[n] = spec->features[i][n]; - } - if (n - negative > 0 - && OTF_check_features (otf, i == 0, spec->script, spec->langsys, - tags, n - negative) != 1) - return 0; - } + if (! spec->features[i] || spec->features[i][0] != 0) + { + int no_feature = ! otf || OTF_get_features (otf, i == 0) < 0; + + if (! spec->features[i]) + { + if (no_feature) + continue; + return 0; + } + if (spec->features[i][0] == 0xFFFFFFFF) + { + if (no_feature) + continue; + } + else if (no_feature) + return 0; + /* Now (! no_feature) */ + for (n = 1; spec->features[i][n]; n++); + tags = alloca (sizeof (OTF_Tag) * n); + for (n = 0, negative = 0; spec->features[i][n]; n++) + { + if (spec->features[i][n] == 0xFFFFFFFF) + negative = 1; + else if (negative) + tags[n - 1] = spec->features[i][n] | 0x80000000; + else + tags[n] = spec->features[i][n]; + } + if (OTF_check_features (otf, i == 0, spec->script, spec->langsys, + tags, n - negative) != 1) + return 0; + } return 1; - not_otf: + #endif /* HAVE_OTF */ - return ((! spec->features[0] || spec->features[0][0] == 0xFFFFFFFF) - && (! spec->features[1] || spec->features[1][0] == 0xFFFFFFFF)); + return ((! spec->features[0] || (spec->features[0][0] == 0 + && spec->features[0][0] == 0xFFFFFFFF)) + && (! spec->features[0] || (spec->features[0][0] == 0 + && spec->features[0][0] == 0xFFFFFFFF))); } #ifdef HAVE_OTF