summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLillian Angel <langel@redhat.com>2005-11-22 19:08:43 +0000
committerLillian Angel <langel@redhat.com>2005-11-22 19:08:43 +0000
commitb90706f9af5a3bcdd3c82a194d3fd92bdad262b7 (patch)
treeb422f86186ec7d5d0c9acaedd2a820a31005d9e4
parent38d05af11d4a5378b733eb1d8ca3c53cf3ab2571 (diff)
downloadclasspath-b90706f9af5a3bcdd3c82a194d3fd92bdad262b7.tar.gz
2005-11-22 Lillian Angel <langel@redhat.com>
PR 24937 * gnu/java/awt/peer/gtk/GdkGraphics.java (drawString): Removed pattern matching code. This is now done in native. * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c (Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString): Added a loop to filter out all non-printing characters.
-rw-r--r--ChangeLog10
-rw-r--r--gnu/java/awt/peer/gtk/GdkGraphics.java4
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c29
3 files changed, 37 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 1a1caf32e..76f679aea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2005-11-22 Lillian Angel <langel@redhat.com>
+
+ PR 24937
+ * gnu/java/awt/peer/gtk/GdkGraphics.java
+ (drawString): Removed pattern matching code. This is now
+ done in native.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
+ (Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString): Added
+ a loop to filter out all non-printing characters.
+
2005-11-22 Audrius Meskauskas <AudriusA@Bioinformatics.org>
* javax/swing/text/DefaultCaret.java (updateTimerStatus):
diff --git a/gnu/java/awt/peer/gtk/GdkGraphics.java b/gnu/java/awt/peer/gtk/GdkGraphics.java
index a8bfd0fc8..84fb1371e 100644
--- a/gnu/java/awt/peer/gtk/GdkGraphics.java
+++ b/gnu/java/awt/peer/gtk/GdkGraphics.java
@@ -247,10 +247,6 @@ public class GdkGraphics extends Graphics
native void drawString (GdkFontPeer f, String str, int x, int y);
public void drawString (String str, int x, int y)
{
- // FIXME: Possibly more characters we need to ignore/
- // Also, implementation may be inefficent because allocating
- // new Strings.
- str = Pattern.compile("[\b|\t|\n|\f|\r|\"|\']").matcher(str).replaceAll("");
drawString(getFontPeer(), str, x, y);
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
index 4aca1cf57..2825e7166 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
@@ -291,6 +291,11 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString
struct peerfont *pfont = NULL;
struct graphics *g = NULL;
const char *cstr = NULL;
+ char *p = NULL;
+ char *tmp = NULL;
+ char *sTmp = NULL;
+ int count = 0;
+ int charSize = 0;
int baseline_y = 0;
PangoLayoutIter *iter = NULL;
@@ -303,9 +308,29 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString
g_assert (pfont != NULL);
cstr = (*env)->GetStringUTFChars (env, str, NULL);
+ g_assert (cstr != NULL);
+
+ charSize = sizeof(char);
+ p = malloc((strlen(cstr) + 1) * charSize);
+ g_assert (p != NULL);
+
+ tmp = p;
+ sTmp = cstr;
+ for (; *sTmp != '\0'; sTmp++)
+ if (isprint(*sTmp))
+ {
+ *p = *sTmp;
+ count++;
+ p++;
+ }
+ *p = '\0';
+
+ p = realloc(tmp, (count + 1) * charSize);
+ g_assert (p != NULL);
+ pango_layout_set_text (pfont->layout, p, -1);
+ free(p);
pango_layout_set_font_description (pfont->layout, pfont->desc);
- pango_layout_set_text (pfont->layout, cstr, -1);
iter = pango_layout_get_iter (pfont->layout);
baseline_y = pango_layout_iter_get_baseline (iter);
@@ -317,7 +342,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString
pango_layout_iter_free (iter);
pango_layout_set_text (pfont->layout, "", -1);
-
+
gdk_flush ();
(*env)->ReleaseStringUTFChars (env, str, cstr);