changeset 22925:509b2ef72225

Properly initialize axes labels font properties (bug #49775) * graphics.cc (axes::properties::init): initialize the fontsize and fontweight of label * graphics.cc (axes::properties::set_defaults): dito * title.m: make use of __axis_labels__ function * __axis_labels__.m: add if block to distinguish titles from other labels
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Tue, 06 Dec 2016 15:19:37 +0100
parents b150be19734d
children feaa4160a43b
files libinterp/corefcn/graphics.cc scripts/plot/appearance/private/__axis_label__.m scripts/plot/appearance/title.m
diffstat 3 files changed, 24 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.cc	Sun Dec 18 07:10:20 2016 -0800
+++ b/libinterp/corefcn/graphics.cc	Tue Dec 06 15:19:37 2016 +0100
@@ -4600,6 +4600,15 @@
   xset (zlabel.handle_value (), "__autopos_tag__", "zlabel");
   xset (title.handle_value (), "__autopos_tag__", "title");
 
+  double fs = labelfontsizemultiplier.double_value () * 
+    fontsize.double_value ();
+  xset (xlabel.handle_value (), "fontsize", octave_value (fs));
+  xset (ylabel.handle_value (), "fontsize", octave_value (fs));
+  xset (zlabel.handle_value (), "fontsize", octave_value (fs));
+  fs = titlefontsizemultiplier.double_value () * fontsize.double_value ();
+  xset (title.handle_value (), "fontsize", octave_value (fs));
+  xset (title.handle_value (), "fontweight", titlefontweight.get ());
+
   adopt (xlabel.handle_value ());
   adopt (ylabel.handle_value ());
   adopt (zlabel.handle_value ());
@@ -5084,6 +5093,15 @@
   xset (zlabel.handle_value (), "__autopos_tag__", "zlabel");
   xset (title.handle_value (), "__autopos_tag__", "title");
 
+  double fs = labelfontsizemultiplier.double_value () * 
+    fontsize.double_value ();
+  xset (xlabel.handle_value (), "fontsize", octave_value (fs));
+  xset (ylabel.handle_value (), "fontsize", octave_value (fs));
+  xset (zlabel.handle_value (), "fontsize", octave_value (fs));
+  fs = titlefontsizemultiplier.double_value () * fontsize.double_value ();
+  xset (title.handle_value (), "fontsize", octave_value (fs));
+  xset (title.handle_value (), "fontweight", titlefontweight.get ());
+
   update_transform ();
   sync_positions ();
   override_defaults (bgo);
--- a/scripts/plot/appearance/private/__axis_label__.m	Sun Dec 18 07:10:20 2016 -0800
+++ b/scripts/plot/appearance/private/__axis_label__.m	Tue Dec 06 15:19:37 2016 +0100
@@ -27,20 +27,15 @@
 
   h = get (hax, caller);
 
-  set (h, "fontangle", get (hax, "fontangle"),
-          "fontname", get (hax, "fontname"),
-          "fontunits", get (hax, "fontunits"),   # must precede fontsize
-          "fontsize", get (hax, "LabelFontSizeMultiplier") *
-                      get (hax, "fontsize"),
-          "fontweight", get (hax, "fontweight"),
-          "string", txt,
-          varargin{:});
+  set (h, "string", txt, varargin{:});
 
   ## FIXME: It would be better to delete only the listener that [xyz]label
   ##        installed.  But this didn't work, so instead it deletes all
   ##        listener's on the [xyz]color property.
-  dellistener (hax, [caller(1) "color"]);
-  addlistener (hax, [caller(1) "color"], {@cb_color, h, caller(1)});
+  if (! strcmp (caller, "title"))
+    dellistener (hax, [caller(1) "color"]);
+    addlistener (hax, [caller(1) "color"], {@cb_color, h, caller(1)});
+  endif
 
   if (nargout > 0)
     retval = h;
--- a/scripts/plot/appearance/title.m	Sun Dec 18 07:10:20 2016 -0800
+++ b/scripts/plot/appearance/title.m	Tue Dec 06 15:19:37 2016 +0100
@@ -48,16 +48,7 @@
     print_usage ();
   endif
 
-  htmp = get (hax, "title");
-
-  set (htmp, "fontangle", get (hax, "fontangle"),
-             "fontname", get (hax, "fontname"),
-             "fontunits", get (hax, "fontunits"),   # must precede fontsize
-             "fontsize", get (hax, "TitleFontSizeMultiplier") *
-                         get (hax, "fontsize"),
-             "fontweight", get (hax, "titlefontweight"),
-             "string", varargin{1},
-             varargin{2:end});
+  htmp = __axis_label__ (hax, "title", varargin{:});
 
   if (nargout > 0)
     h = htmp;