You are not logged in.

#1 2017-06-10 07:51:05

clayman
Member
Registered: 2013-05-26
Posts: 19

[SOLVED] Fontconfig matches incorrect face in a family

Hi guys,

I have a question to all the Fontconfig gurus out here. Recently, I started using the amazing Operator Mono SSm font, but I am facing an issue where whenever I pick this font family for monospace font in an application (Firefox, Visual Studio Code,...), Fontconfig picks the bold face as the default representation and not the "Book" face, which is the regular weight in this case.

How can I make FC choose the book face? I have gone through the basic FC user documentation, but I am pretty new to all this and I probably haven't fully grasped all the concepts and details described therein. Any hints or pointers you guys can provide would therefore be much appreciated.

Thanks. smile

Last edited by clayman (2017-06-11 09:39:49)

Offline

#2 2017-06-11 09:39:32

clayman
Member
Registered: 2013-05-26
Posts: 19

Re: [SOLVED] Fontconfig matches incorrect face in a family

All right, it seems that I have solved the issue. Upon closer inspection of values of the attributes Fontconfig expects the font to have and the actual values from the font, I noticed that there are fairly large discrepancies in the expected/actual value of the weight attribute. FC expects the Regular weight to be equal to 80, but that is the weight the Bold face of this font has, which is why the bold face was picked by FC instead of the Book face. I had to essentially remap the weight values expected by FC to the actual values indicated by the faces of this font See EDIT below.

Below is the complete content of my own FC configuration file I have created for this purpose and stored at ~/.config/fontconfig/conf.d/90-operator-mono-ssm.conf. It has a few things extra apart from the weight reset code. It seems that Firefox does not care much about this setting, though, since it keeps rendering the font in bold face. I will have to keep digging a little more to fix this, but at least applications such as Visual Studio Code and Atom now display the font in the Book face, if I do not explicitly pick a different weight.

EDIT: Updated the file. It turns out there was an error in the original version and I also did not need all the match branches to assign specific weights to all the faces. Just the one for the generic family name is sufficient.

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
  <!--
	Settings specific to Operator Mono SSm
  -->  
  <alias>
    <!-- Set Operator Mono SSm as a monospace font -->
    <family>Operator Mono SSm</family>
    <default><family>monospace</family></default>
  </alias>
  <match target="font">
    <!-- Render it a little lighter -->
    <test name="family">
      <string>Operator Mono SSm</string>
    </test>
    <edit name="lcdfilter">
      <const>lcdlight</const>
	</edit>
  </match>

  <!-- 
  	The font has weights off with regards to what
	Fontconfig considers the proper weights for the
	given thickness. However, it is sufficient to just
        assign weight to the generic "family only" name pattern.
  -->
  <match target="pattern">
	<test target="pattern" name="family" compare="eq">
		<string>Operator Mono SSm</string>
	</test>
	<edit name="weight" mode="assign">
		<int>53</int>
	</edit>
  </match>
</fontconfig>

Last edited by clayman (2017-06-11 10:07:24)

Offline

Board footer

Powered by FluxBB