harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Hindess <mark.hind...@googlemail.com>
Subject [classlib] Re: 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 Tue, 16 Oct 2007 19:09:07 GMT

Alexei,

The change to LinuxNativeFont.cpp introduces to calls to
newNullPointerException.  There were other references to this function
in the originally contributed version of this file but in order to be
consistent with the rest of the native code, I replaced them in commit:

  r423405 | hindessm | 2006-07-19 09:51:27 +0100 (Wed, 19 Jul 2006) | 1 line

  Change awt natives to use exception functions from luni common library.

I can't understand how this code would work for you.  I get undefined
symbol errors when the dlopen call tries to load the linuxfont dll.

I've checked in a change, r585221, to replace these function calls with
calls to the replacement current equivalent function, throwNPException.

The linux fonts look much better for me now.  Nice work Dmitriy.

Regards,
 Mark.

On 12 October 2007 at 13:11, ayza@apache.org wrote:
> 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 ([classli
> b][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/uni
> x/LinuxNativeFont.c
>     harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/uni
> x/exports.txt
>     harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/uni
> x/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=5
> 84159&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, bo
> olean 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.roun
> d(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/linuxfo
> nt/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=584
> 159&view=diff
> =============================================================================
> =
> --- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/uni
> x/LinuxNativeFont.c (original)
> +++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/uni
> x/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 i
> sAntialiasing){
> +	
> +    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 XFTPatter
> n structure");
> +        }
> +	}
> +    else {
> +        if (!XftPatternAddBool(mpattern, XFT_ANTIALIAS, False)) {
> +            newNullPointerException(env,
> +                "Error during adding font antialias set to false to XFTPatte
> rn structure");
> +        }
> +    }
> +
> +    XftFont *aaFnt = XftFontOpenPattern(dpy, mpattern);
> +    return (long)aaFnt;
> +}
> 
> Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfo
> nt/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&vi
> ew=diff
> =============================================================================
> =
> --- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/uni
> x/exports.txt (original)
> +++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/uni
> x/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/linuxfo
> nt/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_LinuxN
> ativeFont.h?rev=584159&r1=584158&r2=584159&view=diff
> =============================================================================
> =
> --- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/uni
> x/include/org_apache_harmony_awt_gl_font_LinuxNativeFont.h (original)
> +++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/uni
> x/include/org_apache_harmony_awt_gl_font_LinuxNativeFont.h Fri Oct 12 06:10:3
> 3 2007
> @@ -263,6 +263,16 @@
>  JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_font_LinuxNativeFont_f
> reeGlyphOutline
>    (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