0

I am using strwidth() function (see link below) and looking for a solution to define font-alias for Times New Roman on Linux

R Graph - graphical string measurement

Could we define font-alias as described for svglite in below link

https://cran.r-project.org/web/packages/svglite/vignettes/fonts.html

R007
  • 101
  • 1
  • 13

1 Answers1

2

Most Linux distros use Fontconfig to define font aliases. These should be respected by most of the graphical devices that R uses.

For example, to define Tinos as an alias for Times New Roman, you can add the following lines to the file ~/.config/fontconfig/fonts.conf, between the <fontconfig> and </fontconfig> tags.

<match>
    <test name="family"><string>Times New Roman</string></test>
    <edit name="family" mode="assign" binding="strong">
      <string>Tinos</string>
    </edit>
</match>

Note that, if ~/.config/fontconfig/fonts.conf does not exist already, you will need to create it and put the following lines into it first

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
</fontconfig>

If you want to apply these changes system wide rather than just for one user, then instead edit etc/fonts/local.conf instead.

dww
  • 30,425
  • 5
  • 68
  • 111
  • thanks, this answers my question. Your response triggered whether I should be installing Microsoft Fonts on Linux. I started a new thread for that question. https://stackoverflow.com/questions/62347140/install-microsoft-fonts-on-linux-and-use-it-in-r – R007 Jun 12 '20 at 16:01