[Fontconfig] Forcing Artificial Italics on Fonts That *DO* Have One Available?

Erik erik at beanbasket.com
Mon Aug 4 18:06:15 PDT 2008


I understand that this bit of code in .fonts.conf will enable italics 
for fonts that do not have an italic face available:


    <!-- Artificial oblique for fonts without an italic or oblique 
version -->
    <match target="font" >
        <!-- check to see if the font is roman -->
        <test name="slant" >
            <const>roman</const>
        </test>
        <!-- check to see if the pattern requested non-roman -->
        <test target="pattern" compare="not_eq" name="slant" >
            <const>roman</const>
        </test>
        <!-- multiply the matrix to slant the font -->
        <edit mode="assign" name="matrix" >
            <times>
                <name>matrix</name>
                <matrix>
                    <double>1</double>
                    <double>0.2</double>
                    <double>0</double>
                    <double>1</double>
                </matrix>
            </times>
        </edit>
        <!-- pretend the font is oblique now -->
        <edit mode="assign" name="slant" >
            <const>oblique</const>
        </edit>
    </match>


I am interested in *forcing* this behavior on fonts that *do* have an 
italic face available, because I like the way the artificial rendering 
looks.  I have been unable to make it work however. It seems that once 
an existing italic font has been selected, fontconfig will not give it 
up.  One of my approaches was to have a piece of XML prior to the above 
which "undoes" any existing italic:

    <!-- Artificial oblique for fonts WITH an italic or oblique version -->
    <match target="font" >
        <!-- check to see if the font is NOT roman -->
        <test name="slant" compare="not_eq">
            <const>roman</const>
        </test>
        <!-- check to see if the pattern requested non-roman -->
        <test target="pattern" compare="not_eq" name="slant" >
            <const>roman</const>
        </test>
        <edit mode="append" binding="same" name="slant">
            <const>roman</const>
        </edit>
    </match>

But, the end effect is to do double italics, i.e. it slants it twice.  
Does anybody have an idea on how to force it to first select the regular 
font, then apply artificial slanting to it?

Thanks,
Erik


More information about the Fontconfig mailing list