octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Setting the fontname and size of text


From: David Bateman
Subject: Setting the fontname and size of text
Date: Mon, 12 Nov 2007 19:26:22 +0100
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

The attached patch, allows the fontsize and name to be set for all text
objects in Octave. You might not like my choice of "Helvetica" as the
default font, and if so a search and replace in graphics.cc and
__go_draw_axes__.m can change it..

D.

-- 
David Bateman                                address@hidden
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary

*** ./scripts/plot/title.m.orig2        2007-11-12 19:17:16.713882533 +0100
--- ./scripts/plot/title.m      2007-11-12 16:44:41.572249676 +0100
***************
*** 24,30 ****
  
  ## Author: jwe
  
! function retval = title (varargin)
  
    if (rem (nargin, 2) == 1)
      if (nargout > 0)
--- 24,30 ----
  
  ## Author: jwe
  
! function h = title (varargin)
  
    if (rem (nargin, 2) == 1)
      if (nargout > 0)
*** ./scripts/plot/__go_draw_axes__.m.orig2     2007-11-12 19:17:02.067638591 
+0100
--- ./scripts/plot/__go_draw_axes__.m   2007-11-12 19:15:57.911952420 +0100
***************
*** 59,66 ****
        if (isempty (t.string))
        fputs (plot_stream, "unset title;\n");
        else
!       fprintf (plot_stream, "set title \"%s\";\n",
!                undo_string_escapes (t.string));
        endif
      endif
  
--- 59,76 ----
        if (isempty (t.string))
        fputs (plot_stream, "unset title;\n");
        else
!       if (isempty (t.fontname))
!         f = "Helvetica";
!       else
!         f = t.fontname;
!       endif
!       if (isempty (t.fontsize))
!         s = 10;
!       else
!         s = t.fontsize;
!       endif
!       fprintf (plot_stream, "set title \"%s\" font \"%s,%d\";\n",
!                undo_string_escapes (t.string), f, s);
        endif
      endif
  
***************
*** 70,77 ****
        if (isempty (t.string))
        fputs (plot_stream, "unset xlabel;\n");
        else
!       fprintf (plot_stream, "set xlabel \"%s\"",
!                undo_string_escapes (t.string));
        if (have_newer_gnuplot)
          ## Rotation of xlabel not yet support by gnuplot as of 4.2, but
          ## there is no message about it.
--- 80,97 ----
        if (isempty (t.string))
        fputs (plot_stream, "unset xlabel;\n");
        else
!       if (isempty (t.fontname))
!         f = "Helvetica";
!       else
!         f = t.fontname;
!       endif
!       if (isempty (t.fontsize))
!         s = 10;
!       else
!         s = t.fontsize;
!       endif
!       fprintf (plot_stream, "set xlabel \"%s\" font \"%s,%d\"",
!                undo_string_escapes (t.string), f, s);
        if (have_newer_gnuplot)
          ## Rotation of xlabel not yet support by gnuplot as of 4.2, but
          ## there is no message about it.
***************
*** 87,94 ****
        if (isempty (t.string))
        fputs (plot_stream, "unset ylabel;\n");
        else
!       fprintf (plot_stream, "set ylabel \"%s\"",
!                undo_string_escapes (t.string));
        if (have_newer_gnuplot)
          fprintf (plot_stream, " rotate by %f;\n", angle);
        endif
--- 107,124 ----
        if (isempty (t.string))
        fputs (plot_stream, "unset ylabel;\n");
        else
!       if (isempty (t.fontname))
!         f = "Helvetica";
!       else
!         f = t.fontname;
!       endif
!       if (isempty (t.fontsize))
!         s = 10;
!       else
!         s = t.fontsize;
!       endif
!       fprintf (plot_stream, "set ylabel \"%s\" font \"%s,%d\"",
!                undo_string_escapes (t.string), f, s);
        if (have_newer_gnuplot)
          fprintf (plot_stream, " rotate by %f;\n", angle);
        endif
***************
*** 822,837 ****
            endif
          endif
  
          if (nd == 3)
            fprintf (plot_stream,
!                    "set label \"%s\" at %s %.15g,%.15g,%.15g %s rotate by %f 
%s;\n",
!                    undo_string_escapes (label), units,
!                    lpos(1), lpos(2), lpos(3), halign, angle, colorspec);
          else
!           fprintf (plot_stream,
!                    "set label \"%s\" at %s %.15g,%.15g %s rotate by %f %s;\n",
!                    undo_string_escapes (label), units,
!                    lpos(1), lpos(2), halign, angle, colorspec);
          endif
  
        otherwise
--- 852,878 ----
            endif
          endif
  
+         if (isempty (obj.fontname))
+           f = "Helvetica";
+         else
+           f = obj.fontname;
+         endif
+         if (isempty (obj.fontsize))
+           s = 10;
+         else
+           s = obj.fontsize;
+         endif
+ 
          if (nd == 3)
            fprintf (plot_stream,
!                    "set label \"%s\" at %s %.15g,%.15g,%.15g font \"%s,%d\" 
%s rotate by %f %s;\n",
!                    undo_string_escapes (label), units, lpos(1),
!                    lpos(2), lpos(3), f, s, halign, angle, colorspec);
          else
!           fprintf (plot_stream,
!                    "set label \"%s\" at %s %.15g,%.15g font \"%s,%d\" %s 
rotate by %f %s;\n",
!                    undo_string_escapes (label), units,
!                    lpos(1), lpos(2), f, s, halign, angle, colorspec);
          endif
  
        otherwise
*** ./src/graphics.cc.orig2     2007-11-12 19:17:26.344385483 +0100
--- ./src/graphics.cc   2007-11-12 17:20:49.975572176 +0100
***************
*** 1917,1923 ****
      position (Matrix (1, 3, 0.0)),
      rotation (0),
      horizontalalignment ("left"),
!     color (Matrix (1, 3, 0.0))
  { }
  
  void
--- 1917,1925 ----
      position (Matrix (1, 3, 0.0)),
      rotation (0),
      horizontalalignment ("left"),
!     color (Matrix (1, 3, 0.0)),
!     fontname ("Helvetica"),
!     fontsize (10)
  { }
  
  void
***************
*** 1946,1951 ****
--- 1948,1957 ----
      set_horizontalalignment (val);
    else if (name.compare ("color"))
      set_color (val);
+   else if (name.compare ("fontname"))
+     set_fontname (val);
+   else if (name.compare ("fontsize"))
+     set_fontsize (val);
    else
      {
        modified = false;
***************
*** 1971,1976 ****
--- 1977,1984 ----
    m.assign ("rotation", rotation);
    m.assign ("horizontalalignment", horizontalalignment);
    m.assign ("color", color);
+   m.assign ("fontname", fontname);
+   m.assign ("fontsize", fontsize);
  
    return m;
  }
***************
*** 2000,2005 ****
--- 2008,2017 ----
      retval = horizontalalignment;
    else if (name.compare ("color"))
      retval = color;
+   else if (name.compare ("fontname"))
+     retval = fontname;
+   else if (name.compare ("fontsize"))
+     retval = fontsize;
    else
      warning ("get: invalid property `%s'", name.c_str ());
  
***************
*** 2017,2022 ****
--- 2029,2036 ----
    m["rotation"] = 0;
    m["horizontalalignment"] = "left";
    m["color"] = Matrix (1, 3, 1.0);
+   m["fontname"] = "Helvetica";
+   m["fontsize"] = 10;
  
    return m;
  }
*** ./src/graphics.h.in.orig2   2007-11-12 19:17:39.978681914 +0100
--- ./src/graphics.h.in 2007-11-12 17:18:03.157834820 +0100
***************
*** 1410,1415 ****
--- 1410,1417 ----
        octave_value rotation
        octave_value horizontalalignment
        color_property color
+       octave_value fontname
+       octave_value fontsize
      END_PROPERTIES
  
      static std::string go_name;
2007-11-12  David Bateman  <address@hidden>

        * plot/title.m: Fix return value for nargout > 0.
        * plot/__go_draw_axes.m: Allow the font and fontsize to be
        specified for the title, xlabel, ylabel and text objects.

2007-11-12  David Bateman  <address@hidden>

        * graphics.h.in, graphics.cc (class text): Add the fontname and
        fontsize properties. 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]