{png,pdf}cairo terminals and font size

View: New views
5 Messages — Rating Filter:   Alert me  

{png,pdf}cairo terminals and font size

by Allin Cottrell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I like the *cairo terminals a lot: PNG looks good on screen and
PDF is good for publication-quality output; and these two
terminals share a common command-set with high fidelity, since
they use a common back-end.  Except for one thing...

The help for both pngcairo and pdfcairo says that the default size
for fonts is 6 points.  That's fine, and if you go with the
default you get quite consistent-looking output from the two
terminals.

But if you alter the size, an inconsistency emerges.  Suppose I'd
prefer 8 points.  I do my PNG plot using

set term pngcairo font ",8"

then do my PDF plot using

set term pdfcairo font ",8"

Relative to the "6-point" baseline, the PNG file shows a smaller
font (8 < 6, hmm) while the PDF plot shows a larger font (8 > 6).

I'm happy to take a look at the code and see if I can come up with
a patch for this.  But I'd rather hear any comments first.

Allin Cottrell

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta

Re: {png,pdf}cairo terminals and font size

by Ethan Merritt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wednesday 09 September 2009, Allin Cottrell wrote:

>
> I like the *cairo terminals a lot: PNG looks good on screen and
> PDF is good for publication-quality output; and these two
> terminals share a common command-set with high fidelity, since
> they use a common back-end.  Except for one thing...
>
> The help for both pngcairo and pdfcairo says that the default size
> for fonts is 6 points.  That's fine, and if you go with the
> default you get quite consistent-looking output from the two
> terminals.
>
> But if you alter the size, an inconsistency emerges.  Suppose I'd
> prefer 8 points.  I do my PNG plot using
>
> set term pngcairo font ",8"
>
> then do my PDF plot using
>
> set term pdfcairo font ",8"
>
> Relative to the "6-point" baseline, the PNG file shows a smaller
> font (8 < 6, hmm) while the PDF plot shows a larger font (8 > 6).
>
> I'm happy to take a look at the code and see if I can come up with
> a patch for this.  But I'd rather hear any comments first.

I don't see anything immediately in looking at the code.
It really is initialized to 6, but after that it seems to just pass
through any request to the cairo library.

The whole idea of "font size" in a png image is kind of arbitrary anyhow,
since it depends entirely on the pixel size of the device it is viewed on.
Perhaps there is some "pixels per inch" setting in the cairo context that
can be tweaked?

        Ethan

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta

Re: {png,pdf}cairo terminals and font size

by Allin Cottrell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Wed, 9 Sep 2009, Ethan Merritt wrote:

> On Wednesday 09 September 2009, Allin Cottrell wrote:
> >
> > I like the *cairo terminals a lot: PNG looks good on screen and
> > PDF is good for publication-quality output; and these two
> > terminals share a common command-set with high fidelity, since
> > they use a common back-end.  Except for one thing...
> >
> > The help for both pngcairo and pdfcairo says that the default size
> > for fonts is 6 points.  That's fine, and if you go with the
> > default you get quite consistent-looking output from the two
> > terminals.
> >
> > But if you alter the size, an inconsistency emerges.  Suppose I'd
> > prefer 8 points.  I do my PNG plot using
> >
> > set term pngcairo font ",8"
> >
> > then do my PDF plot using
> >
> > set term pdfcairo font ",8"
> >
> > Relative to the "6-point" baseline, the PNG file shows a smaller
> > font (8 < 6, hmm) while the PDF plot shows a larger font (8 > 6).
> >
> > I'm happy to take a look at the code and see if I can come up with
> > a patch for this.  But I'd rather hear any comments first.
>
> I don't see anything immediately in looking at the code.
> It really is initialized to 6, but after that it seems to just pass
> through any request to the cairo library.

Ah, in cairo.trm we have two alternative default initializations,
CAIROPDF_PARAMS_DEFAULT and CAIROPNG_PARAMS_DEFAULT; the former
specifies a 6-point font and the latter specifies 12-point.

> The whole idea of "font size" in a png image is kind of arbitrary anyhow,
> since it depends entirely on the pixel size of the device it is viewed on.

Yes, agreed, there is a degree of freedom here, and I think the
following may be the implicit logic of how that degree of
freedom is used at present:

* In pdfcairo a 6-point font looks appropriate.

* We want the default appearance of PNG to be similar to PDF.

* You get similar-looking output by setting a fontsize of 12 for
pngcairo.

* So we'll call that (fontsize = 12) "6 points" in the doc for
pngcairo.

This seems alright until the user changes the font size in
pngcairo, and sees that "8 point" comes out smaller than "6
point".

What's to be done?  One option would be to multiply the user's
font size specification by 2 in the case of pngcairo, to make it
consistent with the "6 point" default. That is, if I say

set term pngcairo font "foo,8"

the actual size sent to the driver is 16.

The alternative would be to amend the doc for pngcairo to say that
the default is 12 points.  This has the advantage that it doesn't
change the output of existing gnuplot scripts, but the
disadvantage that it ratifies the situation where you have to
apply a factor of 2 to the font size if you want comparable output
from pdfcairo and pngcairo (in the case where you're not just
accepting the default size).

Allin Cottrell


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta

Re: {png,pdf}cairo terminals and font size

by Ethan Merritt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thursday 10 September 2009 11:38:09 Allin Cottrell wrote:
> On Wed, 9 Sep 2009, Ethan Merritt wrote:
> > I don't see anything immediately in looking at the code.
> > It really is initialized to 6, but after that it seems to just pass
> > through any request to the cairo library.
>
> Ah, in cairo.trm we have two alternative default initializations,
> CAIROPDF_PARAMS_DEFAULT and CAIROPNG_PARAMS_DEFAULT; the former
> specifies a 6-point font and the latter specifies 12-point.

Guess I missed that in my quick look.
 

> What's to be done?  One option would be to multiply the user's
> font size specification by 2 in the case of pngcairo, to make it
> consistent with the "6 point" default. That is, if I say
>
> set term pngcairo font "foo,8"
>
> the actual size sent to the driver is 16.
>
> The alternative would be to amend the doc for pngcairo to say that
> the default is 12 points.  This has the advantage that it doesn't
> change the output of existing gnuplot scripts, but the
> disadvantage that it ratifies the situation where you have to
> apply a factor of 2 to the font size if you want comparable output
> from pdfcairo and pngcairo (in the case where you're not just
> accepting the default size).

The issue is more general that just comparing pdfcairo and pngcairo.
For instance, 'set term post' defaults to 7x10" output, but
'set term post eps' defaults to half of that: 3.5"x5".  Yet they
both claim to have the same default font size.

My inclination is to add a "fontscale" option for all terminal drivers,
analogous to the "linewidth" and "dashlength" terminal options.
Like these, it would be interpreted as "whatever font size was requested,
multiply it by this scale factor before using it".  

Then the font sizes mentioned explicitly in a script could be used
without change, so long as you added an appropriate scaling factor
in the 'set term' command.

        Ethan



--
Ethan A Merritt
Biomolecular Structure Center
University of Washington, Seattle 98195-7742

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta

Re: {png,pdf}cairo terminals and font size

by Petr Mikulik :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> My inclination is to add a "fontscale" option for all terminal drivers,
> analogous to the "linewidth" and "dashlength" terminal options.
> Like these, it would be interpreted as "whatever font size was requested,
> multiply it by this scale factor before using it".  
>
> Then the font sizes mentioned explicitly in a script could be used
> without change, so long as you added an appropriate scaling factor
> in the 'set term' command.

That would be great especially for inset figures in multiplot, where smaller
font is  a must. A simple command such as "set termoption fontscale 0.5"
would make the job much easier.

---
PM

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@...
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta