changeset 23210:3a298e07002c

Deprecate "light" and "demi" values for "fontweight" property (bug #50353). * NEWS: announce deprecation. * graphics.in.h (text::properties::update_fontweight uicontrol::properties::update_fontweight): emit a warning when value is "demi" or "light". * graphics.in.h (uipanel::properties::update_fontweight uibuttongroup::properties::update_fontweight): new updater, emit a warning when value is "demi" or "light". * genpropdoc.m: provide templates for font* properties doc. Remove "demi" and "light" from fontweight docstrings. * deprecate-prop.tst: add test for deprecated values and instructions on how to remove them in 4.7+. * QtHandlesUtils.cc (computeFont): fix typo in "bold" case.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Sun, 19 Feb 2017 12:37:59 +0100
parents 5d9d756724cc
children 95a9d6ffaecc
files NEWS doc/interpreter/genpropdoc.m libgui/graphics/QtHandlesUtils.cc libinterp/corefcn/graphics.in.h test/deprecate-props.tst
diffstat 5 files changed, 165 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Sun Feb 19 21:19:34 2017 +0100
+++ b/NEWS	Sun Feb 19 12:37:59 2017 +0100
@@ -33,21 +33,25 @@
 
  ** Deprecated graphics properties.
 
-    The following properties have been deprecated in Octave 4.4 and will
-    be removed from Octave 4.8 (or whatever version is the second major
-    release after 4.4):
+    The following properties or allowed corresponding values have been 
+    deprecated in Octave 4.4 and will be removed from Octave 4.8 (or whatever 
+    version is the second major release after 4.4):
 
-      Object               | Property
-      ---------------------|------------------
-      figure               | doublebuffer
-                           | mincolormap
-                           | wvisual
-                           | wvisualmode
-                           | xdisplay
-                           | xvisual
-                           | xvisualmode
-      axes                 | drawmode
-      annotation           | edgecolor ("rectangle")
+      Object               | Property                | Value   
+      ---------------------|-------------------------|-------------------
+      figure               | doublebuffer            |
+                           | mincolormap             |
+                           | wvisual                 |
+                           | wvisualmode             |
+                           | xdisplay                |
+                           | xvisual                 |
+                           | xvisualmode             |
+      axes                 | drawmode                |
+      annotation           | edgecolor ("rectangle") |
+      text                 | fontweight              | "demi" and "light"
+      uicontrol            | fontweight              | "demi" and "light"
+      uipanel              | fontweight              | "demi" and "light"
+      uibuttongroup        | fontweight              | "demi" and "light"
 
  ** The following functions were deprecated in Octave 4.0 and have been
     removed from Octave 4.4.
--- a/doc/interpreter/genpropdoc.m	Sun Feb 19 21:19:34 2017 +0100
+++ b/doc/interpreter/genpropdoc.m	Sun Feb 19 12:37:59 2017 +0100
@@ -110,6 +110,17 @@
 __prop__ is unused.";
   doc_unused =  "__prop__ is unused.";
 
+  doc_fontangle = "Control whether the font is italic or normal.";
+  doc_fontsize = "Size of the font used for text rendering.  \
+@xref{XREF__objname__fontunits, , fontunits property}.";
+  doc_fontname = "Name of font used for text rendering.  When setting \
+this property, the text rendering engine will search for a matching \
+font in your system.  If none is found then text is rendered using a \
+default sans serif font (same as the default @qcode{\"*\"} value).";
+  doc_fontunits = "Units used to interpret the @qcode{\"fontsize\"} property.";
+  doc_fontweight = "Control the variant of the base font used for \
+text rendering.";
+  
   ## Initialize structure
   if (isfield (base, field))
     s = base.(field);
@@ -625,24 +636,25 @@
 
       case "dataaspectratiomode"
       case "fontangle"
-        s.doc = "Control whether the font is italic or normal.";
+        s.doc = doc_fontangle;
+        
       case "fontname"
-        s.doc = "Name of the font used for axes annotations.";
+        s.doc = doc_fontname;
         s.valid = valid_string;
 
       case "fontsize"
-        s.doc = "Size of the font used for axes annotations.  \
-@xref{XREFaxesfontunits, , @w{fontunits property}}.";
+        s.doc = doc_fontsize;
         s.valid = "scalar";
 
       case "fontunits"
-        s.doc = "Unit used to interpret @code{fontsize} property.";
+        s.doc = doc_fontunits;
 
       case "fontsmoothing"
         s.doc = doc_unused;
 
       case "fontweight"
-        s.doc = "Control variant of base font used: bold, demi, light, normal.";
+        s.doc = doc_fontweight;
+        
       case "gridalpha"
         s.doc = sprintf (doc_notimpl, "Transparency");
 
@@ -1011,26 +1023,24 @@
         s.doc = "Vector @code{[x0 y0 width height]} indicating the size \
 and location of the text string.";
         s.valid = valid_4elvec;
-        
+      
       case "fontangle"
-        s.doc = "Control whether the font is italic or normal.  \
-@code{fontangle} is currently unused.";
-
+        s.doc = doc_fontangle;
+        
       case "fontname"
-        s.doc = "The font used for the text.";
+        s.doc = doc_fontname;
         s.valid = valid_string;
 
       case "fontsize"
-        s.doc = "The font size of the text as measured in \
-@code{fontunits}.";
+        s.doc = doc_fontsize;
         s.valid = "scalar";
 
       case "fontunits"
-        s.doc = "The units used to interpret @code{fontsize} property.";
+        s.doc = doc_fontunits;
 
       case "fontweight"
-        s.doc = "Control variant of base font used: bold, light, normal, etc.";
-
+        s.doc = doc_fontweight;
+        
       case "horizontalalignment"
       case "interpreter"
         s.doc = "Control the way the @qcode{\"string\"} property is \
@@ -1425,10 +1435,22 @@
       case "bordertype"
       case "borderwidth"
       case "fontangle"
+        s.doc = doc_fontangle;
+        
       case "fontname"
+        s.doc = doc_fontname;
+        s.valid = valid_string;
+
       case "fontsize"
+        s.doc = doc_fontsize;
+        s.valid = "scalar";
+
       case "fontunits"
+        s.doc = doc_fontunits;
+
       case "fontweight"
+        s.doc = doc_fontweight;
+        
       case "foregroundcolor"
       case "highlightcolor"
       case "position"
@@ -1446,24 +1468,36 @@
       ## Overridden shared properties
 
       ## Specific properties
-        case "backgroundcolor"
-        case "bordertype"
-        case "borderwidth"
-        case "fontangle"
-        case "fontname"
-        case "fontsize"
-        case "fontunits"
-        case "fontweight"
-        case "foregroundcolor"
-        case "highlightcolor"
-        case "position"
-        case "resizefcn"
-        case "selectedobject"
-        case "selectionchangedfcn"
-        case "shadowcolor"
-        case "title"
-        case "titleposition"
-        case "units"
+      case "backgroundcolor"
+      case "bordertype"
+      case "borderwidth"
+      case "fontangle"
+        s.doc = doc_fontangle;
+        
+      case "fontname"
+        s.doc = doc_fontname;
+        s.valid = valid_string;
+
+      case "fontsize"
+        s.doc = doc_fontsize;
+        s.valid = "scalar";
+
+      case "fontunits"
+        s.doc = doc_fontunits;
+
+      case "fontweight"
+        s.doc = doc_fontweight;
+        
+      case "foregroundcolor"
+      case "highlightcolor"
+      case "position"
+      case "resizefcn"
+      case "selectedobject"
+      case "selectionchangedfcn"
+      case "shadowcolor"
+      case "title"
+      case "titleposition"
+      case "units"
 
     endswitch
 
@@ -1479,10 +1513,22 @@
       case "enable"
       case "extent"
       case "fontangle"
+        s.doc = doc_fontangle;
+        
       case "fontname"
+        s.doc = doc_fontname;
+        s.valid = valid_string;
+
       case "fontsize"
+        s.doc = doc_fontsize;
+        s.valid = "scalar";
+
       case "fontunits"
+        s.doc = doc_fontunits;
+
       case "fontweight"
+        s.doc = doc_fontweight;
+        
       case "foregroundcolor"
       case "horizontalalignment"
       case "keypressfcn"
--- a/libgui/graphics/QtHandlesUtils.cc	Sun Feb 19 21:19:34 2017 +0100
+++ b/libgui/graphics/QtHandlesUtils.cc	Sun Feb 19 12:37:59 2017 +0100
@@ -115,7 +115,7 @@
           weightMap[std::string ("normal")] = QFont::Normal;
           weightMap[std::string ("light")] = QFont::Light;
           weightMap[std::string ("demi")] = QFont::DemiBold;
-          weightMap[std::string ("bold")] = QFont::Normal;
+          weightMap[std::string ("bold")] = QFont::Bold;
 
           angleMap[std::string ("normal")] = QFont::StyleNormal;
           angleMap[std::string ("italic")] = QFont::StyleItalic;
--- a/libinterp/corefcn/graphics.in.h	Sun Feb 19 21:19:34 2017 +0100
+++ b/libinterp/corefcn/graphics.in.h	Sun Feb 19 12:37:59 2017 +0100
@@ -4775,7 +4775,18 @@
     void update_fontname (void) { update_font (); update_text_extent (); }
     void update_fontsize (void) { update_font (); update_text_extent (); }
     void update_fontangle (void) { update_font (); update_text_extent (); }
-    void update_fontweight (void) { update_font (); update_text_extent (); }
+
+    void update_fontweight (void) 
+    { 
+      update_font (); 
+      update_text_extent ();
+      // FIXME: Remove warning with demi and light in 4.7+
+      if (fontweight.is ("demi") || fontweight.is ("light"))
+        warning_with_id ("Octave:deprecated-property",
+                         "Setting 'fontweight' to '%s' is deprecated, \
+use 'normal' or 'bold'.", fontweight.current_value ().c_str ());
+    }
+
     void update_interpreter (void) { update_text_extent (); }
     void update_horizontalalignment (void) { update_text_extent (); }
     void update_verticalalignment (void) { update_text_extent (); }
@@ -5773,7 +5784,17 @@
     void update_fontname (void) { update_text_extent (); }
     void update_fontsize (void) { update_text_extent (); }
     void update_fontangle (void) { update_text_extent (); }
-    void update_fontweight (void) { update_text_extent (); }
+
+    void update_fontweight (void) 
+    { 
+      update_text_extent (); 
+      // FIXME: Remove warning with demi and light in 4.7+
+      if (fontweight.is ("demi") || fontweight.is ("light"))
+        warning_with_id ("Octave:deprecated-property",
+                         "Setting 'fontweight' to '%s' is deprecated, \
+use 'normal' or 'bold'.", fontweight.current_value ().c_str ());
+    }
+
     void update_fontunits (const caseless_str& old_units);
 
     void update_units (void);
@@ -5832,7 +5853,7 @@
       string_property fontname , OCTAVE_DEFAULT_FONTNAME
       double_property fontsize , 10
       radio_property fontunits S , "inches|centimeters|normalized|{points}|pixels"
-      radio_property fontweight , "light|{normal}|demi|bold"
+      radio_property fontweight u , "light|{normal}|demi|bold"
       color_property foregroundcolor , color_values (0, 0, 0)
       color_property highlightcolor , color_values (1, 1, 1)
       array_property position , default_panel_position ()
@@ -5859,7 +5880,15 @@
     // void update_fontname (void) { update_text_extent (); }
     // void update_fontsize (void) { update_text_extent (); }
     // void update_fontangle (void) { update_text_extent (); }
-    // void update_fontweight (void) { update_text_extent (); }
+
+    void update_fontweight (void) 
+    { 
+      // FIXME: Remove this warning in 4.7+
+      if (fontweight.is ("demi") || fontweight.is ("light"))
+        warning_with_id ("Octave:deprecated-property",
+                         "Setting 'fontweight' to '%s' is deprecated, \
+use 'normal' or 'bold'.", fontweight.current_value ().c_str ());
+    }
 
     void update_units (const caseless_str& old_units);
     void update_fontunits (const caseless_str& old_units);
@@ -5918,7 +5947,7 @@
       string_property fontname , OCTAVE_DEFAULT_FONTNAME
       double_property fontsize , 10
       radio_property fontunits S , "inches|centimeters|normalized|{points}|pixels"
-      radio_property fontweight , "light|{normal}|demi|bold"
+      radio_property fontweight u , "light|{normal}|demi|bold"
       color_property foregroundcolor , color_values (0, 0, 0)
       color_property highlightcolor , color_values (1, 1, 1)
       array_property position , default_panel_position ()
@@ -5940,6 +5969,14 @@
     void update_units (const caseless_str& old_units);
     void update_fontunits (const caseless_str& old_units);
 
+    void update_fontweight (void) 
+    { 
+      // FIXME: Remove this warning in 4.7+
+      if (fontweight.is ("demi") || fontweight.is ("light"))
+        warning_with_id ("Octave:deprecated-property",
+                         "Setting 'fontweight' to '%s' is deprecated, \
+use 'normal' or 'bold'.", fontweight.current_value ().c_str ());
+    }
   };
 
 private:
--- a/test/deprecate-props.tst	Sun Feb 19 21:19:34 2017 +0100
+++ b/test/deprecate-props.tst	Sun Feb 19 12:37:59 2017 +0100
@@ -98,3 +98,27 @@
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
+
+## text/uicontrol/uipanel/uibuttongroup  "demi" and "light" values for
+## "fontweight" property are deprecated in 4.4, remove from 4.7.+:
+##   * remove "demi" and "light" options in graphics.in.h,
+##   QtHandlesUtils.cc and ft-text-renderer.cc
+##   * remove warnings from update_fontweight in graphics.in.h
+%!test
+%! hf = figure ("visible", "off");
+%! unwind_protect
+%!   ht = text ();
+%!   testprop (ht, "fontweight", "4.6", "demi");
+%!   testprop (ht, "fontweight", "4.6", "light");
+%!   hui = uicontrol ();
+%!   testprop (hui, "fontweight", "4.6", "demi");
+%!   testprop (hui, "fontweight", "4.6", "light");
+%!   hui = uipanel ();
+%!   testprop (hui, "fontweight", "4.6", "demi");
+%!   testprop (hui, "fontweight", "4.6", "light");
+%!   hui = uibuttongroup ();
+%!   testprop (hui, "fontweight", "4.6", "demi");
+%!   testprop (hui, "fontweight", "4.6", "light");
+%! unwind_protect_cleanup
+%!   close (hf);
+%! end_unwind_protect