diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3.c index a650d5f349f..7320aafd63c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3.c @@ -992,6 +992,48 @@ JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1file_1chooser_1set_1uri) } #endif +#ifndef NO_gtk_1font_1chooser_1dialog_1new +JNIEXPORT jlong JNICALL GTK3_NATIVE(gtk_1font_1chooser_1dialog_1new) + (JNIEnv *env, jclass that, jbyteArray arg0, jlong arg1) +{ + jbyte *lparg0=NULL; + jlong rc = 0; + GTK3_NATIVE_ENTER(env, that, gtk_1font_1chooser_1dialog_1new_FUNC); + if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail; + rc = (jlong)gtk_font_chooser_dialog_new((const gchar *)lparg0, (GtkWindow *)arg1); +fail: + if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0); + GTK3_NATIVE_EXIT(env, that, gtk_1font_1chooser_1dialog_1new_FUNC); + return rc; +} +#endif + +#ifndef NO_gtk_1font_1chooser_1get_1font +JNIEXPORT jlong JNICALL GTK3_NATIVE(gtk_1font_1chooser_1get_1font) + (JNIEnv *env, jclass that, jlong arg0) +{ + jlong rc = 0; + GTK3_NATIVE_ENTER(env, that, gtk_1font_1chooser_1get_1font_FUNC); + rc = (jlong)gtk_font_chooser_get_font((GtkFontChooser *)arg0); + GTK3_NATIVE_EXIT(env, that, gtk_1font_1chooser_1get_1font_FUNC); + return rc; +} +#endif + +#ifndef NO_gtk_1font_1chooser_1set_1font +JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1font_1chooser_1set_1font) + (JNIEnv *env, jclass that, jlong arg0, jbyteArray arg1) +{ + jbyte *lparg1=NULL; + GTK3_NATIVE_ENTER(env, that, gtk_1font_1chooser_1set_1font_FUNC); + if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail; + gtk_font_chooser_set_font((GtkFontChooser *)arg0, (const gchar *)lparg1); +fail: + if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); + GTK3_NATIVE_EXIT(env, that, gtk_1font_1chooser_1set_1font_FUNC); +} +#endif + #ifndef NO_gtk_1frame_1set_1shadow_1type JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1frame_1set_1shadow_1type) (JNIEnv *env, jclass that, jlong arg0, jint arg1) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.h index 656e9558a8c..285dc0afb90 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.h @@ -105,6 +105,9 @@ typedef enum { gtk_1file_1chooser_1set_1local_1only_FUNC, gtk_1file_1chooser_1set_1select_1multiple_FUNC, gtk_1file_1chooser_1set_1uri_FUNC, + gtk_1font_1chooser_1dialog_1new_FUNC, + gtk_1font_1chooser_1get_1font_FUNC, + gtk_1font_1chooser_1set_1font_FUNC, gtk_1frame_1set_1shadow_1type_FUNC, gtk_1gesture_1drag_1new_FUNC, gtk_1gesture_1rotate_1new_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c index dfaf3a62937..10a421b8d9c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c @@ -980,6 +980,112 @@ JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1file_1dialog_1set_1title) } #endif +#ifndef NO_gtk_1font_1dialog_1choose_1font +JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1font_1dialog_1choose_1font) + (JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlong arg2, jlong arg3, jlong arg4, jlong arg5) +{ + GTK4_NATIVE_ENTER(env, that, gtk_1font_1dialog_1choose_1font_FUNC); +/* + gtk_font_dialog_choose_font(arg0, (GtkWindow *)arg1, (PangoFontDescription *)arg2, (GCancellable *)arg3, (GAsyncReadyCallback)arg4, (gpointer)arg5); +*/ + { + GTK4_LOAD_FUNCTION(fp, gtk_font_dialog_choose_font) + if (fp) { + ((void (CALLING_CONVENTION*)(jlong, GtkWindow *, PangoFontDescription *, GCancellable *, GAsyncReadyCallback, gpointer))fp)(arg0, (GtkWindow *)arg1, (PangoFontDescription *)arg2, (GCancellable *)arg3, (GAsyncReadyCallback)arg4, (gpointer)arg5); + } + } + GTK4_NATIVE_EXIT(env, that, gtk_1font_1dialog_1choose_1font_FUNC); +} +#endif + +#ifndef NO_gtk_1font_1dialog_1choose_1font_1finish +JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1font_1dialog_1choose_1font_1finish) + (JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlongArray arg2) +{ + jlong *lparg2=NULL; + jlong rc = 0; + GTK4_NATIVE_ENTER(env, that, gtk_1font_1dialog_1choose_1font_1finish_FUNC); + if (arg2) if ((lparg2 = (*env)->GetLongArrayElements(env, arg2, NULL)) == NULL) goto fail; +/* + rc = (jlong)gtk_font_dialog_choose_font_finish(arg0, (GAsyncResult *)arg1, (GError **)lparg2); +*/ + { + GTK4_LOAD_FUNCTION(fp, gtk_font_dialog_choose_font_finish) + if (fp) { + rc = (jlong)((jlong (CALLING_CONVENTION*)(jlong, GAsyncResult *, GError **))fp)(arg0, (GAsyncResult *)arg1, (GError **)lparg2); + } + } +fail: + if (arg2 && lparg2) (*env)->ReleaseLongArrayElements(env, arg2, lparg2, 0); + GTK4_NATIVE_EXIT(env, that, gtk_1font_1dialog_1choose_1font_1finish_FUNC); + return rc; +} +#endif + +#ifndef NO_gtk_1font_1dialog_1new +JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1font_1dialog_1new) + (JNIEnv *env, jclass that) +{ + jlong rc = 0; + GTK4_NATIVE_ENTER(env, that, gtk_1font_1dialog_1new_FUNC); +/* + rc = (jlong)gtk_font_dialog_new(); +*/ + { + GTK4_LOAD_FUNCTION(fp, gtk_font_dialog_new) + if (fp) { + rc = (jlong)((jlong (CALLING_CONVENTION*)())fp)(); + } + } + GTK4_NATIVE_EXIT(env, that, gtk_1font_1dialog_1new_FUNC); + return rc; +} +#endif + +#ifndef NO_gtk_1font_1dialog_1set_1modal +JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1font_1dialog_1set_1modal) + (JNIEnv *env, jclass that, jlong arg0, jboolean arg1) +{ + jlong rc = 0; + GTK4_NATIVE_ENTER(env, that, gtk_1font_1dialog_1set_1modal_FUNC); +/* + rc = (jlong)gtk_font_dialog_set_modal(arg0, (gboolean)arg1); +*/ + { + GTK4_LOAD_FUNCTION(fp, gtk_font_dialog_set_modal) + if (fp) { + rc = (jlong)((jlong (CALLING_CONVENTION*)(jlong, gboolean))fp)(arg0, (gboolean)arg1); + } + } + GTK4_NATIVE_EXIT(env, that, gtk_1font_1dialog_1set_1modal_FUNC); + return rc; +} +#endif + +#ifndef NO_gtk_1font_1dialog_1set_1title +JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1font_1dialog_1set_1title) + (JNIEnv *env, jclass that, jlong arg0, jbyteArray arg1) +{ + jbyte *lparg1=NULL; + jlong rc = 0; + GTK4_NATIVE_ENTER(env, that, gtk_1font_1dialog_1set_1title_FUNC); + if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail; +/* + rc = (jlong)gtk_font_dialog_set_title(arg0, (char *)lparg1); +*/ + { + GTK4_LOAD_FUNCTION(fp, gtk_font_dialog_set_title) + if (fp) { + rc = (jlong)((jlong (CALLING_CONVENTION*)(jlong, char *))fp)(arg0, (char *)lparg1); + } + } +fail: + if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); + GTK4_NATIVE_EXIT(env, that, gtk_1font_1dialog_1set_1title_FUNC); + return rc; +} +#endif + #ifndef NO_gtk_1frame_1set_1child JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1frame_1set_1child) (JNIEnv *env, jclass that, jlong arg0, jlong arg1) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4_stats.h index f8c9e0bd018..7bdf0eeb903 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4_stats.h @@ -93,6 +93,11 @@ typedef enum { gtk_1file_1dialog_1set_1initial_1folder_FUNC, gtk_1file_1dialog_1set_1initial_1name_FUNC, gtk_1file_1dialog_1set_1title_FUNC, + gtk_1font_1dialog_1choose_1font_FUNC, + gtk_1font_1dialog_1choose_1font_1finish_FUNC, + gtk_1font_1dialog_1new_FUNC, + gtk_1font_1dialog_1set_1modal_FUNC, + gtk_1font_1dialog_1set_1title_FUNC, gtk_1frame_1set_1child_FUNC, gtk_1gesture_1click_1new_FUNC, gtk_1gesture_1drag_1new_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c index 9e036be3b44..999a971259e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c @@ -4781,48 +4781,6 @@ JNIEXPORT void JNICALL GTK_NATIVE(gtk_1file_1filter_1set_1name) } #endif -#ifndef NO_gtk_1font_1chooser_1dialog_1new -JNIEXPORT jlong JNICALL GTK_NATIVE(gtk_1font_1chooser_1dialog_1new) - (JNIEnv *env, jclass that, jbyteArray arg0, jlong arg1) -{ - jbyte *lparg0=NULL; - jlong rc = 0; - GTK_NATIVE_ENTER(env, that, gtk_1font_1chooser_1dialog_1new_FUNC); - if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail; - rc = (jlong)gtk_font_chooser_dialog_new((const gchar *)lparg0, (GtkWindow *)arg1); -fail: - if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0); - GTK_NATIVE_EXIT(env, that, gtk_1font_1chooser_1dialog_1new_FUNC); - return rc; -} -#endif - -#ifndef NO_gtk_1font_1chooser_1get_1font -JNIEXPORT jlong JNICALL GTK_NATIVE(gtk_1font_1chooser_1get_1font) - (JNIEnv *env, jclass that, jlong arg0) -{ - jlong rc = 0; - GTK_NATIVE_ENTER(env, that, gtk_1font_1chooser_1get_1font_FUNC); - rc = (jlong)gtk_font_chooser_get_font((GtkFontChooser *)arg0); - GTK_NATIVE_EXIT(env, that, gtk_1font_1chooser_1get_1font_FUNC); - return rc; -} -#endif - -#ifndef NO_gtk_1font_1chooser_1set_1font -JNIEXPORT void JNICALL GTK_NATIVE(gtk_1font_1chooser_1set_1font) - (JNIEnv *env, jclass that, jlong arg0, jbyteArray arg1) -{ - jbyte *lparg1=NULL; - GTK_NATIVE_ENTER(env, that, gtk_1font_1chooser_1set_1font_FUNC); - if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail; - gtk_font_chooser_set_font((GtkFontChooser *)arg0, (const gchar *)lparg1); -fail: - if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); - GTK_NATIVE_EXIT(env, that, gtk_1font_1chooser_1set_1font_FUNC); -} -#endif - #ifndef NO_gtk_1frame_1get_1label_1widget JNIEXPORT jlong JNICALL GTK_NATIVE(gtk_1frame_1get_1label_1widget) (JNIEnv *env, jclass that, jlong arg0) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h index cc4d4ecce8a..485ac5a9d2c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h @@ -380,9 +380,6 @@ typedef enum { gtk_1file_1filter_1get_1name_FUNC, gtk_1file_1filter_1new_FUNC, gtk_1file_1filter_1set_1name_FUNC, - gtk_1font_1chooser_1dialog_1new_FUNC, - gtk_1font_1chooser_1get_1font_FUNC, - gtk_1font_1chooser_1set_1font_FUNC, gtk_1frame_1get_1label_1widget_FUNC, gtk_1frame_1new_FUNC, gtk_1frame_1set_1label_1widget_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java index 919b524df51..c5a9ff0769e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java @@ -776,22 +776,6 @@ public class GTK extends OS { */ public static final native double gtk_gesture_zoom_get_scale_delta(long gesture); - /* GtkFontChooserDialog */ - /** - * @param title cast=(const gchar *) - * @param parent cast=(GtkWindow *) - */ - public static final native long gtk_font_chooser_dialog_new(byte[] title, long parent); - - /* GtkFontChooser Interface */ - /** @param fontchooser cast=(GtkFontChooser *) */ - public static final native long gtk_font_chooser_get_font(long fontchooser); - /** - * @param fsd cast=(GtkFontChooser *) - * @param fontname cast=(const gchar *) - */ - public static final native void gtk_font_chooser_set_font(long fsd, byte[] fontname); - /* GtkFrame */ /** @param label cast=(const gchar *) */ public static final native long gtk_frame_new(byte[] label); diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GTK3.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GTK3.java index 8b772cf1815..04e4092f0f9 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GTK3.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GTK3.java @@ -1110,6 +1110,22 @@ public class GTK3 { */ public static final native long gtk_gesture_drag_new(long widget); + /* GtkFontChooserDialog */ + /** + * @param title cast=(const gchar *) + * @param parent cast=(GtkWindow *) + */ + public static final native long gtk_font_chooser_dialog_new(byte[] title, long parent); + + /* GtkFontChooser Interface */ + /** @param fontchooser cast=(GtkFontChooser *) */ + public static final native long gtk_font_chooser_get_font(long fontchooser); + /** + * @param fsd cast=(GtkFontChooser *) + * @param fontname cast=(const gchar *) + */ + public static final native void gtk_font_chooser_set_font(long fsd, byte[] fontname); + /* Sizeof */ public static final native int GtkTargetEntry_sizeof(); public static final native int GdkEvent_sizeof(); diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk4/GTK4.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk4/GTK4.java index f255f723e25..752f5aa822c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk4/GTK4.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk4/GTK4.java @@ -283,6 +283,42 @@ public class GTK4 { */ public static final native long gtk_file_dialog_save_finish(long self, long result, long[] error); + /* GtkFontDialog */ + /** + * @method flags=dynamic + * + * @param parent cast=(GtkWindow *) + * @param initial_value cast=(PangoFontDescription *) + * @param cancellable cast=(GCancellable *) + * @param callback cast=(GAsyncReadyCallback) + * @param user_data cast=(gpointer) + */ + public static final native void gtk_font_dialog_choose_font(long self, long parent, long initial_value, long cancellable, long callback, long user_data); + /** + * @method flags=dynamic + * + * @param result cast=(GAsyncResult *) + * @param error cast=(GError **) + */ + public static final native long gtk_font_dialog_choose_font_finish(long self, long result, long[] error); + /** + * @method flags=dynamic + */ + public static final native long gtk_font_dialog_new(); + /** + * @method flags=dynamic + * + * @param modal cast=(gboolean) + */ + public static final native long gtk_font_dialog_set_modal(long self, boolean modal); + /** + * @method flags=dynamic + * + * @param title cast=(char *) + */ + public static final native long gtk_font_dialog_set_title(long self, byte[] title); + + /* GtkScrolledWindow */ public static final native long gtk_scrolled_window_new(); /** @param scrolled_window cast=(GtkScrolledWindow *) */ diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java index 1a26b29ab0a..26a75153355 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2019 IBM Corporation and others. + * Copyright (c) 2000, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -159,23 +159,34 @@ public RGB getRGB () { public FontData open () { byte[] titleBytes = Converter.javaStringToCString(title); Display display = parent != null ? parent.getDisplay(): Display.getCurrent(); - long handle = GTK.gtk_font_chooser_dialog_new (titleBytes, 0); - - if (parent != null) { - long shellHandle = parent.topHandle(); - GTK.gtk_window_set_transient_for(handle, shellHandle); + long handle; + if (GTK.GTK4) { + handle = GTK4.gtk_font_dialog_new(); + } else { + handle = GTK3.gtk_font_chooser_dialog_new (titleBytes, 0); } + if (handle == 0) error (SWT.ERROR_NO_HANDLES); - long defaultWindowGroup = GTK.gtk_window_get_group(0); - GTK.gtk_window_group_add_window(defaultWindowGroup, handle); - GTK.gtk_window_set_modal(handle, true); + if (GTK.GTK4) { + GTK4.gtk_font_dialog_set_modal(handle, true); + GTK4.gtk_font_dialog_set_title(handle, titleBytes); + } else { + if (parent != null) { + long shellHandle = parent.topHandle(); + GTK.gtk_window_set_transient_for(handle, shellHandle); + } + + long defaultWindowGroup = GTK.gtk_window_get_group(0); + GTK.gtk_window_group_add_window(defaultWindowGroup, handle); + GTK.gtk_window_set_modal(handle, true); + } display.addIdleProc(); Dialog oldModal = display.getModalDialog(); display.setModalDialog(this); // Set font chooser dialog to current font - if (fontData != null) { + if (fontData != null && !GTK.GTK4) { Font font = new Font(display, fontData); long fontName = OS.pango_font_description_to_string(font.handle); @@ -185,7 +196,7 @@ public FontData open () { font.dispose(); OS.g_free(fontName); - GTK.gtk_font_chooser_set_font(handle, buffer); + GTK3.gtk_font_chooser_set_font(handle, buffer); } int signalId = 0; @@ -196,8 +207,27 @@ public FontData open () { } int response; + long fontDesc = 0; if (GTK.GTK4) { - response = SyncDialogUtil.run(display, handle, false); + long shellHandle = parent != null ? parent.topHandle() : 0; + Font font = new Font(display, fontData); + fontDesc = SyncDialogUtil.run(display, new AsyncReadyCallback() { + @Override + public void async(long callback) { + // The font dialog ignores the given font and simply picks the first installed font + // See https://gitlab.gnome.org/GNOME/gtk/-/issues/6892 + GTK4.gtk_font_dialog_choose_font(handle, shellHandle, font.handle, 0, callback, 0); + } + + @Override + public long await(long result) { + return GTK4.gtk_font_dialog_choose_font_finish(handle, result, null); + } + + }); + font.dispose(); + + response = fontDesc != 0 ? GTK.GTK_RESPONSE_OK : GTK.GTK_RESPONSE_CANCEL; } else { display.externalEventLoop = true; display.sendPreExternalEventDispatchEvent(); @@ -214,12 +244,14 @@ public FontData open () { boolean success = response == GTK.GTK_RESPONSE_OK; if (success) { - long fontName = GTK.gtk_font_chooser_get_font (handle); - int length = C.strlen (fontName); - byte [] buffer = new byte [length + 1]; - C.memmove (buffer, fontName, length); - OS.g_free (fontName); - long fontDesc = OS.pango_font_description_from_string (buffer); + if (!GTK.GTK4) { + long fontName = GTK3.gtk_font_chooser_get_font (handle); + int length = C.strlen (fontName); + byte [] buffer = new byte [length + 1]; + C.memmove (buffer, fontName, length); + OS.g_free (fontName); + fontDesc = OS.pango_font_description_from_string (buffer); + } Font font = Font.gtk_new (display, fontDesc); fontData = font.getFontData () [0]; OS.pango_font_description_free (fontDesc); @@ -229,9 +261,7 @@ public FontData open () { display.removeIdleProc (); - if (GTK.GTK4) { - GTK4.gtk_window_destroy(handle); - } else { + if (!GTK.GTK4) { GTK3.gtk_widget_destroy(handle); }