[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Setting the fontname and size of text
From: |
David Bateman |
Subject: |
Re: Setting the fontname and size of text |
Date: |
Tue, 13 Nov 2007 11:29:25 +0100 |
User-agent: |
Thunderbird 1.5.0.7 (X11/20060921) |
John W. Eaton wrote:
> On 12-Nov-2007, David Bateman wrote:
>
> | 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..
>
> I applied this patch.
>
> Thanks,
>
> jwe
>
>
Ok, and here is the complement to set the weight and angle of the font..
Not all combinations of fonts, weights and angles are valid on all
terminals with gnuplot however.. I've also limited the options of the
weight to "normal" and "bold" and ignored the "demi", and "light"
options that matlab provides as there seems to be no easy way to deal
with this in gnuplot.. Similar I treated the "oblique" option for the
angle as "italic". This allows things like
h = text (0,0,"Test Label");
set(h,"FontName","Times","FontSize", 20, "FontWeight","Bold",
"FontAngle","Italic")
to work.
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/__go_draw_axes__.m.orig3 2007-11-13 10:21:50.106992986
+0100
--- ./scripts/plot/__go_draw_axes__.m 2007-11-13 11:13:47.990435630 +0100
***************
*** 60,68 ****
fputs (plot_stream, "unset title;\n");
else
if (isempty (t.fontname))
! f = "Helvetica";
else
! f = t.fontname;
endif
if (isempty (t.fontsize))
s = 10;
--- 60,82 ----
fputs (plot_stream, "unset title;\n");
else
if (isempty (t.fontname))
! f = "helvetica";
else
! f = tolower (t.fontname);
! endif
! if (! isempty(t.fontweight) &&
! strcmp (tolower (t.fontweight), "bold"))
! if (! isempty(t.fontangle) &&
! (strcmp (tolower (t.fontangle), "italic") ||
! strcmp (tolower (t.fontangle), "oblique")))
! f = strcat (f, "-bolditalic");
! else
! f = strcat (f, "-bold");
! endif
! elseif (! isempty(t.fontangle) &&
! (strcmp (tolower (t.fontangle), "italic") ||
! strcmp (tolower (t.fontangle), "oblique")))
! f = strcat (f, "-italic");
endif
if (isempty (t.fontsize))
s = 10;
***************
*** 81,89 ****
fputs (plot_stream, "unset xlabel;\n");
else
if (isempty (t.fontname))
! f = "Helvetica";
else
! f = t.fontname;
endif
if (isempty (t.fontsize))
s = 10;
--- 95,117 ----
fputs (plot_stream, "unset xlabel;\n");
else
if (isempty (t.fontname))
! f = "helvetica";
else
! f = tolower (t.fontname);
! endif
! if (! isempty(t.fontweight) &&
! strcmp (tolower (t.fontweight), "bold"))
! if (! isempty(t.fontangle) &&
! (strcmp (tolower (t.fontangle), "italic") ||
! strcmp (tolower (t.fontangle), "oblique")))
! f = strcat (f, "-bolditalic");
! else
! f = strcat (f, "-bold");
! endif
! elseif (! isempty(t.fontangle) &&
! (strcmp (tolower (t.fontangle), "italic") ||
! strcmp (tolower (t.fontangle), "oblique")))
! f = strcat (f, "-italic");
endif
if (isempty (t.fontsize))
s = 10;
***************
*** 108,116 ****
fputs (plot_stream, "unset ylabel;\n");
else
if (isempty (t.fontname))
! f = "Helvetica";
else
! f = t.fontname;
endif
if (isempty (t.fontsize))
s = 10;
--- 136,158 ----
fputs (plot_stream, "unset ylabel;\n");
else
if (isempty (t.fontname))
! f = "helvetica";
else
! f = tolower (t.fontname);
! endif
! if (! isempty(t.fontweight) &&
! strcmp (tolower (t.fontweight), "bold"))
! if (! isempty(t.fontangle) &&
! (strcmp (tolower (t.fontangle), "italic") ||
! strcmp (tolower (t.fontangle), "oblique")))
! f = strcat (f, "-bolditalic");
! else
! f = strcat (f, "-bold");
! endif
! elseif (! isempty(t.fontangle) &&
! (strcmp (tolower (t.fontangle), "italic") ||
! strcmp (tolower (t.fontangle), "oblique")))
! f = strcat (f, "-italic");
endif
if (isempty (t.fontsize))
s = 10;
***************
*** 853,861 ****
endif
if (isempty (obj.fontname))
! f = "Helvetica";
else
! f = obj.fontname;
endif
if (isempty (obj.fontsize))
s = 10;
--- 895,917 ----
endif
if (isempty (obj.fontname))
! f = "helvetica";
else
! f = tolower(obj.fontname);
! endif
! if (! isempty(obj.fontweight) &&
! strcmp (tolower (obj.fontweight), "bold"))
! if (! isempty(obj.fontangle) &&
! (strcmp (tolower (obj.fontangle), "italic") ||
! strcmp (tolower (obj.fontangle), "oblique")))
! f = strcat (f, "-bolditalic");
! else
! f = strcat (f, "-bold");
! endif
! elseif (! isempty(obj.fontangle) &&
! (strcmp (tolower (obj.fontangle), "italic") ||
! strcmp (tolower (obj.fontangle), "oblique")))
! f = strcat (f, "-italic");
endif
if (isempty (obj.fontsize))
s = 10;
*** ./src/graphics.h.in.orig3 2007-11-13 10:18:08.677130836 +0100
--- ./src/graphics.h.in 2007-11-13 10:20:59.452568542 +0100
***************
*** 1412,1417 ****
--- 1412,1419 ----
color_property color
octave_value fontname
octave_value fontsize
+ octave_value fontangle
+ octave_value fontweight
END_PROPERTIES
static std::string go_name;
*** ./src/graphics.cc.orig3 2007-11-13 10:18:01.541511035 +0100
--- ./src/graphics.cc 2007-11-13 10:25:17.999292476 +0100
***************
*** 1919,1925 ****
horizontalalignment ("left"),
color (Matrix (1, 3, 0.0)),
fontname ("Helvetica"),
! fontsize (10)
{ }
void
--- 1919,1927 ----
horizontalalignment ("left"),
color (Matrix (1, 3, 0.0)),
fontname ("Helvetica"),
! fontsize (10),
! fontangle ("normal"),
! fontweight ("normal")
{ }
void
***************
*** 1952,1957 ****
--- 1954,1963 ----
set_fontname (val);
else if (name.compare ("fontsize"))
set_fontsize (val);
+ else if (name.compare ("fontangle"))
+ set_fontangle (val);
+ else if (name.compare ("fontweight"))
+ set_fontweight (val);
else
{
modified = false;
***************
*** 1979,1984 ****
--- 1985,1992 ----
m.assign ("color", color);
m.assign ("fontname", fontname);
m.assign ("fontsize", fontsize);
+ m.assign ("fontangle", fontangle);
+ m.assign ("fontweight", fontweight);
return m;
}
***************
*** 2012,2017 ****
--- 2020,2029 ----
retval = fontname;
else if (name.compare ("fontsize"))
retval = fontsize;
+ else if (name.compare ("fontangle"))
+ retval = fontangle;
+ else if (name.compare ("fontweight"))
+ retval = fontweight;
else
warning ("get: invalid property `%s'", name.c_str ());
***************
*** 2031,2036 ****
--- 2043,2050 ----
m["color"] = Matrix (1, 3, 1.0);
m["fontname"] = "Helvetica";
m["fontsize"] = 10;
+ m["fontangle"] = "normal";
+ m["fontweight"] = "normal";
return m;
}
2007-11-13 David Bateman <address@hidden>
* plot/__go_draw_axes.m: Allow the fontangle and fontweight 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 fontangle and
fontweight properties.
Re: Setting the fontname and size of text, Daniel J Sebald, 2007/11/13