Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I access various true type fonts through gnuplot with png terminal?

Tags:

gnuplot

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!

like image 790
phoganuci Avatar asked Nov 29 '22 06:11

phoganuci


2 Answers

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.

like image 184
otto.poellath Avatar answered Dec 06 '22 16:12

otto.poellath


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.

like image 22
Seemsman Avatar answered Dec 06 '22 15:12

Seemsman