2

I am frequently using the Generic Mapping Tools (GMT) to generate high-quality geographical maps in postscript format. Recently, I wanted to switch from the standard postscript fonts (Helvetica, Courrier, etc. available by default in GMT) to other fonts I have installed on my computer.

I massively googled this question, and all I've found is that it is possible to use custom fonts as following:

  1. Create CUSTOM_font_info.d file in the local directory or in the GMT's share/pslib of the GMT directory and specify the custom font name, size and encoding

      # CUSTOM_font_info.d
    
      YourCustomFont     0.700    0
    
  2. In your bash script set the FONT variable with your custom font (gmt set FONT YourCustomFont)

Once I did that, I executed my GMT script, no warning or error occurred, but the font on my figure is not the one I wanted. Do anyone see what's going on ?

By the way, I am running GMT 5.1.2 under Mac OS X 10.11.2, and the font I want to use is CMU Sans Serif (downloaded both as .tff and .dfont formats).

Leonard
  • 2,510
  • 18
  • 37
  • From the little searching I've done the way to set the `FONT` variable seems to be `gmt gmtset FONT YourCustomFont`. Is that what you tried? – Etan Reisner Jan 29 '16 at 14:40
  • Yes, that's the way I did. What's strange is that when GMT doesn't find the font, it usually returns a warning message to say the font it is using instead. In my case I have no warning message but the font is the default one. – Leonard Jan 30 '16 at 10:24

1 Answers1

0

I've just encountered the same symptoms and managed to solve the problem. In my case the font I wanted to use was Libris ADF Std. I had

LibrisADFStd 0.7 0

in the font definition file and

gmt set FONT LibrisADFStd

in my GMT script. I verified the name using fc-list on my Ubuntu 16.04 system. Like you, I found that the file processed without errors or warnings, but the output file didn't display with the desired font -- it fell back to Courier. However, the font was clearly being found since specifying a non-existent font does produce a warning from GMT.

What I eventually found was that the font has a ‘PostScript name’ which differs from its usual system name. Running fc-query on the font's OTF file gave, amongst a lot of other output, the following:

postscriptname: "LibrisADFStd-Regular"(s)

Changing LibrisADFStd to LibrisADFStd-Regular in the GMT font definition file and script allowed GMT to use the font successfully.

Pont
  • 333
  • 3
  • 12
  • 1
    Thanks for your answer. I tried to apply your recipe: it still doesn't work but I now get the same error as [in the first post of this discussion](http://gmt-help.hawaii.narkive.com/416ouvLj/using-urw-garamond-fonts-in-gmt). Trying to apply the solutions provided in the discussion doesn't change the results. – Leonard May 08 '17 at 08:11