bugGNU Octave - Bugs: bug #49044, gnuplot enhanced text...

 
 

bug #49044: gnuplot enhanced text specification has changed for versions >= 5.0

Submitter:  Avinoam Kalma <avinoam>
Submitted:  Fri 09 Sep 2016 09:33:40 PM UTC
   
 
Category:  Plotting with gnuplot Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Avinoam Open/Closed:  * Closed
Release:  * 4.2.0-rc1 Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 19 Sep 2016 10:40:21 PM UTC, comment #15: 

For the moment, things are okay because the default gnuplot built by MXE does not include wxt or pdfcairo terminals.  Eventually, the quick test that I used for a "windows" terminal (ispc) will need to be improved.  I filed a new bug report about that (bug #49135).

Rik <rik5>
Group administrator
Sun 18 Sep 2016 01:47:35 AM UTC, comment #14: 

I suggest to make the default font "Noto".
https://www.google.com/get/noto/

In worst case people get the same warnings and the font gets
substituted to "Tahoma" (at least this is what happened
with gnuplot 5.0.4 on Win computer where I tried). If
people do not like warnings they can go and install this font.
It is a decent-looking free font (I think it is derivative of DejaVu), supports many languages etc...



Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Sat 17 Sep 2016 11:50:47 PM UTC, comment #13: 

I have built windows binary with you changeset.

Of course, your changeset solves the problem for windows terminal.

However, your patch introduce extra warning for cairo based terminals like wxt, pngcairo and pdfcairo.


*****************************
(The below C:/Programs/gp504-64/bin/gnuplot.exe is full featured
gnuplot from gnuplot official site in my situation.)

Example 1
wxt termimal

Before your pactch

>> gnuplot_binary C:/Programs/gp504-64/bin/gnuplot.exe
>> graphics_toolkit gnuplot
>> setenv GNUTERM wxt
>> plot (rand(5))
>>




After your patch

>> gnuplot_binary C:/Programs/gp504-64/bin/gnuplot.exe
>> graphics_toolkit gnuplot
>> setenv GNUTERM wxt
>> plot (rand(5))
>>
(gnuplot.exe:6116): Pango-WARNING **: couldn't load font "Helvetica Not-Rotated 2
00", falling back to "Sans Not-Rotated 200", expect ugly output.


Example 2
cairo based print devise

Before your patch

>> graphics_toolkit gnuplot
>> setenv GNUTERM windows
>> plot (rand(5));
>> print -dpdfcairo rand.pdf



After your patch

>> gnuplot_binary C:/Programs/gp504-64/bin/gnuplot.exe
>> graphics_toolkit gnuplot
>> setenv GNUTERM windows
>> plot (rand(5));
>> print -dpdfcairo rand.pdf

(gnuplot.exe:3000): Pango-WARNING **: couldn't load font "Helvetica Not-Rotated 1
00", falling back to "Sans Not-Rotated 100", expect ugly output.


But qt terminal does not give warning.

For cairo based terminal, set default is to Helvetica
gives annoying warning.


If I change font specify code from
      fnt = "Helvetica";
to
      fnt = "Arial";

warnings disappear.

Please keep in mind your patch causes extra warning when
octave uses cairo based terminals. 

Tatsuro MATSUOKA <tmacchant>
Sat 17 Sep 2016 02:02:06 PM UTC, comment #12: 

The important point is not whether the system has the Helvetica font--most systems won't--but that the system knows how to map the name "Helvetica" to a real font that does exist on the system.

For Linux platforms, "Sans" appears to be a name that can always be mapped to a real font.  But Windows doesn't always accept that, according to the reports from Avinoam and my own experience with a Windows XP virtual machine.

Try


set (0, "DefaultAxesFontName", "Sans")
graphics_toolkit gnuplot
demo ezmesh 1


For me, that issues about 8 warnings of


Warning:  font "Sans:Bold" not available, trying "Arial" instead.


There are no such warnings if I use "Helvetica" for the default font.

Rik <rik5>
Group administrator
Sat 17 Sep 2016 06:47:16 AM UTC, comment #11: 

I do not think 'Helvetica' is not good solution for windows platform
because windows does not have 'Helvetica' font.

On gnuplot.exe (not wgbnuplot.exe) 5.0.4 from www.gnuplot.info,



set terminal pngcairo font 'Helvetica'
set out 'test.png'
plot x


gives warning:


(gnuplot.exe:8132): Pango-WARNING **: couldn't load font "Helvetica Not-Rotated 240", falling back to "Sans Not-Rotated 240", expect ugly output.


Currently gnuplot embedded with octave does not support cairo based
terminal. However, one can use external gnuplot from official site which supports almost all terminals.
In that case, one can use cairo based print devise.

Perhaps this warning appear on octave command windows.

I am trying make tar ball for the snapshot the dev tree and will build windows binary using mxe-octave.

When test result will be gotten, I will report here.

Tatsuro MATSUOKA <tmacchant>
Sat 17 Sep 2016 03:41:52 AM UTC, comment #10: 

I added support for the new gnuplot 5.0 enhanced text syntax in this cset (http://hg.savannah.gnu.org/hgweb/octave/rev/549f8625a61b).  I also changed the default font on Windows to Helvetica.  This should fix the issues in this report.

Rik <rik5>
Group administrator
Thu 15 Sep 2016 10:10:17 PM UTC, comment #9: 

Re-titling this bug report.  From looking at the gnuplot documentation it is clear that they changed the syntax that they use.

As a test example, try


close all
graphics_toolkit gnuplot
ht = text (0.5, 0.5, "Hello World");
set (ht, "Fontname", "Arial:Bold");


This correctly produces Arial font in Bold.  It looks like Octave's code needs to be updated to detect whether it is running gnuplot versions less than or greater than 5 and then change the commands it issues.  At least for me, "Sans" also works on Windows.  But it does seem just as easy to use "Helvetica" which will get mapped to something and is probably has wider usage.


Rik <rik5>
Group administrator
Thu 15 Sep 2016 05:30:05 AM UTC, comment #8: 

I tried with gnuplot 5.0.4 (gp504-win64-mingw) on win7 and it works
fine (picks up Tahoma Bold font).
Both "Sans Bold" and "Sans:Bold" worked.

I do not know what resolve Sans to Tahoma on windows. Perhaps
this particular version of gnuplot does it.

Dmitri.


(file #38512)

Dmitri A. Sergatskov <dasergatskov>
Thu 15 Sep 2016 04:53:41 AM UTC, comment #7: 

So, I think I was correct in comment #3 that we will have to divide the behavior between Windows platforms and other platforms.

Rik <rik5>
Group administrator
Thu 15 Sep 2016 04:49:27 AM UTC, comment #6: 

It does not work on Windows:


Warning:  font "Sans:Bold" not available, trying "Tahoma" instead.
-verbatim

Avinoam Kalma <avinoam>
Group Member
Wed 14 Sep 2016 10:34:31 PM UTC, comment #5: 

E.g. in gnuplot:


plot sin(x)
set title "sin"
replot
set term pdfcairo font "Sans Bold"
set out "t1.pdf"
replot


the "t1.pdf" is attached.


(file #38511)

Dmitri A. Sergatskov <dasergatskov>
Wed 14 Sep 2016 10:12:08 PM UTC, comment #4: 

On linux you can specify font "Sans" and then it would pick up default fontfamyly (I think on most distros it is DejaVu).
I am not sure if that works for Macos and other windows.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Wed 14 Sep 2016 09:51:20 PM UTC, comment #3: 

I think both things need to be done.  First, ":Bold" should be used when the gnuplot version is >= 5.0.  Second, the default font, which on Linux can be "", should be set to something like "Helvetica", but only for Windows where this is an issue.

Rik <rik5>
Group administrator
Wed 14 Sep 2016 08:28:58 PM UTC, comment #2: 

After changing "-bold" with ":Bold" I still get warnings:


Warning:  font ":Bold" not available, trying "Tahoma" instead.


Because f is empty before the command


f = [f ":Bold"]


Again, if with do not leave f empty in


  if (isempty (t.fontname) || strcmp (t.fontname, "*"))
    fnt = "";
  else
    fnt = t.fontname;
  endif


there will be no warnings. For example:


  if (isempty (t.fontname) || strcmp (t.fontname, "*"))
    fnt = "Helvetica";
  else
    fnt = t.fontname;
  endif




Avinoam Kalma <avinoam>
Group Member
Wed 14 Sep 2016 06:14:41 PM UTC, comment #1: 

I think the warnings are because gnuplot has changed syntax.  See this Stack Overflow article (http://stackoverflow.com/questions/16428338/bold-enhanced-text-in-gnuplot#34402420).

Briefly, it seems that the new syntax uses a colon ':' rather than a dash '-'.

I modified _gnuplot_draw_axes_.m on the Windows side to replace instances of


f = [f "-bold"]


with


f = [f ":Bold"]


and I no longer get warnings.

I'm adding Dan Sebald to the CC list.  This looks like another instance where we need to check _gnuplot_has_feature_ and either use the old syntax ("-bold") or the new syntax (":Bold").


Rik <rik5>
Group administrator
Fri 09 Sep 2016 09:33:40 PM UTC, original submission:  



>> graphics_toolkit gnuplot
>> demo ezmesh 1
ezmesh example 1:
 clf;
 colormap ("default");
 f = @(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2);
 ezmesh (f, [-3, 3]);

>> Warning:  font "-bold" not available, trying "Tahoma" instead.
Warning:  font "-bold" not available, trying "Tahoma" instead.
Warning:  font "-bold" not available, trying "Tahoma" instead.
Warning:  font "-bold" not available, trying "Tahoma" instead.
.....


This is due to:


function [f, s, fnt, it, bld] = get_fontname_and_size (t)

  if (isempty (t.fontname) || strcmp (t.fontname, "*"))
    fnt = "";
  else
    fnt = t.fontname;
  endif

  f = fnt;
  it = false;
  bld = false;
  if (! isempty (t.fontweight) && strcmp (t.fontweight, "bold"))
    if (! isempty (t.fontangle)
        && (strcmp (t.fontangle, "italic")
            || strcmp (t.fontangle, "oblique")))
      f = [f "-bolditalic"];
      it = true;
      bld = true;
    else
      f = [f "-bold"];
      bld = true;
    endif
  elseif (! isempty (t.fontangle)
          && (strcmp (t.fontangle, "italic")
              || strcmp (t.fontangle, "oblique")))
    f = [f "-italic"];
    it = true;
  endif


In _gnuplot_draw_axes_.m

If I set default font to "Helvetica" instead of empty string and "-bold" to " Bold" the result is "Helvetica Bold" which seems to be a decent font name.

Avinoam Kalma <avinoam>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #38512:  wint2.pdf added by dasergatskov (9KiB - application/pdf)
file #38511:  t1.pdf added by dasergatskov (8KiB - application/pdf)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by tmacchant (Posted a comment)
  • -email is unavailable- added by dasergatskov (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by rik5
  • -email is unavailable- added by avinoam (Submitted the item)
  • -email is unavailable- added by avinoam
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-09-17 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2016-09-15 rik5 Summarygnuplot graphics_toolkit: Warning on &quot;demo ezmesh&quot; gnuplot enhanced text specification has changed for versions >= 5.0
    2016-09-15 dasergatskov Attached File- Added wint2.pdf, #38512
    2016-09-14 dasergatskov Attached File- Added t1.pdf, #38511
    2016-09-14 rik5 StatusNone Confirmed
        Carbon-Copy- Added sebald
    2016-09-09 avinoam Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code