gcc/gcc41-rh231818.patch
Jakub Jelinek 260b1eeeea 4.1.2-8
2007-04-03 16:21:25 +00:00

634 lines
24 KiB
Diff

2007-04-02 Francis Kung <fkung@redhat.com>
* gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
(fontSet): Initialize to null.
(FreetypeGlyphVector(Font, int[], FontRenderContext)): Populate fontSet
array with default font if needed.
(FreetypeGlyphVector(FreetypeGlyphVector)): Clone all fields.
(getNativeFontPointer): New native method.
* include/gnu_java_awt_peer_gtk_FreetypeGlyphVector.h: Regenerated.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c
(Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getNativeFontPointer):
New function.
2007-04-02 Francis Kung <fkung@redhat.com>
* gnu/java/awt/peer/gtk/CairoGraphics2D.java
(cairoDrawGlyphVector): Added parameter.
(drawGlyphVector): Retrieve and pass fontset parameter.
* gnu/java/awt/peer/gtk/ComponentGraphics.java
(cairoDrawGlyphVector): Added parameter.
(lock): Removed unnecessary cast.
(unlock): Removed unnecessary cast and explicitly set to ONE variable.
* gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
(fontSet): New field.
(dispose): New native method.
(finalize): New method.
(getGlyphFonts): New method.
(getGlyphOutline): Pass fontSet parameter to native method.
(getGlyphOutlineNative): Added parameter.
(getGlyphs): Pass extra parameters to native method.
(getGlyphsNative): Added parameters.
(getKerning): Added fontSet parameter.
(getMetricsNative): Added fontSet parameter.
(performDefaultLayout): Only check kerning if glyphs use the same font.
(setupGlyphMetrics): Pass extra parameters to native methods.
* include/gnu_java_awt_peer_gtk_CairoGraphics2D.h,
* include/gnu_java_awt_peer_gtk_FreetypGlyphVector.h: Regenerated.
* native/jni/gtk-peer/gdkfont.h: Enable pango engine.
(peerfont): Add variable for fontset.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
(Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawGlyphVector): Accept
array of font pointers to use when drawing glyphs.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c
(getFontSet): New function.
(Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_dispose): New function.
(Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getGlyphOutlineNative):
Added and use new fontSet parameter.
(Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getGlyphs): Use pango
to retrieve glyphs and estimate font, if the current font does not contain
a requested glyph.
(Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getKerning): Added and use
new fontSet parameter.
(Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getMetricsNative): Added
and use new fontSet parameter.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c
(Java_gnu_java_awt_peer_gtk_GdkFontPeer_dispose): Free fontset.
(Java_gnu_java_awt_peer_gtk_GdkFontPeer_setFont): Load fontset.
--- libjava/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java 16 Mar 2007 15:14:53 -0000 1.67
+++ libjava/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java 2 Apr 2007 19:39:26 -0000 1.68
@@ -392,7 +392,7 @@ public abstract class CairoGraphics2D ex
*/
native void cairoDrawGlyphVector(long pointer, GdkFontPeer font,
float x, float y, int n,
- int[] codes, float[] positions);
+ int[] codes, float[] positions, long[] fontset);
/**
* Set the font in cairo.
@@ -1676,6 +1676,7 @@ public abstract class CairoGraphics2D ex
{
int n = gv.getNumGlyphs ();
int[] codes = gv.getGlyphCodes (0, n, null);
+ long[] fontset = ((FreetypeGlyphVector)gv).getGlyphFonts (0, n, null);
float[] positions = gv.getGlyphPositions (0, n, null);
setFont (gv.getFont ());
@@ -1683,7 +1684,7 @@ public abstract class CairoGraphics2D ex
synchronized (fontPeer)
{
cairoDrawGlyphVector(nativePointer, fontPeer,
- x, y, n, codes, positions);
+ x, y, n, codes, positions, fontset);
}
}
else
--- libjava/classpath/gnu/java/awt/peer/gtk/ComponentGraphics.java 16 Mar 2007 15:14:53 -0000 1.25
+++ libjava/classpath/gnu/java/awt/peer/gtk/ComponentGraphics.java 2 Apr 2007 19:39:26 -0000 1.26
@@ -134,6 +134,8 @@ public class ComponentGraphics extends C
hasLock.set(null);
end_gdk_drawing();
}
+ else if (i.intValue() == 2)
+ hasLock.set(ONE);
else
hasLock.set(Integer.valueOf(i.intValue() - 1));
}
--- libjava/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java 6 Mar 2007 19:38:31 -0000 1.16
+++ libjava/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java 2 Apr 2007 21:28:58 -0000 1.18
@@ -79,6 +79,11 @@ public class FreetypeGlyphVector extends
* The glyph codes
*/
private int[] glyphCodes;
+
+ /**
+ * The set of fonts used in this glyph vector.
+ */
+ private long[] fontSet = null;
/**
* Glyph transforms. (de facto only the translation is used)
@@ -86,6 +91,19 @@ public class FreetypeGlyphVector extends
private AffineTransform[] glyphTransforms;
private GlyphMetrics[] metricsCache;
+
+ private native void dispose(long[] fonts);
+
+ /**
+ * Returns a pointer to the native PangoFcFont object.
+ *
+ * The object will be referenced with g_object_ref n times before being
+ * returned, and must be unreferenced a corresponding number of times.
+ *
+ * @param n Number of times to reference the object.
+ * @return Pointer to the native default font.
+ */
+ private native long getNativeFontPointer(int n);
/**
* Create a glyphvector from a given (Freetype) font and a String.
@@ -135,6 +153,13 @@ public class FreetypeGlyphVector extends
glyphCodes = new int[ codes.length ];
System.arraycopy(codes, 0, glyphCodes, 0, codes.length);
nGlyphs = glyphCodes.length;
+
+ if (fontSet == null)
+ {
+ fontSet = new long[nGlyphs];
+ Arrays.fill(fontSet, getNativeFontPointer(nGlyphs));
+ }
+
performDefaultLayout();
}
@@ -157,6 +182,7 @@ public class FreetypeGlyphVector extends
}
glyphCodes = new int[ nGlyphs ];
+ fontSet = new long[nGlyphs];
glyphPositions = new float[(nGlyphs + 1) * 2];
glyphTransforms = new AffineTransform[ nGlyphs ];
for(int i = 0; i < nGlyphs; i++ )
@@ -166,6 +192,13 @@ public class FreetypeGlyphVector extends
}
System.arraycopy(gv.glyphPositions, 0, glyphPositions, 0,
glyphPositions.length);
+ System.arraycopy(gv.glyphCodes, 0, glyphCodes, 0, nGlyphs);
+ System.arraycopy(gv.fontSet, 0, fontSet, 0, nGlyphs);
+ }
+
+ public void finalize()
+ {
+ dispose(fontSet);
}
/**
@@ -175,6 +208,7 @@ public class FreetypeGlyphVector extends
{
nGlyphs = s.codePointCount( 0, s.length() );
glyphCodes = new int[ nGlyphs ];
+ fontSet = new long[ nGlyphs ];
int[] codePoints = new int[ nGlyphs ];
int stringIndex = 0;
@@ -194,22 +228,22 @@ public class FreetypeGlyphVector extends
}
}
- glyphCodes = getGlyphs( codePoints );
+ getGlyphs( codePoints, glyphCodes, fontSet );
}
/**
* Returns the glyph code within the font for a given character
*/
- public native int[] getGlyphs(int[] codepoints);
+ public native int[] getGlyphs(int[] codepoints, int[] glyphs, long[] fonts);
/**
* Returns the kerning of a glyph pair
*/
- private native Point2D getKerning(int leftGlyph, int rightGlyph);
+ private native Point2D getKerning(int leftGlyph, int rightGlyph, long font);
- private native double[] getMetricsNative( int glyphCode );
+ private native double[] getMetricsNative(int glyphCode, long font);
- private native GeneralPath getGlyphOutlineNative(int glyphIndex);
+ private native GeneralPath getGlyphOutlineNative(int glyphIndex, long font);
public Object clone()
@@ -267,10 +301,12 @@ public class FreetypeGlyphVector extends
x += gm.getAdvanceX();
y += gm.getAdvanceY();
-
- if (i != nGlyphs-1)
+
+ // Get the kerning only if it's not the last glyph, and the two glyphs are
+ // using the same font
+ if (i != nGlyphs-1 && fontSet[i] == fontSet[i+1])
{
- Point2D p = getKerning(glyphCodes[i], glyphCodes[i + 1]);
+ Point2D p = getKerning(glyphCodes[i], glyphCodes[i + 1], fontSet[i]);
x += p.getX();
y += p.getY();
}
@@ -305,6 +341,26 @@ public class FreetypeGlyphVector extends
return rval;
}
+ /**
+ * Returns pointers to the fonts used in this glyph vector.
+ *
+ * The array index matches that of the glyph vector itself.
+ */
+ protected long[] getGlyphFonts(int beginGlyphIndex, int numEntries,
+ long[] codeReturn)
+ {
+ long[] rval;
+
+ if( codeReturn == null || codeReturn.length < numEntries)
+ rval = new long[ numEntries ];
+ else
+ rval = codeReturn;
+
+ System.arraycopy(fontSet, beginGlyphIndex, rval, 0, numEntries);
+
+ return rval;
+ }
+
public Shape getGlyphLogicalBounds(int glyphIndex)
{
GlyphMetrics gm = getGlyphMetrics( glyphIndex );
@@ -335,11 +391,10 @@ public class FreetypeGlyphVector extends
for(int i = 0; i < nGlyphs; i++)
{
- GlyphMetrics gm = (GlyphMetrics)
- peer.getGlyphMetrics( glyphCodes[ i ] );
+ GlyphMetrics gm = (GlyphMetrics)peer.getGlyphMetrics(glyphCodes[i]);
if( gm == null )
{
- double[] val = getMetricsNative( glyphCodes[ i ] );
+ double[] val = getMetricsNative(glyphCodes[i], fontSet[i]);
if( val == null )
gm = null;
else
@@ -374,7 +429,8 @@ public class FreetypeGlyphVector extends
*/
public Shape getGlyphOutline(int glyphIndex)
{
- GeneralPath gp = getGlyphOutlineNative( glyphCodes[ glyphIndex ] );
+ GeneralPath gp = getGlyphOutlineNative(glyphCodes[glyphIndex],
+ fontSet[glyphIndex]);
if (glyphTransforms[glyphIndex] != null)
gp.transform( glyphTransforms[glyphIndex]);
--- libjava/classpath/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h 16 Mar 2007 15:14:53 -0000 1.17
+++ libjava/classpath/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h 2 Apr 2007 19:39:26 -0000 1.18
@@ -22,7 +22,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetFillRule (JNIEnv *env, jobject, jlong, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetLine (JNIEnv *env, jobject, jlong, jdouble, jint, jint, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetDash (JNIEnv *env, jobject, jlong, jdoubleArray, jint, jdouble);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawGlyphVector (JNIEnv *env, jobject, jlong, jobject, jfloat, jfloat, jint, jintArray, jfloatArray);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawGlyphVector (JNIEnv *env, jobject, jlong, jobject, jfloat, jfloat, jint, jintArray, jfloatArray, jlongArray);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetFont (JNIEnv *env, jobject, jlong, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoRectangle (JNIEnv *env, jobject, jlong, jdouble, jdouble, jdouble, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoArc (JNIEnv *env, jobject, jlong, jdouble, jdouble, jdouble, jdouble, jdouble);
--- libjava/classpath/include/gnu_java_awt_peer_gtk_FreetypeGlyphVector.h 11 Jun 2006 08:29:57 -0000 1.2
+++ libjava/classpath/include/gnu_java_awt_peer_gtk_FreetypeGlyphVector.h 2 Apr 2007 21:28:58 -0000 1.4
@@ -10,10 +10,12 @@ extern "C"
{
#endif
-JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getGlyphs (JNIEnv *env, jobject, jintArray);
-JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getKerning (JNIEnv *env, jobject, jint, jint);
-JNIEXPORT jdoubleArray JNICALL Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getMetricsNative (JNIEnv *env, jobject, jint);
-JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getGlyphOutlineNative (JNIEnv *env, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getGlyphs (JNIEnv *env, jobject, jintArray, jintArray, jlongArray);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getKerning (JNIEnv *env, jobject, jint, jint, jlong);
+JNIEXPORT jdoubleArray JNICALL Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getMetricsNative (JNIEnv *env, jobject, jint, jlong);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getGlyphOutlineNative (JNIEnv *env, jobject, jint, jlong);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_dispose (JNIEnv *env, jobject, jlongArray);
+JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getNativeFontPointer (JNIEnv *env, jobject, jint);
#ifdef __cplusplus
}
--- libjava/classpath/native/jni/gtk-peer/gdkfont.h 21 Nov 2006 14:14:25 -0000 1.10
+++ libjava/classpath/native/jni/gtk-peer/gdkfont.h 2 Apr 2007 19:39:26 -0000 1.11
@@ -40,6 +40,7 @@
#include "gtkpeer.h"
+#define PANGO_ENABLE_ENGINE
#include <pango/pango.h>
#include <pango/pango-context.h>
#include <pango/pango-fontmap.h>
@@ -123,6 +124,7 @@ extern struct state_table *cp_gtk_native
struct peerfont
{
PangoFont *font;
+ PangoFontset *set;
PangoFontDescription *desc;
PangoContext *ctx;
PangoLayout *layout;
--- libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c 16 Mar 2007 15:14:55 -0000 1.21
+++ libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c 2 Apr 2007 19:39:26 -0000 1.22
@@ -308,9 +308,8 @@ Java_gnu_java_awt_peer_gtk_CairoGraphics
jobject font,
jfloat x, jfloat y, jint n,
jintArray java_codes,
- jfloatArray java_positions)
+ jfloatArray java_positions, jlongArray java_fontset)
{
-
struct cairographics2d *gr = NULL;
struct peerfont *pfont = NULL;
cairo_glyph_t *glyphs = NULL;
@@ -333,6 +332,7 @@ Java_gnu_java_awt_peer_gtk_CairoGraphics
native_codes = (*env)->GetIntArrayElements (env, java_codes, NULL);
native_positions = (*env)->GetFloatArrayElements (env, java_positions, NULL);
+ /* Set up glyphs and layout */
for (i = 0; i < n; ++i)
{
glyphs[i].index = native_codes[i];
@@ -343,10 +343,31 @@ Java_gnu_java_awt_peer_gtk_CairoGraphics
(*env)->ReleaseFloatArrayElements (env, java_positions, native_positions, 0);
(*env)->ReleaseIntArrayElements (env, java_codes, native_codes, 0);
- pango_fc_font_lock_face( (PangoFcFont *)pfont->font );
- cairo_show_glyphs (gr->cr, glyphs, n);
- pango_fc_font_unlock_face( (PangoFcFont *)pfont->font );
+ /* Iterate through glyphs and draw */
+ jlong* fonts = (*env)->GetLongArrayElements (env, java_fontset, NULL);
+ for (i = 0; i < n; i++)
+ {
+ PangoFcFont *font = JLONG_TO_PTR(PangoFcFont, fonts[i]);
+
+ /* Draw as many glyphs as possible with the current font */
+ int length = 0;
+ while (i < n-1 && fonts[i] == fonts[i+1])
+ {
+ length++;
+ i++;
+ }
+
+ FT_Face face = pango_fc_font_lock_face( font );
+ cairo_font_face_t *ft = cairo_ft_font_face_create_for_ft_face (face, 0);
+ g_assert (ft != NULL);
+ cairo_set_font_face (gr->cr, ft);
+ cairo_show_glyphs (gr->cr, &glyphs[i-length], length+1);
+
+ cairo_font_face_destroy (ft);
+ pango_fc_font_unlock_face(font);
+ }
+
g_free(glyphs);
}
--- libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c 11 Jun 2006 11:31:03 -0000 1.4
+++ libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c 2 Apr 2007 21:28:59 -0000 1.6
@@ -35,6 +35,7 @@ this exception to your version of the li
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+#define PANGO_ENABLE_ENGINE
#include <jni.h>
#include <gtk/gtk.h>
#include <string.h>
@@ -43,6 +44,7 @@ exception statement from your version. *
#include <pango/pangofc-font.h>
#include <freetype/ftglyph.h>
#include <freetype/ftoutln.h>
+#include "jcl.h"
#include "native_state.h"
#include "gdkfont.h"
#include "gnu_java_awt_peer_gtk_FreetypeGlyphVector.h"
@@ -81,42 +83,92 @@ getFont(JNIEnv *env, jobject obj)
return (PangoFcFont *)pfont->font;
}
-JNIEXPORT jintArray JNICALL
+static PangoFontset *
+getFontSet(JNIEnv *env, jobject obj)
+{
+ jfieldID fid;
+ jobject data;
+ jclass cls;
+ struct peerfont *pfont;
+
+ cls = (*env)->GetObjectClass (env, obj);
+ fid = (*env)->GetFieldID (env, cls, "peer",
+ "Lgnu/java/awt/peer/gtk/GdkFontPeer;");
+ g_assert (fid != 0);
+
+ data = (*env)->GetObjectField (env, obj, fid);
+ g_assert (data != NULL);
+
+ pfont = (struct peerfont *)NSA_GET_FONT_PTR (env, data);
+ g_assert (pfont != NULL);
+ g_assert (pfont->font != NULL);
+
+ return (PangoFontset *)pfont->set;
+}
+
+JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getGlyphs
- (JNIEnv *env, jobject obj, jintArray codepoints)
+ (JNIEnv *env, jobject obj, jintArray codepoints, jintArray glyphs,
+ jlongArray fonts)
{
- FT_Face ft_face;
- jintArray retArray;
- PangoFcFont *font;
- jint *values, *cpvals;
+ PangoFcFont *default_font, *current_font;
+ PangoFontset *pfs;
+ jint *cpvals;
jint length;
int i;
- font = getFont(env, obj);
-
- ft_face = pango_fc_font_lock_face( font );
- g_assert (ft_face != NULL);
+ /* Set up default font and fontset */
+ default_font = getFont(env, obj);
+ current_font = default_font;
+ pfs = getFontSet(env, obj);
+ /* Retrieve string information */
length = (*env)->GetArrayLength (env, codepoints);
cpvals = (*env)->GetIntArrayElements (env, codepoints, NULL);
+
+ jint *glyphArray = (*env)->GetIntArrayElements (env, glyphs, NULL);
+ jlong *fontArray = (*env)->GetLongArrayElements (env, fonts, NULL);
- retArray = (*env)->NewIntArray (env, length);
- values = (*env)->GetIntArrayElements (env, retArray, NULL);
+ /* A design goal of Pango is to be threadsafe, but it's admitted that it is
+ * not actually threadsafe at the moment. Using gdk locking here to be safe,
+ * but I don't know if if actually helps at all... */
+ gdk_threads_enter();
for( i = 0; i < length; i++ )
- values[i] = FT_Get_Char_Index( ft_face, cpvals[i] );
+ {
+ /* Ensure the current font has the requested character; if it doesn't,
+ * try the default font before pulling a new font out of the fontset.
+ * Once chosen, a font will be used until a character not in the font is
+ * encountered. */
+ if (!pango_fc_font_has_char(current_font, cpvals[i]))
+ {
+ if (pango_fc_font_has_char(default_font, cpvals[i]))
+ {
+ current_font = default_font;
+ }
+ else
+ {
+ current_font = (PangoFcFont*)pango_fontset_get_font(pfs, cpvals[i]);
+ }
+ }
+
+ /* Get glyph, and store both glyph and pointer to font */
+ glyphArray[i] = (int)pango_fc_font_get_glyph(current_font,
+ (gunichar)cpvals[i]);
+ g_object_ref(current_font);
+ fontArray[i] = PTR_TO_JLONG(current_font);
+ }
+
+ gdk_threads_leave();
- (*env)->ReleaseIntArrayElements (env, retArray, values, 0);
+ (*env)->ReleaseIntArrayElements (env, glyphs, glyphArray, 0);
(*env)->ReleaseIntArrayElements (env, codepoints, cpvals, 0);
-
- pango_fc_font_unlock_face (font);
-
- return retArray;
+ (*env)->ReleaseLongArrayElements (env, fonts, fontArray, 0);
}
JNIEXPORT jobject JNICALL
Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getKerning
-(JNIEnv *env, jobject obj, jint rightGlyph, jint leftGlyph)
+(JNIEnv *env, jobject obj __attribute__((unused)), jint rightGlyph, jint leftGlyph, jlong fnt)
{
FT_Face ft_face;
FT_Vector kern;
@@ -125,7 +177,7 @@ Java_gnu_java_awt_peer_gtk_FreetypeGlyph
jvalue values[2];
PangoFcFont *font;
- font = getFont(env, obj);
+ font = JLONG_TO_PTR(PangoFcFont, fnt);
ft_face = pango_fc_font_lock_face( font );
g_assert (ft_face != NULL);
FT_Get_Kerning( ft_face, rightGlyph, leftGlyph, FT_KERNING_DEFAULT, &kern );
@@ -142,14 +194,14 @@ Java_gnu_java_awt_peer_gtk_FreetypeGlyph
JNIEXPORT jdoubleArray JNICALL
Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getMetricsNative
-(JNIEnv *env, jobject obj, jint glyphIndex )
+(JNIEnv *env, jobject obj __attribute__((unused)), jint glyphIndex, jlong fnt)
{
FT_Face ft_face;
jdouble *values;
jdoubleArray retArray = NULL;
PangoFcFont *font;
- font = getFont(env, obj);
+ font = JLONG_TO_PTR(PangoFcFont, fnt);
ft_face = pango_fc_font_lock_face( font );
g_assert (ft_face != NULL);
@@ -285,7 +337,7 @@ static int _curveTo( const FT_Vector* c
JNIEXPORT jobject JNICALL
Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getGlyphOutlineNative
- (JNIEnv *env, jobject obj, jint glyphIndex)
+ (JNIEnv *env, jobject obj __attribute__((unused)), jint glyphIndex, jlong fnt)
{
generalpath *path;
jobject gp;
@@ -302,7 +354,7 @@ Java_gnu_java_awt_peer_gtk_FreetypeGlyph
FT_Face ft_face;
FT_Glyph glyph;
- font = getFont(env, obj);
+ font = JLONG_TO_PTR(PangoFcFont, fnt);
ft_face = pango_fc_font_lock_face( font );
g_assert (ft_face != NULL);
@@ -345,4 +397,39 @@ Java_gnu_java_awt_peer_gtk_FreetypeGlyph
return gp;
}
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_dispose
+ (JNIEnv *env, jobject obj __attribute__((unused)), jlongArray fontset)
+{
+ PangoFcFont *font;
+ jlong *fontArray;
+ int i, length;
+ length = (*env)->GetArrayLength (env, fontset);
+ fontArray = (*env)->GetLongArrayElements (env, fontset, NULL);
+
+ gdk_threads_enter();
+
+ for( i = 0; i < length; i++ )
+ {
+ font = JLONG_TO_PTR(PangoFcFont, fontArray[i]);
+ g_object_unref(font);
+ }
+
+ gdk_threads_leave();
+
+ (*env)->ReleaseLongArrayElements (env, fontset, fontArray, 0);
+}
+
+JNIEXPORT jlong JNICALL
+Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getNativeFontPointer
+ (JNIEnv *env, jobject obj, jint n)
+{
+ int i;
+ PangoFcFont *font = getFont(env, obj);
+
+ for (i = 0; i < n; i++)
+ g_object_ref(font);
+
+ return PTR_TO_JLONG(font);
+}
--- libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c 26 Feb 2007 22:11:38 -0000 1.22
+++ libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c 2 Apr 2007 19:39:26 -0000 1.23
@@ -35,6 +35,7 @@
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+#define PANGO_ENABLE_ENGINE
#include <pango/pango.h>
#include <pango/pangoft2.h>
#include <pango/pangofc-font.h>
@@ -97,6 +98,8 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_d
g_object_unref (pfont->layout);
if (pfont->font != NULL)
g_object_unref (pfont->font);
+ if (pfont->set != NULL)
+ g_object_unref (pfont->set);
if (pfont->ctx != NULL)
g_object_unref (pfont->ctx);
if (pfont->desc != NULL)
@@ -257,6 +260,8 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_s
g_object_unref (pfont->ctx);
if (pfont->font != NULL)
g_object_unref (pfont->font);
+ if (pfont->set != NULL)
+ g_object_unref (pfont->set);
if (pfont->desc != NULL)
pango_font_description_free (pfont->desc);
@@ -268,7 +273,6 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_s
pango_font_description_set_family (pfont->desc, family_name);
(*env)->ReleaseStringUTFChars(env, family_name_str, family_name);
-
if (style & java_awt_font_BOLD)
pango_font_description_set_weight (pfont->desc, PANGO_WEIGHT_BOLD);
@@ -293,6 +297,8 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_s
pango_context_set_font_description (pfont->ctx, pfont->desc);
pango_context_set_language (pfont->ctx, gtk_get_default_language());
+ pfont->set = pango_context_load_fontset(pfont->ctx, pfont->desc,
+ gtk_get_default_language());
pfont->font = pango_context_load_font (pfont->ctx, pfont->desc);
g_assert (pfont->font != NULL);