Usage of "{}" as default fontname for gnuplot

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Usage of "{}" as default fontname for gnuplot

benjamin lindner-3
Hello,

currently, for the gnuplot graphics backend, the default font "*" is
translated into "{}" before passing to gnuplot.
This causes troubles with the windows terminal, and I wondered if "{}"
is a valid gnuplot fontname specification.
I glanced through gnuplot's manual, but there is no mentioning of "{}"
for a font name - for enhanced text, yes, but not fontname.
So, shouldn't it be rather "" (empty) for the default fontname?

benjamin
Reply | Threaded
Open this post in threaded view
|

Re: Usage of "{}" as default fontname for gnuplot

benjamin lindner-3
> Hello,
>
> currently, for the gnuplot graphics backend, the default font "*" is
> translated into "{}" before passing to gnuplot.
> This causes troubles with the windows terminal, and I wondered if "{}"
> is a valid gnuplot fontname specification.
> I glanced through gnuplot's manual, but there is no mentioning of "{}"
> for a font name - for enhanced text, yes, but not fontname.
> So, shouldn't it be rather "" (empty) for the default fontname?

Sorry clicked send too soon, forgot the details - there's the
offending translation:

diff --git a/scripts/plot/__go_draw_axes__.m b/scripts/plot/__go_draw_axes__.m
--- a/scripts/plot/__go_draw_axes__.m
+++ b/scripts/plot/__go_draw_axes__.m
@@ -2084,7 +2084,7 @@

 function [f, s, fnt, it, bld] = get_fontname_and_size (t)
   if (isempty (t.fontname) || strcmp (t.fontname, "*"))
-    fnt = "{}";
+    fnt = "";
   else
     fnt = t.fontname;
   endif

The manifestation is, that enhanced ylabel text is printed wrong, e.g.
ylabel("foo in mm^2")
results in the superscipt "2" being not rotated but horizontal.

The problem can be reproduced within gnuplot by
  set term windows enhanced
  set ylabel "foo in mm^2" font "{},10"
  plot sin(x)
which fails, but
  set ylabel "foo in mm^2" font ",10"
works as expected
Reply | Threaded
Open this post in threaded view
|

Re: Usage of "{}" as default fontname for gnuplot

David Bateman-2
Benjamin Lindner wrote:

>> Hello,
>>
>> currently, for the gnuplot graphics backend, the default font "*" is
>> translated into "{}" before passing to gnuplot.
>> This causes troubles with the windows terminal, and I wondered if "{}"
>> is a valid gnuplot fontname specification.
>> I glanced through gnuplot's manual, but there is no mentioning of "{}"
>> for a font name - for enhanced text, yes, but not fontname.
>> So, shouldn't it be rather "" (empty) for the default fontname?
>>    
>
> Sorry clicked send too soon, forgot the details - there's the
> offending translation:
>
> diff --git a/scripts/plot/__go_draw_axes__.m b/scripts/plot/__go_draw_axes__.m
> --- a/scripts/plot/__go_draw_axes__.m
> +++ b/scripts/plot/__go_draw_axes__.m
> @@ -2084,7 +2084,7 @@
>
>  function [f, s, fnt, it, bld] = get_fontname_and_size (t)
>    if (isempty (t.fontname) || strcmp (t.fontname, "*"))
> -    fnt = "{}";
> +    fnt = "";
>    else
>      fnt = t.fontname;
>    endif
>
> The manifestation is, that enhanced ylabel text is printed wrong, e.g.
> ylabel("foo in mm^2")
> results in the superscipt "2" being not rotated but horizontal.
>
> The problem can be reproduced within gnuplot by
>   set term windows enhanced
>   set ylabel "foo in mm^2" font "{},10"
>   plot sin(x)
> which fails, but
>   set ylabel "foo in mm^2" font ",10"
> works as expected
>
>  

Please see the bug report of why this change was made

https://savannah.gnu.org/bugs/index.php?32118

No I didn't test under windows, so didn't see this issue. However making
the change you suggest will make the issue with the TeX interpreter
under gnuplot come back

D.

Reply | Threaded
Open this post in threaded view
|

Re: Usage of "{}" as default fontname for gnuplot

benjamin lindner-3
> Please see the bug report of why this change was made
>
> https://savannah.gnu.org/bugs/index.php?32118
>
> No I didn't test under windows, so didn't see this issue. However making
> the change you suggest will make the issue with the TeX interpreter
> under gnuplot come back

I can't quite follow the reasoning in the bug report, nor can I
reproduce the problem - perhaps I am missing something?

Here is what I tried:

With both 4.4.2 and a recent 4.5.0 CVS gnuplot:
    set term windows enhanced
    set label 1 "{/Symbol \\362}@_0^x e^{-x} dx" at  1.0,0.5 left
    plot x
works as expected.
    set label 1 "{/Symbol \\362}@_0^x e^{-x} dx" at  1.0,0.5 left font ",20"
also works as expected - the whole string is now printed with fontsize 20
The same goes for the wxt terminal, and for the postscript terminal.

So I don't see why you have to issue font "{},20" - it's AFAICS not
valid gnuplot syntax. And it exposes the here reported bug that
rotated ylabel text is no longer rotated - and others:
Try the following:

set term post enhanced font "Helvetica,14"
set output "test.ps"
set ylabel "foo in mm^2" font ",10"
set label 1 "{/Symbol \\362}@_0^x e^{-x} dx" at  1.0,0.5 left font ",20"
plot x
set output

set output "test2.ps"
set ylabel "foo in mm^2" font "{},10"
set label 1 "{/Symbol \\362}@_0^x e^{-x} dx" at  1.0,0.5 left font "{},20"
plot x
set output

I see that test.ps looks fine, but test2.ps has the wrong font for
both the ylabel and the text label.

I also tested your example in the bug report.
   set(gca,"fontname","*");
   text(0.5,0.5,'\int_0^x e^(-x) dx','fontsize',20)
and
   set (gca, "fontname", "Arial")
   text(0.5,0.5,'\int_0^x e^(-x) dx','fontsize',20)
both yield the same (correct) result - where the correct result is
that only the "(" parenthesis is displayed as superscript.
And both yield the same result with either the "{},20" or the ",20"
font setting.

So I am - back at the start - a bit confused as to the original bug report.
What did you see without the "{}" font setting?

benjamin
Reply | Threaded
Open this post in threaded view
|

Re: Usage of "{}" as default fontname for gnuplot

bpabbott
Administrator
On Feb 17, 2011, at 3:18 AM, Benjamin Lindner wrote:

>> Please see the bug report of why this change was made
>>
>> https://savannah.gnu.org/bugs/index.php?32118
>>
>> No I didn't test under windows, so didn't see this issue. However making
>> the change you suggest will make the issue with the TeX interpreter
>> under gnuplot come back
>
> I can't quite follow the reasoning in the bug report, nor can I
> reproduce the problem - perhaps I am missing something?
>
> Here is what I tried:
>
> With both 4.4.2 and a recent 4.5.0 CVS gnuplot:
>    set term windows enhanced
>    set label 1 "{/Symbol \\362}@_0^x e^{-x} dx" at  1.0,0.5 left
>    plot x
> works as expected.
>    set label 1 "{/Symbol \\362}@_0^x e^{-x} dx" at  1.0,0.5 left font ",20"
> also works as expected - the whole string is now printed with fontsize 20
> The same goes for the wxt terminal, and for the postscript terminal.
>
> So I don't see why you have to issue font "{},20" - it's AFAICS not
> valid gnuplot syntax. And it exposes the here reported bug that
> rotated ylabel text is no longer rotated - and others:
> Try the following:
>
> set term post enhanced font "Helvetica,14"
> set output "test.ps"
> set ylabel "foo in mm^2" font ",10"
> set label 1 "{/Symbol \\362}@_0^x e^{-x} dx" at  1.0,0.5 left font ",20"
> plot x
> set output
>
> set output "test2.ps"
> set ylabel "foo in mm^2" font "{},10"
> set label 1 "{/Symbol \\362}@_0^x e^{-x} dx" at  1.0,0.5 left font "{},20"
> plot x
> set output
>
> I see that test.ps looks fine, but test2.ps has the wrong font for
> both the ylabel and the text label.
>
> I also tested your example in the bug report.
>   set(gca,"fontname","*");
>   text(0.5,0.5,'\int_0^x e^(-x) dx','fontsize',20)
> and
>   set (gca, "fontname", "Arial")
>   text(0.5,0.5,'\int_0^x e^(-x) dx','fontsize',20)
> both yield the same (correct) result - where the correct result is
> that only the "(" parenthesis is displayed as superscript.
> And both yield the same result with either the "{},20" or the ",20"
> font setting.
>
> So I am - back at the start - a bit confused as to the original bug report.
> What did you see without the "{}" font setting?
>
> benjamin

The original report by Michael Godfrey indicates that when using the FLTK backend and the fontname "*", that TeX style exponentiation did not work. There was no problem for the gnuplot backend.

Did you try the examples for the FLTK backend?

Ben




Reply | Threaded
Open this post in threaded view
|

Re: Usage of "{}" as default fontname for gnuplot

benjamin lindner-3
> The original report by Michael Godfrey indicates that when using the FLTK backend and the fontname "*", that TeX style exponentiation did not work. There was no problem for the gnuplot backend.

They talked about 'either backend' so I assumed gnuplot was affected as well.
If it's a fltk-only problem, then the "{}" fix should probably be
specific for fltk?

> Did you try the examples for the FLTK backend?

With the fltk backend, I don't get any enhanced text processing at
all. Even with
   text(0.5,0.5,'\int_0^x e^(-x) dx','fontsize',20, 'interpreter', 'tex')
The string is shown as literal string (at correct font size & rotation)

I am doing this on the release-3-4-0 tag, though, so perhaps I need to
abandon it and move to current tip.
Reply | Threaded
Open this post in threaded view
|

Re: Usage of "{}" as default fontname for gnuplot

bpabbott
Administrator
On Feb 17, 2011, at 7:56 AM, Benjamin Lindner wrote:

>> The original report by Michael Godfrey indicates that when using the FLTK backend and the fontname "*", that TeX style exponentiation did not work. There was no problem for the gnuplot backend.
>
> They talked about 'either backend' so I assumed gnuplot was affected as well.
> If it's a fltk-only problem, then the "{}" fix should probably be
> specific for fltk?
>
>> Did you try the examples for the FLTK backend?
>
> With the fltk backend, I don't get any enhanced text processing at
> all. Even with
>   text(0.5,0.5,'\int_0^x e^(-x) dx','fontsize',20, 'interpreter', 'tex')
> The string is shown as literal string (at correct font size & rotation)
>
> I am doing this on the release-3-4-0 tag, though, so perhaps I need to
> abandon it and move to current tip.

Ok. You're seeing the problem that was reported in the bug tracker. If you add the fontname, then it should work.

        text(0.5,0.5,'\int_0^x e^(-x) dx','fontsize',20, 'fontname', 'Helvetica', 'interpreter', 'tex')

... assuming you have "Helvetica".

We may need to bundle a fsf font with Octave to properly resolved this problem. There are font's available, but I don't know how this would be done.

Ben
Reply | Threaded
Open this post in threaded view
|

Re: Usage of "{}" as default fontname for gnuplot

benjamin lindner-3
> Ok. You're seeing the problem that was reported in the bug tracker. If you add the fontname, then it should work.
>
>        text(0.5,0.5,'\int_0^x e^(-x) dx','fontsize',20, 'fontname', 'Helvetica', 'interpreter', 'tex')
>
> ... assuming you have "Helvetica".

I fear I am making a fool of myself here, I still don't really see it.

I tried

figure(1);
set(gca,'fontname','Arial');
plot([0:1], [0:1]);
text(0.5,0.5,'\int_0^x e^(-x) dx','fontsize',20);
text(0.3,0.3,'\int_0^x e^(-x)
dx','fontsize',20,'interpreter','tex','fontname','Arial');
ylabel('foo in mm^2');

figure(2);
set(gca,'fontname','*');
plot([0:1], [0:1]);
text(0.5,0.5,'\int_0^x e^(-x) dx','fontsize',20);
text(0.3,0.3,'\int_0^x e^(-x)
dx','fontsize',20,'interpreter','tex','fontname','Arial');
ylabel('foo in mm^2');

for both fltk and gnuplot (4.5.0 CVS) backend, and for both with the
"{}" part in __go_draw_axes__.m enabled and disabled.

For the fltk backend all 4 figures look exactly alike - no enhanced
text, just literal text (both texts and the ylabel)

For the gnuplot backend, the respective pair of figures looks again
alike, now with enhanced text (both texts and the ylabel), but with
the "{}" setting in __go_draw_axes__.m, part of ylabel is not rotated.
Without the "{}" setting, the ylabel is correctly displayed.

I guess there is something else screwed up with my setup then. Hooray...
Reply | Threaded
Open this post in threaded view
|

Re: Usage of "{}" as default fontname for gnuplot

bpabbott
Administrator
On Feb 17, 2011, at 08:55 AM, Benjamin Lindner <[hidden email]> wrote:

> Ok. You're seeing the problem that was reported in the bug tracker. If you add the fontname, then it should work.
>
>        text(0.5,0.5,'\int_0^x e^(-x) dx','fontsize',20, 'fontname', 'Helvetica', 'interpreter', 'tex')
>
> ... assuming you have "Helvetica".

I fear I am making a fool of myself here, I still don't really see it.

I tried

figure(1);
set(gca,'fontname','Arial');
plot([0:1], [0:1]);
text(0.5,0.5,'\int_0^x e^(-x) dx','fontsize',20);
text(0.3,0.3,'\int_0^x e^(-x)
dx','fontsize',20,'interpreter','tex','fontname','Arial');
ylabel('foo in mm^2');

figure(2);
set(gca,'fontname','*');
plot([0:1], [0:1]);
text(0.5,0.5,'\int_0^x e^(-x) dx','fontsize',20);
text(0.3,0.3,'\int_0^x e^(-x)
dx','fontsize',20,'interpreter','tex','fontname','Arial');
ylabel('foo in mm^2');

for both fltk and gnuplot (4.5.0 CVS) backend, and for both with the
"{}" part in __go_draw_axes__.m enabled and disabled.

For the fltk backend all 4 figures look exactly alike - no enhanced
text, just literal text (both texts and the ylabel)

For the gnuplot backend, the respective pair of figures looks again
alike, now with enhanced text (both texts and the ylabel), but with
the "{}" setting in __go_draw_axes__.m, part of ylabel is not rotated.
Without the "{}" setting, the ylabel is correctly displayed.

I guess there is something else screwed up with my setup then. Hooray...
 
Ok. Now that I've had my coffee .... and can think.

My experience is also that fltk backend only displays the literal text.

I'm also running FLTK 11.10.

Sorry for the confusion.

Ben