Bug 59385

Summary: Do the right thing for intermixed edit and test elements
Product: fontconfig Reporter: Behdad Esfahbod <freedesktop>
Component: libraryAssignee: Akira TAGOH <akira>
Status: RESOLVED FIXED QA Contact: Behdad Esfahbod <freedesktop>
Severity: normal    
Priority: medium CC: akira, fontconfig-bugs
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Behdad Esfahbod 2013-01-15 00:53:20 UTC
Note: remember to update DTD

Behdad Esfahbod wrote:
> Currently, for every match elements, all tests are evaluated, and if all
> match, all edits are applied in order of appearance.
>
> I like to change this such that all test and edits are applied in order of
> appearance simultaneously.   These are the reasons:

Why not...
Since interleaved <test> and <edit> were previously not even allowed by the DTD, it shouldn't have any real impact on existing configs. OK it was tolerated by fontconfig but I can't imagine this was exploited by anyone...

Raimund
Comment 1 Akira TAGOH 2013-01-25 11:08:02 UTC
proposed fix for this:
  http://cgit.freedesktop.org/~tagoh/fontconfig/commit/?h=bz59385

maybe I should export FcSubst* as FcPrivate but static function, instead of own structure to stock the FcTest and FcEdit to reorder.

        <match>
                <test name="lang" compare="eq">
                        <string>ja</string>
                </test>
                <edit name="family" mode="append">
                        <string>foo</string>
                </edit>
                <test name="family" compare="contains">
                        <string>foo</string>
                </test>
                <edit name="family" mode="assign">
                        <string>bar</string>
                </edit>
        </match>

before applying this change:

        Loading config file /home/tagoh/.config/fontconfig/conf.d/00-bz59385.conf
Add Subst match
        pattern any lang Equal "ja"
        pattern any family Contains "foo"
edit
        Edit family Append "foo";
        Edit family Assign "bar";
...
FcConfigSubstitute test pattern any lang Equal "ja"
FcConfigSubstitute test pattern any family Contains "foo"
No match

after applying:

        Loading config file /home/tagoh/.config/fontconfig/conf.d/00-bz59385.conf
Add Subst match
        pattern any lang Equal "ja"
edit
        Edit family Append "foo";

Add Subst match
        pattern any family Contains "foo"
edit
        Edit family Assign "bar";
...
FcConfigSubstitute test pattern any lang Equal "ja"
Substitute match
        pattern any lang Equal "ja"
edit
        Edit family Append "foo";

Append list before  "sans-serif"(w) [insert here]
Append list after  "sans-serif"(w) "foo"(w)
FcConfigSubstitute editPattern has 3 elts (size 16)
        family: "sans-serif"(w) "foo"(w)
        lang: "ja"(w)
        prgname: "lt-fc-match"(s)

FcConfigSubstitute test pattern any family Contains "foo"
Substitute match
        pattern any family Contains "foo"
edit
        Edit family Assign "bar";

Append list before  "sans-serif"(w) "foo"(w) [insert here]
Append list after  "sans-serif"(w) "foo"(w) "bar"(w)
FcConfigSubstitute editPattern has 3 elts (size 16)
        family: "sans-serif"(w) "bar"(w)
        lang: "ja"(w)
        prgname: "lt-fc-match"(s)
Comment 2 Akira TAGOH 2013-02-01 02:32:50 UTC
After a bit cleanup, committed into master.

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.