Question

I am trying to output a png image with an arial size 14 font. I use mac OS X 10.6 and did not build GNUPLOT myself. I got the program from a website called High Performance Computing for OS X in the package for Octave. Here is what I entered in gnuplot:

G N U P L O T
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!

Was it helpful?

Solution

The following works on Mac OS X 10.5 with gnuplot installed via MacPorts:

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

The documentation is available via help terminal png (emphasis mine):

If gnuplot was built with support for TrueType (.ttf) or Adobe Type 1 (.pfa) fonts, they may be selected using the 'font {}' option. is either the full pathname to the font file, or a font face name that is assumed to be the first part of a filename in one of the directories listed in the GDFONTPATH environmental variable. That is, 'set term png font "Face"' will look for a font file named either /Face.ttf or /Face.pfa. Both TrueType and Adobe Type 1 fonts are fully scalable and may be rotated through any angle. If no font is specified, gnuplot checks the environmental variable GNUPLOT_DEFAULT_GDFONT to see if there is a preferred default font.

Update: I just noticed that your gnuplot installation complains about "No TTF font support", so the above may not work for you. In order to get true type fonts to work at all, you probably have to re-install gnuplot.

OTHER TIPS

Thanks! The info with $GDFONTPATH was really helpful for on MacOS.

Adding the line:

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

to my /Users/username/.profile solved the Problem for me. Don't forget to source the .profilefile. Or to restart the Terminal. So that the variable gets loaded.

It depends on the terminal type

On (X)Ubuntu LTS GNU/Linux, gnuplot seems to look up fonts in a whole host of directories by default. For example, the following line worked by default with the terminal png:

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

Even though I had no environment variables set and the package manager had previously installed this font in /usr/share/texmf/fonts/opentype/public/tex-gyre. Nice!

However, if I employ the more advanced terminal pngcairo, the very same font is specified by its name; not its filename. Even nicer!

set terminal pngcairo font "TeX Gyre Pagella, 12"

Please, also notice the syntactic difference in specifying the font size.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top