Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 6032 invoked from network); 12 Oct 2007 13:14:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Oct 2007 13:14:29 -0000 Received: (qmail 24500 invoked by uid 500); 12 Oct 2007 13:14:17 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 24482 invoked by uid 500); 12 Oct 2007 13:14:17 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 24473 invoked by uid 99); 12 Oct 2007 13:14:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Oct 2007 06:14:17 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Oct 2007 13:14:29 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id F421E1A9832; Fri, 12 Oct 2007 06:14:08 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@harmony.apache.org From: ayza@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071012131408.F421E1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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