This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gui] [PATCH] Default Font attributes
- From: David Jee <djee at redhat dot com>
- To: java-patches at gcc dot gnu dot org
- Date: 25 Feb 2004 15:40:38 -0500
- Subject: [gui] [PATCH] Default Font attributes
- Organization:
Hello. I committed the following patch to java-gui-branch, to fix the
default attributes for Font objects. It turns out that the default size
is 12 after all. Plus, when a font name is not given, it defaults to
"Default". Lastly, in the constructor Font(String name, Map attrs), if
attrs is null, the font should get default attributes.
-David Jee
2004-02-25 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkFontPeer.java
(GtkFontPeer): Change default size to 12.
* gnu/java/awt/peer/gtk/GtkToolkit.java
(getFontPeer): Change default size to 12.
(getClasspathFontPeer): Likewise. Set default name to "Default".
* java/awt/Font.java
(Font(Map)): Call Font(String,Map).
(Font(String,Map)): If attrs is null, initialize it as an empty
HashMap, which will ensure that the Font will get default attributes.
Index: gnu/java/awt/peer/gtk/GtkFontPeer.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/awt/peer/gtk/GtkFontPeer.java,v
retrieving revision 1.3.8.1
diff -u -r1.3.8.1 GtkFontPeer.java
--- gnu/java/awt/peer/gtk/GtkFontPeer.java 25 Feb 2004 17:18:01 -0000 1.3.8.1
+++ gnu/java/awt/peer/gtk/GtkFontPeer.java 25 Feb 2004 20:14:45 -0000
@@ -66,8 +66,8 @@
public GtkFontPeer (String name, int style)
{
- // All fonts get a default size of 1 if size is not specified.
- this(name, style, 1);
+ // All fonts get a default size of 12 if size is not specified.
+ this(name, style, 12);
}
public GtkFontPeer (String name, int style, int size)
Index: gnu/java/awt/peer/gtk/GtkToolkit.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/awt/peer/gtk/GtkToolkit.java,v
retrieving revision 1.8.2.2
diff -u -r1.8.2.2 GtkToolkit.java
--- gnu/java/awt/peer/gtk/GtkToolkit.java 25 Feb 2004 17:18:01 -0000 1.8.2.2
+++ gnu/java/awt/peer/gtk/GtkToolkit.java 25 Feb 2004 20:14:45 -0000
@@ -368,8 +368,8 @@
* implementations. Our newer Font class uses getClasspathFontPeer.
*/
protected FontPeer getFontPeer (String name, int style) {
- // All fonts get a default size of 1 if size is not specified.
- return getFontPeer(name, style, 1);
+ // All fonts get a default size of 12 if size is not specified.
+ return getFontPeer(name, style, 12);
}
/**
@@ -397,9 +397,11 @@
return new GdkClasspathFontPeer (name, attrs);
else
{
- // All fonts get a default size of 1 if size is not specified.
- int size = 1;
+ // Default values
+ int size = 12;
int style = Font.PLAIN;
+ if (name == null)
+ name = "Default";
if (attrs.containsKey (TextAttribute.WEIGHT))
{
Index: java/awt/Font.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/Font.java,v
retrieving revision 1.16
diff -u -r1.16 Font.java
--- java/awt/Font.java 31 Dec 2003 08:58:30 -0000 1.16
+++ java/awt/Font.java 25 Feb 2004 20:14:47 -0000
@@ -330,16 +330,20 @@
}
public Font (Map attrs)
-{
- this.peer = getPeerFromToolkit (null, attrs);
-}
+ {
+ this(null, attrs);
+ }
/* This extra constructor is here to permit ClasspathToolkit and to build
a font with a "logical name" as well as attrs. */
public Font (String name, Map attrs)
-{
+ {
+ // If attrs is null, setting it to an empty HashMap will give this
+ // Font default attributes.
+ if (attrs == null)
+ attrs = new HashMap();
this.peer = getPeerFromToolkit (name, attrs);
-}
+ }
/*************************************************************************/