How to access various true type fonts through gnuplot using png terminal?

I am trying to output a png image with an arial 14 font. I am using Mac OS X 10.6 and have not created GNUPLOT myself. I got the program from the High Performance Computing website for OS X in the Octave package. Here is what I introduced in gnuplot:

GNUPLOT Version 4.2 patchlevel 5 last modified Mar 2009 System: Darwin 10.0.0 Copyright (C) 1986 - 1993, 1998, 2004, 2007 - 2009 Thomas Williams, Colin Kelley and many others Type `help` to access the on-line reference manual. The gnuplot FAQ is available from http://www.gnuplot.info/faq/ Send bug reports and suggestions to <http://sourceforge.net/projects/gnuplot> Terminal type set to 'x11' gnuplot> set term png font "arial" 14 Terminal type set to 'png' No TTF font support, using internal non-scalable font ^ invalid color spec, must be xRRGGBB gnuplot> 

Any help would be greatly appreciated. Thanks!

+4
source share
3 answers

On Mac OS X 10.5, it works with gnuplot installed through MacPorts:

 set terminal png font "/Library/Fonts/Arial.ttf" 14 

The documentation is available through the help terminal png (my selection):

If gnuplot was created with support for TrueType (.ttf) or Adobe Type 1 (.pfa), they can be selected using the font {} 'option. either the full path to the font file, or the font is the name of the person that is considered the first part of the file name in one of the directories listed in the GDFONTPATH ​​environment variable. That is, "set term png font" Face "will look for a font file named /Face.ttf or /Face.pfa. Both TrueType and Adobe Type 1 fonts are fully scalable and can rotate at any angle. If the font is not specified, gnuplot checks the GNUPLOT_DEFAULT_GDFONT environment variable to see if there is a preferred default font.

Update: I just noticed that your gnuplot installation complains about “No TTF font support” support, so the above might not work for you. To get true font fonts to work in general, you may have to reinstall gnuplot.

+17
source

Thanks! The information with $ GDFONTPATH ​​was really useful for MacOS.

Adding a line:

 export GDFONTPATH=/System/Library/Fonts:$GDFONTPATH 

in my /Users/username/.profile solved the problem for me. Remember to download the .profile file. Or restart the terminal. So the variable is loading.

+3
source

It depends on the type of terminal

On (X) Ubuntu LTS GNU / Linux , gnuplot seems to be looking for fonts in the whole default directory host. For example, the following line worked by default using terminal png :

 set terminal png font "texgyrepagella-regular.otf" 12 

Even if I did not have the environment variables set, and the package manager previously installed this font in /usr/share/texmf/fonts/opentype/public/tex-gyre . Nice!

However, if I use the more advanced terminal pngcairo , the same font is indicated by its name; not his name. Even nicer!

 set terminal pngcairo font "TeX Gyre Pagella, 12" 

Also note the syntactic difference in determining font size.

+1
source

All Articles