Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

"set terminal pdfcairo" and fname question

1,603 views
Skip to first unread message

Louise Hoffman

unread,
Mar 1, 2008, 2:15:50 PM3/1/08
to
Dear readers,

I have compiled the latest cvs version of gnuplot, and when I do this,
I get:

gnuplot> set terminal pdfcairo fname "Times"; set output
'test.pdf';set xlabel 'rtime'; set ylabel 'FPI'; set xrange
[1979:2005]; plot "test.dat" using 3:4 with lines title 'test';set
terminal pdfcairo
Terminal type set to 'pdfcairo'
^
unrecognized terminal option

gnuplot>

if I remove 'fname "Times"' it writes the pdf file.

So here are my questions:

* I would like to use the default Latex font. How do I do that?
* Is it a bug, that the pdf file i zero bytes, if I don't finish the
command with "set terminal pdfcairo" ?

Using Linux Fedora 8.

Hope some one can help me =)

Hugs,
Louise

Ethan Merritt

unread,
Mar 1, 2008, 3:36:52 PM3/1/08
to
In article <86f9d0db-d9c8-4d96...@i12g2000prf.googlegroups.com>,

Louise Hoffman <louise....@gmail.com> wrote:
>Dear readers,
>
>I have compiled the latest cvs version of gnuplot, and when I do this,
>I get:
>
>gnuplot> set terminal pdfcairo fname "Times"; set output
>'test.pdf';set xlabel 'rtime'; set ylabel 'FPI'; set xrange
>[1979:2005]; plot "test.dat" using 3:4 with lines title 'test';set
>terminal pdfcairo
>Terminal type set to 'pdfcairo'
> ^
> unrecognized terminal option

First the easy part:

gnuplot> help set term pdfcairo
Syntax:
set term pdfcairo
{{no}enhanced} {mono|color} {solid|dashed}
{font <font>}
{linewidth <lw>} {rounded|butt} {dashlength <dl>}
{size <XX>{unit},<YY>{unit}}


So, no "fname" option.
I assume you meant
set term pdfcairo font "Times"

That will almost certainly work, because it is very likely you have
a font named "Times" installed.


>So here are my questions:
>
>* I would like to use the default Latex font. How do I do that?

Now it gets harder :-(

By "the default Latex font", I guess you mean 10 pt Computer Modern.
There are various conversions of this font to formats linux can use,
but I don't know which of these might be present on your system.
Mine has, for example:
/usr/share/texmf/fonts/type1/bluesky/cm/cmr10.pfb
There is also a cmr10.ttf out there somewhere, but I don't have a copy.
So the first thing is to make sure you actually have such a font
installed on your system.

Now you have to make sure that the cairo libraries know where to
find your fonts. This is where my knowledge becomes very sketchy.
Some recent linux systems use a font management package called "fontconfig".
If this is the case on yours, then look for a file
/etc/fonts/local.conf
and make sure it contains an entry for the directory your TeX fonts are in.
Mine has, for instance:
<dir>/usr/local/share/ttfonts</dir>
but if I wanted cairo to find the TeX fonts I think I'd have to add
<dir>/usr/share/texmf/fonts/type1/bluesky/cm/</dir>

Finally, you need to refer to the font by its proper name.
This may depend on the specific version of the font you have.
There may be a way to assign aliases or synonyms in fontconfig, but I don't
know what it is. In the case of /usr/share/texmf/fonts/type1/bluesky/cm/cmr10.pfb
the font name is CMR10 (note uppercase).

So if you have the font, and the cairo library knows how to find it
(which may or may not involve fontconfig), then you would say:
set term pdfcairo font "CMR10"

>* Is it a bug, that the pdf file i zero bytes, if I don't finish the
>command with "set terminal pdfcairo" ?

I don't understand the question. Finish what command?

Since pdf files can hold multiple plots, the file is not complete until
you explicitly tell gnuplot you have no more plots to put in it.
This happens automatically if you exit gnuplot, but you could also
use the command
unset output


I hope that helps
--
Ethan A Merritt

Louise Hoffman

unread,
Mar 1, 2008, 4:31:36 PM3/1/08
to
> First the easy part:
>
> gnuplot> help set term pdfcairo
> Syntax:
> set term pdfcairo
> {{no}enhanced} {mono|color} {solid|dashed}
> {font <font>}
> {linewidth <lw>} {rounded|butt} {dashlength <dl>}
> {size <XX>{unit},<YY>{unit}}
>
> So, no "fname" option.

So "help" can take arguments for the command? =) Cool! =)

> I assume you meant
> set term pdfcairo font "Times"

Thanks.

> By "the default Latex font", I guess you mean 10 pt Computer Modern.
> There are various conversions of this font to formats linux can use,
> but I don't know which of these might be present on your system.
> Mine has, for example:
> /usr/share/texmf/fonts/type1/bluesky/cm/cmr10.pfb

I have that one too.

> There is also a cmr10.ttf out there somewhere, but I don't have a copy.
> So the first thing is to make sure you actually have such a font
> installed on your system.

Must it be in .ttf format? I have all the Computer Modern files in
/usr/share/texmf/fonts/type1/bluesky/cm/

which are in .pfb format.


> Now you have to make sure that the cairo libraries know where to
> find your fonts. This is where my knowledge becomes very sketchy.
> Some recent linux systems use a font management package called "fontconfig".
> If this is the case on yours, then look for a file
> /etc/fonts/local.conf
> and make sure it contains an entry for the directory your TeX fonts are in.
> Mine has, for instance:
> <dir>/usr/local/share/ttfonts</dir>
> but if I wanted cairo to find the TeX fonts I think I'd have to add
> <dir>/usr/share/texmf/fonts/type1/bluesky/cm/</dir>

Now I have added that line to my
/etc/fonts/conf.avail/51-local.conf

and have run "fc-cache".

~/.fonts$ fc-list |grep -i cm
cmex10:style=Regular
cmbx10:style=Regular
cmsy10:style=Regular
cmr10:style=Regular
cmmi10:style=Regular
~/.fonts$ fc-list |grep -i com
Computer Modern:style=Regular
~/.fonts$

I didn't had the "Computer Modern" before I added the
<dir>/usr/share/texmf/fonts/type1/bluesky/cm/</dir>

Does that mean that Cairo can see them now?

> Finally, you need to refer to the font by its proper name.
> This may depend on the specific version of the font you have.
> There may be a way to assign aliases or synonyms in fontconfig, but I don't
> know what it is. In the case of /usr/share/texmf/fonts/type1/bluesky/cm/cmr10.pfb
> the font name is CMR10 (note uppercase).

How did you figure that out?

I can't see any difference if trying CRM10/crm10/SomethingRandom10

When you run the fc-list command are yours written like mine?


> So if you have the font, and the cairo library knows how to find it
> (which may or may not involve fontconfig), then you would say:
> set term pdfcairo font "CMR10"

So I guess Cairo can't see the fonts then...

> I don't understand the question. Finish what command?
>
> Since pdf files can hold multiple plots, the file is not complete until
> you explicitly tell gnuplot you have no more plots to put in it.
> This happens automatically if you exit gnuplot, but you could also
> use the command
> unset output
>
> I hope that helps

It sure did! =) It was exactlt that command that I was looking for =)

Ethan Merritt

unread,
Mar 1, 2008, 5:55:43 PM3/1/08
to
In article <48e9c99d-b6cc-4375...@p73g2000hsd.googlegroups.com>,

Louise Hoffman <louise....@gmail.com> wrote:
>
>> By "the default Latex font", I guess you mean 10 pt Computer Modern.
>> There are various conversions of this font to formats linux can use,
>> but I don't know which of these might be present on your system.
>> Mine has, for example:
>> /usr/share/texmf/fonts/type1/bluesky/cm/cmr10.pfb
>
>> There is also a cmr10.ttf out there somewhere, but I don't have a copy.
>
>Must it be in .ttf format? I have all the Computer Modern files in
>/usr/share/texmf/fonts/type1/bluesky/cm/
>which are in .pfb format.

That's fine.

>> but if I wanted cairo to find the TeX fonts I think I'd have to add
>> <dir>/usr/share/texmf/fonts/type1/bluesky/cm/</dir>
>
>Now I have added that line to my
>/etc/fonts/conf.avail/51-local.conf
>
>and have run "fc-cache".
>
>~/.fonts$ fc-list |grep -i cm
>cmex10:style=Regular
>cmbx10:style=Regular
>cmsy10:style=Regular
>cmr10:style=Regular
>cmmi10:style=Regular
>~/.fonts$ fc-list |grep -i com
>Computer Modern:style=Regular
>~/.fonts$
>
>I didn't had the "Computer Modern" before I added the
><dir>/usr/share/texmf/fonts/type1/bluesky/cm/</dir>

Looks good. I didn't know about that fc-list command.

>Does that mean that Cairo can see them now?

So far as I know, yes. But I already said I'm rather hazy on this
new mechanism for font management.

>> Finally, you need to refer to the font by its proper name.
>> This may depend on the specific version of the font you have.
>> There may be a way to assign aliases or synonyms in fontconfig, but I don't
>> know what it is. In the case of /usr/share/texmf/fonts/type1/bluesky/cm/cmr10.pfb
>> the font name is CMR10 (note uppercase).
>
>How did you figure that out?

It says so in the first 40 bytes of the cmr10.pfb file.
Also I tried it :-)

>I can't see any difference if trying CRM10/crm10/SomethingRandom10
>When you run the fc-list command are yours written like mine?

Yes.

>> So if you have the font, and the cairo library knows how to find it
>> (which may or may not involve fontconfig), then you would say:
>> set term pdfcairo font "CMR10"
>
>So I guess Cairo can't see the fonts then...

Hmm. Well in pdfcairo it works for me, using either lower case or
upper case cmr10. PostScript requires upper case, but apparently cairo
doesn't care. The system may perform some addition step automatically
to publish the font list, but if so I don't know how to do it manually.

If I instead say:
set term pdfcairo font "cmmi10"
set output 'cmmi10.pdf'
load 'charset.dem'
I get the italic variant of the same font.

--
Ethan A Merritt

Louise Hoffman

unread,
Mar 1, 2008, 6:24:56 PM3/1/08
to
Now it works =)

Thank you very much for your detailed reply! =)

After I changed font to "Computer Modern" (which rendered the plot
without text), and then changed font to "cmr10", it worked =)

About the size of the plot. I don't understand how gnuplot can force a
plot size without the aspect become wrong?

What does it infact mean to set a size for a PDF file? Isn't it pure
vector?

From "help set term pdfcairo":
"The default size for the output is 5 inches x 3 inches."

Louise Hoffman

unread,
Mar 1, 2008, 8:27:24 PM3/1/08
to
Please forget about the size question =)

Of course something have to bound it, either pdf its self or Latex =)

Dan

unread,
Mar 3, 2008, 5:02:03 PM3/3/08
to
On Mar 1, 4:55 pm, merr...@u.washington.edu (Ethan Merritt) wrote:

>
> If I instead say:
> set term pdfcairo font "cmmi10"
> set output 'cmmi10.pdf'
> load 'charset.dem'
> I get the italic variant of the same font.

Not quite. The italic version of cmr10 is cmti10 ("ti" for "text
italic").
With cmmi10 you get the "math italic" font. This differs from cmti
not only in shapes (slightly more slanted and wider) and metrics
(mostly no kerning pairs), but also in glyphs covered (lowercase
greek letters vs. ligatures and accents).


Dan

0 new messages