<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
  <description>Add sans-serif to the family when no generic name</description>

  <!-- Add family from genericfamly -->
  <match target="pattern">
    <test qual="first" name="genericfamily" compare="eq">
      <const>serif</const>
    </test>
    <edit name="family" mode="append">
      <string>serif</string>
    </edit>
  </match>
  <match target="pattern">
    <test qual="first" name="genericfamily" compare="eq">
      <const>sans-serif</const>
    </test>
    <edit name="family" mode="append">
      <string>sans-serif</string>
    </edit>
  </match>
  <match target="pattern">
    <test qual="first" name="genericfamily" compare="eq">
      <const>monospace</const>
    </test>
    <edit name="family" mode="append">
      <string>monospace</string>
    </edit>
  </match>
  <match target="pattern">
    <test qual="first" name="genericfamily" compare="eq">
      <const>emoji</const>
    </test>
    <edit name="family" mode="append">
      <string>emoji</string>
    </edit>
  </match>
  <match target="pattern">
    <test qual="first" name="genericfamily" compare="eq">
      <const>math</const>
    </test>
    <edit name="family" mode="append">
      <string>math</string>
    </edit>
  </match>

  <!--
      If the font still has no generic name, add sans-serif
  -->
  <match target="pattern">
	<test qual="all" name="family" compare="not_eq">
	  <string>sans-serif</string>
	</test>
	<test qual="all" name="family" compare="not_eq">
	  <string>serif</string>
	</test>
	<test qual="all" name="family" compare="not_eq">
	  <string>monospace</string>
	</test>
    <test qual="all" name="genericfamily" compare="contains">
      <const xsi:nil="true" />
    </test>
    <edit name="genericfamily" mode="append">
      <const>sans-serif</const>
    </edit>
  </match>

  <match target="pattern">
	<test qual="all" name="family" compare="not_eq">
	  <string>sans-serif</string>
	</test>
	<test qual="all" name="family" compare="not_eq">
	  <string>serif</string>
	</test>
	<test qual="all" name="family" compare="not_eq">
	  <string>monospace</string>
	</test>
	<edit name="family" mode="append_last">
	  <string>sans-serif</string>
	</edit>
  </match>

</fontconfig>
