harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r584159 - in /harmony/enhanced/classlib/trunk/modules/awt/src/main: java/unix/org/apache/harmony/awt/gl/font/ java/unix/org/apache/harmony/awt/gl/linux/ native/linuxfont/unix/ native/linuxfont/unix/include/
Date Fri, 12 Oct 2007 13:11:16 GMT
Author: ayza
Date: Fri Oct 12 06:10:33 2007
New Revision: 584159

URL: http://svn.apache.org/viewvc?rev=584159&view=rev
Log:
Support for antialiasing for Unix fonts was added. See HARMONY-4562 ([classlib][awt] Antialliasing
is not implemented on Linux)

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFont.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxNativeFont.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/DrawableTextRenderer.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/LinuxNativeFont.c
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/exports.txt
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/include/org_apache_harmony_awt_gl_font_LinuxNativeFont.h

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFont.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFont.java?rev=584159&r1=584158&r2=584159&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFont.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFont.java
Fri Oct 12 06:10:33 2007
@@ -57,6 +57,9 @@
 
     // X11 screen value
     private int screen = 0;
+
+    // native antialiased font handle
+    private long aaFont = 0;
     
     public LinuxFont(String fontName, int fontStyle, int fontSize) {
         /*
@@ -332,5 +335,20 @@
         }
         
         return extraMetrix;
+    }
+
+    /**
+     * Returns native font handle of this font peer. 
+     */
+    public long getFontHandle(boolean isAntialiased) {
+        if (!isAntialiased) {
+            return this.getFontHandle();
+        } else {
+            if (aaFont == 0) {
+                aaFont = LinuxNativeFont.getAntialiasedFont(
+                        pFont, this.display, true);
+            }
+            return aaFont;
+        }
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxNativeFont.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxNativeFont.java?rev=584159&r1=584158&r2=584159&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxNativeFont.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxNativeFont.java
Fri Oct 12 06:10:33 2007
@@ -110,6 +110,11 @@
     public synchronized static native String getFontPSNameNative(long fnt);
 
     /**
+     * Getting antialiasing font from existing font
+     */
+    public static native long getAntialiasedFont(long font, long display, boolean isAntialiasing);
+
+    /**
      * Disposing XftFont object.
      * 
      * @param hndFont XftFont handle

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/DrawableTextRenderer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/DrawableTextRenderer.java?rev=584159&r1=584158&r2=584159&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/DrawableTextRenderer.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/DrawableTextRenderer.java
Fri Oct 12 06:10:33 2007
@@ -25,6 +25,7 @@
 import java.awt.font.GlyphVector;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Point2D;
+import java.awt.RenderingHints;
 
 import org.apache.harmony.awt.gl.CommonGraphics2D;
 import org.apache.harmony.awt.gl.TextRenderer;
@@ -50,6 +51,11 @@
     // X11 instanse
     static final X11 x11 = X11.getInstance();
 
+    boolean isAntialiasingHintSet(Graphics2D g){
+        Object value = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
+        return (value == RenderingHints.VALUE_ANTIALIAS_ON);
+    }
+
     public void drawString(Graphics2D ga, String str, float x, float y) {
         CommonGraphics2D g = (CommonGraphics2D)ga;
         AffineTransform trans = g.getTransform();
@@ -57,6 +63,7 @@
         double yOffset = y + trans.getTranslateY();
 
         FontPeerImpl fnt = (FontPeerImpl)g.getFont().getPeer();
+
         if (fnt.getClass() == CompositeFont.class){
             drawCompositeString(g, str, xOffset, yOffset);
         } else {
@@ -128,7 +135,7 @@
         }
         if (inChars.length != 0 ){
             LinuxNativeFont.drawStringNative(xg2d.xftDraw, display, colormap, 
-                    peer.getFontHandle(), (int)Math.round(x), (int)Math.round(y), 
+                    peer.getFontHandle(isAntialiasingHintSet(g)), (int)Math.round(x), (int)Math.round(y),
                     outChars, j, xcolorPtr);
         }
         xcolor.unlock();
@@ -251,7 +258,7 @@
             char chars[] = {gl.getChar()};
 
             LinuxNativeFont.drawStringNative(xg2d.xftDraw, display, colormap, 
-                    peer.getFontHandle(), xBaseLine, yBaseLine, chars, 1, 
+                    peer.getFontHandle(isAntialiasingHintSet(g)), xBaseLine, yBaseLine, chars,
1,
                     xcolorPtr);
         }
         xcolor.unlock();

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/LinuxNativeFont.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/LinuxNativeFont.c?rev=584159&r1=584158&r2=584159&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/LinuxNativeFont.c
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/LinuxNativeFont.c
Fri Oct 12 06:10:33 2007
@@ -1769,3 +1769,34 @@
     return metrics;
        
 }
+
+/*
+ * Getting antialiased font from existing font 
+ */
+JNIEXPORT jlong JNICALL
+	Java_org_apache_harmony_awt_gl_font_LinuxNativeFont_getAntialiasedFont(
+		JNIEnv *env, jclass jobj, jlong font, jlong display, jboolean isAntialiasing){
+	
+    XftFont *fnt = (XftFont *)(long)font;
+    Display *dpy = (Display *)(long)display;
+
+    XftResult result;
+    XftPattern *mpattern = XftFontMatch(dpy, DefaultScreen(dpy),fnt->pattern,&result);

+
+    XftPatternDel(mpattern, XFT_ANTIALIAS);
+    if (isAntialiasing) {
+        if (!XftPatternAddBool(mpattern, XFT_ANTIALIAS, True)) {
+            newNullPointerException(env,
+                "Error during adding font antialias set to true to XFTPattern structure");
+        }
+	}
+    else {
+        if (!XftPatternAddBool(mpattern, XFT_ANTIALIAS, False)) {
+            newNullPointerException(env,
+                "Error during adding font antialias set to false to XFTPattern structure");
+        }
+    }
+
+    XftFont *aaFnt = XftFontOpenPattern(dpy, mpattern);
+    return (long)aaFnt;
+}

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/exports.txt
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/exports.txt?rev=584159&r1=584158&r2=584159&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/exports.txt
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/exports.txt
Fri Oct 12 06:10:33 2007
@@ -27,3 +27,4 @@
 Java_org_apache_harmony_awt_gl_font_LinuxNativeFont_NativeFreeGlyphBitmap
 Java_org_apache_harmony_awt_gl_font_LinuxNativeFont_getPointsFromFTVector
 Java_org_apache_harmony_awt_gl_font_LinuxNativeFont_freeGlyphOutline
+Java_org_apache_harmony_awt_gl_font_LinuxNativeFont_getAntialiasedFont

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/include/org_apache_harmony_awt_gl_font_LinuxNativeFont.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/include/org_apache_harmony_awt_gl_font_LinuxNativeFont.h?rev=584159&r1=584158&r2=584159&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/include/org_apache_harmony_awt_gl_font_LinuxNativeFont.h
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/include/org_apache_harmony_awt_gl_font_LinuxNativeFont.h
Fri Oct 12 06:10:33 2007
@@ -263,6 +263,16 @@
 JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_font_LinuxNativeFont_freeGlyphOutline
   (JNIEnv *, jclass, jlong);
 
+
+/*
+ * Method: org.apache.harmony.awt.gl.font.LinuxNativeFont.getAntialiasedFont 
+ */
+
+JNIEXPORT jlong JNICALL
+	Java_org_apache_harmony_awt_gl_font_LinuxNativeFont_getAntialiasedFont(
+		JNIEnv *, jclass, jlong, jlong, jboolean);
+
+
 #ifdef __cplusplus
 }
 #endif



Mime
View raw message