1999-03-13 Tor Lillqvist <tml@iki.fi>
- * configure.in acconfig.h: Check for dirent.h and pwd.h.
+ * configure.in acconfig.h: Check for dirent.h and pwd.h. Generate
+ gdk/gdkconfig.h using similar mechanism as GLib's glibconfig.h.
+ * gtk-config.in: Add @libdir/gtk+/include (where gdkconfig.h is
+ installed) to CFLAGS.
+
+ * gdk/Makefile.am: Add rules for gdkconfig.h.
+
+ * gdk/gdktypes.h: Include gdkconfig.h. Define macros for windowing
+ APIs.
+
+ * gdk/gdkfontsel.c: Don't include Xlib.h, it gets included via
+ gdkx.h anyway when compiling for X11.
+ (gtk_font_selection_create_xlfd): Use g_strdup_printf. (In
+ general): Merge in Win32 version.
+
* gtk/gtkfilesel.c: Use g_get_current_dir(). Merge in Win32
version: Use G_DIR_SEPARATOR, g_path_is_absolute, no tilde
- expansion (based on HAVE_PWD_H), allow for drive letters. UNC
- paths (\\server\share\...) not handled yet. Also, code from Craig
- Setera's port to Win32 that uses cygwin.dll
+ expansion (if we don't have HAVE_PWD_H), allow for drive
+ letters. UNC paths (\\server\share\...) are not handled yet. Also,
+ included code from Craig Setera's port to Win32 (the one that uses
+ X11, and the cygwin dll), even if it probably will be abandoned.
* gtk/gtkfilesel.c: Don't append a * to the pattern to complete if
the user entered one herself. This way one can complete *.h and
1999-03-13 Tor Lillqvist <tml@iki.fi>
- * configure.in acconfig.h: Check for dirent.h and pwd.h.
+ * configure.in acconfig.h: Check for dirent.h and pwd.h. Generate
+ gdk/gdkconfig.h using similar mechanism as GLib's glibconfig.h.
+ * gtk-config.in: Add @libdir/gtk+/include (where gdkconfig.h is
+ installed) to CFLAGS.
+
+ * gdk/Makefile.am: Add rules for gdkconfig.h.
+
+ * gdk/gdktypes.h: Include gdkconfig.h. Define macros for windowing
+ APIs.
+
+ * gdk/gdkfontsel.c: Don't include Xlib.h, it gets included via
+ gdkx.h anyway when compiling for X11.
+ (gtk_font_selection_create_xlfd): Use g_strdup_printf. (In
+ general): Merge in Win32 version.
+
* gtk/gtkfilesel.c: Use g_get_current_dir(). Merge in Win32
version: Use G_DIR_SEPARATOR, g_path_is_absolute, no tilde
- expansion (based on HAVE_PWD_H), allow for drive letters. UNC
- paths (\\server\share\...) not handled yet. Also, code from Craig
- Setera's port to Win32 that uses cygwin.dll
+ expansion (if we don't have HAVE_PWD_H), allow for drive
+ letters. UNC paths (\\server\share\...) are not handled yet. Also,
+ included code from Craig Setera's port to Win32 (the one that uses
+ X11, and the cygwin dll), even if it probably will be abandoned.
* gtk/gtkfilesel.c: Don't append a * to the pattern to complete if
the user entered one herself. This way one can complete *.h and
1999-03-13 Tor Lillqvist <tml@iki.fi>
- * configure.in acconfig.h: Check for dirent.h and pwd.h.
+ * configure.in acconfig.h: Check for dirent.h and pwd.h. Generate
+ gdk/gdkconfig.h using similar mechanism as GLib's glibconfig.h.
+ * gtk-config.in: Add @libdir/gtk+/include (where gdkconfig.h is
+ installed) to CFLAGS.
+
+ * gdk/Makefile.am: Add rules for gdkconfig.h.
+
+ * gdk/gdktypes.h: Include gdkconfig.h. Define macros for windowing
+ APIs.
+
+ * gdk/gdkfontsel.c: Don't include Xlib.h, it gets included via
+ gdkx.h anyway when compiling for X11.
+ (gtk_font_selection_create_xlfd): Use g_strdup_printf. (In
+ general): Merge in Win32 version.
+
* gtk/gtkfilesel.c: Use g_get_current_dir(). Merge in Win32
version: Use G_DIR_SEPARATOR, g_path_is_absolute, no tilde
- expansion (based on HAVE_PWD_H), allow for drive letters. UNC
- paths (\\server\share\...) not handled yet. Also, code from Craig
- Setera's port to Win32 that uses cygwin.dll
+ expansion (if we don't have HAVE_PWD_H), allow for drive
+ letters. UNC paths (\\server\share\...) are not handled yet. Also,
+ included code from Craig Setera's port to Win32 (the one that uses
+ X11, and the cygwin dll), even if it probably will be abandoned.
* gtk/gtkfilesel.c: Don't append a * to the pattern to complete if
the user entered one herself. This way one can complete *.h and
1999-03-13 Tor Lillqvist <tml@iki.fi>
- * configure.in acconfig.h: Check for dirent.h and pwd.h.
+ * configure.in acconfig.h: Check for dirent.h and pwd.h. Generate
+ gdk/gdkconfig.h using similar mechanism as GLib's glibconfig.h.
+ * gtk-config.in: Add @libdir/gtk+/include (where gdkconfig.h is
+ installed) to CFLAGS.
+
+ * gdk/Makefile.am: Add rules for gdkconfig.h.
+
+ * gdk/gdktypes.h: Include gdkconfig.h. Define macros for windowing
+ APIs.
+
+ * gdk/gdkfontsel.c: Don't include Xlib.h, it gets included via
+ gdkx.h anyway when compiling for X11.
+ (gtk_font_selection_create_xlfd): Use g_strdup_printf. (In
+ general): Merge in Win32 version.
+
* gtk/gtkfilesel.c: Use g_get_current_dir(). Merge in Win32
version: Use G_DIR_SEPARATOR, g_path_is_absolute, no tilde
- expansion (based on HAVE_PWD_H), allow for drive letters. UNC
- paths (\\server\share\...) not handled yet. Also, code from Craig
- Setera's port to Win32 that uses cygwin.dll
+ expansion (if we don't have HAVE_PWD_H), allow for drive
+ letters. UNC paths (\\server\share\...) are not handled yet. Also,
+ included code from Craig Setera's port to Win32 (the one that uses
+ X11, and the cygwin dll), even if it probably will be abandoned.
* gtk/gtkfilesel.c: Don't append a * to the pattern to complete if
the user entered one herself. This way one can complete *.h and
1999-03-13 Tor Lillqvist <tml@iki.fi>
- * configure.in acconfig.h: Check for dirent.h and pwd.h.
+ * configure.in acconfig.h: Check for dirent.h and pwd.h. Generate
+ gdk/gdkconfig.h using similar mechanism as GLib's glibconfig.h.
+ * gtk-config.in: Add @libdir/gtk+/include (where gdkconfig.h is
+ installed) to CFLAGS.
+
+ * gdk/Makefile.am: Add rules for gdkconfig.h.
+
+ * gdk/gdktypes.h: Include gdkconfig.h. Define macros for windowing
+ APIs.
+
+ * gdk/gdkfontsel.c: Don't include Xlib.h, it gets included via
+ gdkx.h anyway when compiling for X11.
+ (gtk_font_selection_create_xlfd): Use g_strdup_printf. (In
+ general): Merge in Win32 version.
+
* gtk/gtkfilesel.c: Use g_get_current_dir(). Merge in Win32
version: Use G_DIR_SEPARATOR, g_path_is_absolute, no tilde
- expansion (based on HAVE_PWD_H), allow for drive letters. UNC
- paths (\\server\share\...) not handled yet. Also, code from Craig
- Setera's port to Win32 that uses cygwin.dll
+ expansion (if we don't have HAVE_PWD_H), allow for drive
+ letters. UNC paths (\\server\share\...) are not handled yet. Also,
+ included code from Craig Setera's port to Win32 (the one that uses
+ X11, and the cygwin dll), even if it probably will be abandoned.
* gtk/gtkfilesel.c: Don't append a * to the pattern to complete if
the user entered one herself. This way one can complete *.h and
1999-03-13 Tor Lillqvist <tml@iki.fi>
- * configure.in acconfig.h: Check for dirent.h and pwd.h.
+ * configure.in acconfig.h: Check for dirent.h and pwd.h. Generate
+ gdk/gdkconfig.h using similar mechanism as GLib's glibconfig.h.
+ * gtk-config.in: Add @libdir/gtk+/include (where gdkconfig.h is
+ installed) to CFLAGS.
+
+ * gdk/Makefile.am: Add rules for gdkconfig.h.
+
+ * gdk/gdktypes.h: Include gdkconfig.h. Define macros for windowing
+ APIs.
+
+ * gdk/gdkfontsel.c: Don't include Xlib.h, it gets included via
+ gdkx.h anyway when compiling for X11.
+ (gtk_font_selection_create_xlfd): Use g_strdup_printf. (In
+ general): Merge in Win32 version.
+
* gtk/gtkfilesel.c: Use g_get_current_dir(). Merge in Win32
version: Use G_DIR_SEPARATOR, g_path_is_absolute, no tilde
- expansion (based on HAVE_PWD_H), allow for drive letters. UNC
- paths (\\server\share\...) not handled yet. Also, code from Craig
- Setera's port to Win32 that uses cygwin.dll
+ expansion (if we don't have HAVE_PWD_H), allow for drive
+ letters. UNC paths (\\server\share\...) are not handled yet. Also,
+ included code from Craig Setera's port to Win32 (the one that uses
+ X11, and the cygwin dll), even if it probably will be abandoned.
* gtk/gtkfilesel.c: Don't append a * to the pattern to complete if
the user entered one herself. This way one can complete *.h and
1999-03-13 Tor Lillqvist <tml@iki.fi>
- * configure.in acconfig.h: Check for dirent.h and pwd.h.
+ * configure.in acconfig.h: Check for dirent.h and pwd.h. Generate
+ gdk/gdkconfig.h using similar mechanism as GLib's glibconfig.h.
+ * gtk-config.in: Add @libdir/gtk+/include (where gdkconfig.h is
+ installed) to CFLAGS.
+
+ * gdk/Makefile.am: Add rules for gdkconfig.h.
+
+ * gdk/gdktypes.h: Include gdkconfig.h. Define macros for windowing
+ APIs.
+
+ * gdk/gdkfontsel.c: Don't include Xlib.h, it gets included via
+ gdkx.h anyway when compiling for X11.
+ (gtk_font_selection_create_xlfd): Use g_strdup_printf. (In
+ general): Merge in Win32 version.
+
* gtk/gtkfilesel.c: Use g_get_current_dir(). Merge in Win32
version: Use G_DIR_SEPARATOR, g_path_is_absolute, no tilde
- expansion (based on HAVE_PWD_H), allow for drive letters. UNC
- paths (\\server\share\...) not handled yet. Also, code from Craig
- Setera's port to Win32 that uses cygwin.dll
+ expansion (if we don't have HAVE_PWD_H), allow for drive
+ letters. UNC paths (\\server\share\...) are not handled yet. Also,
+ included code from Craig Setera's port to Win32 (the one that uses
+ X11, and the cygwin dll), even if it probably will be abandoned.
* gtk/gtkfilesel.c: Don't append a * to the pattern to complete if
the user entered one herself. This way one can complete *.h and
AC_SUBST(GTK_XIM_FLAGS)
AC_SUBST(GTK_LOCALE_FLAGS)
+AC_OUTPUT_COMMANDS([
+
+## Generate `gdk/gdkconfig.h' in two cases
+## 1. `config.status' is run either explicitly, or via configure.
+## Esp. not when it is run in `Makefile' to generate makefiles and
+## config.h
+## 2. CONFIG_OTHER is set explicitly
+##
+## Case 1 is difficult. We know that `automake' sets one of
+## CONFIG_FILES or CONFIG_HEADERS to empty. This heuristic works
+## only when AM_CONFIG_HEADER is set, however.
+
+if test -n "${CONFIG_FILES}" && test -n "${CONFIG_HEADERS}"; then
+ # Both CONFIG_FILES and CONFIG_HEADERS are non-empty ==> Case 1
+ CONFIG_OTHER=${CONFIG_OTHER:-gdk/gdkconfig.h}
+fi
+case "$CONFIG_OTHER" in
+*gdk/gdkconfig.h*)
+ echo creating gdk/gdkconfig.h
+ outfile=gdkconfig.h-tmp
+ cat > $outfile <<\_______EOF
+/* gdkconfig.h
+ *
+ * This is a generated file. Please modify `configure.in'
+ */
+
+#ifndef GDKCONFIG_H
+#define GDKCONFIG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+_______EOF
+
+ cat >>$outfile <<_______EOF
+$gdk_windowing
+_______EOF
+
+ cat >>$outfile <<_______EOF
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* GDKCONFIG_H */
+_______EOF
+
+
+ if cmp -s $outfile gdk/gdkconfig.h; then
+ echo gdk/gdkconfig.h is unchanged
+ rm -f $outfile
+ else
+ mv $outfile gdk/gdkconfig.h
+ fi ;;
+esac
+],[
+# Currently we always use X11 on those systems where we run configure...
+gdk_windowing='
+#define GDK_WINDOWING GDK_WINDOWING_X11'
+])
+
AC_OUTPUT([
gtk+.spec
Makefile
gdkincludedir = $(includedir)/gdk
+configincludedir = $(pkglibdir)/include
+
lib_LTLIBRARIES = libgdk.la
INCLUDES = \
@x_libs@ \
-lm
+configinclude_DATA = \
+ gdkconfig.h
+
+BUILT_SOURCES = stamp-gc-h #note: not gdkconfig.h
+gdkconfig.h: stamp-gc-h
+ @:
+stamp-gc-h: ../config.status
+ cd .. && CONFIG_FILES= CONFIG_HEADERS= CONFIG_OTHER=gdk/gdkconfig.h ./config.status
+ echo timestamp > stamp-gc-h
+
EXTRA_PROGRAMS = gxid
bin_PROGRAMS = @xinput_progs@
#include <glib.h>
+/* The system specific file gdkconfig.h contains such configuration
+ * settings that are needed not only when compiling GDK (or GTK)
+ * itself, but also occasionally when compiling programs that use GDK
+ * (or GTK). One such setting is what windowing API backend is in use.
+ */
+#include <gdkconfig.h>
+
+/* Windowing API alternatives. Note that these macros indicate just
+ * what windowing system is in use, not what operating system. It is
+ * possible to built GDK for X11 in a Win32 environment, for instance.
+ *
+ * gdkconfig.h defines GDK_WINDOWING as one of the following. In
+ * addition to the original X11 only the Win32 implementation exists
+ * yet.
+ */
+#define GDK_WINDOWING_X11 1 /* X11 */
+#define GDK_WINDOWING_WIN32 2 /* Win32 GDI */
+#define GDK_WINDOWING_BEOS 3 /* BeOS */
+#define GDK_WINDOWING_MACOS 4 /* MacOS */
+#define GDK_WINDOWING_GGI 5 /* Linux GGI */
+
+/* some common magic values */
#define GDK_NONE 0L
#define GDK_CURRENT_TIME 0L
#define GDK_PARENT_RELATIVE 1L
--- /dev/null
+/* Handcrafted for Win32 */
+
+#define GDK_WINDOWING GDK_WINDOWING_WIN32
fi
done
fi
- echo $includes @x_cflags@ $glib_cflags
+ echo -I@libdir@/gtk+/include $includes @x_cflags@ $glib_cflags
fi
if test "$echo_libs" = "yes"; then
* Debugging: compile with -DFONTSEL_DEBUG for lots of debugging output.
*/
-
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
-#include <X11/Xlib.h>
+#include "gdk/gdk.h"
#include "gdk/gdkx.h"
#include "gdk/gdkkeysyms.h"
GdkEventConfigure *event,
GtkFontSelectionDialog *fsd);
+#if GDK_WINDOWING == GDK_WINDOWING_WIN32
+static char *logfont_to_xlfd (const LOGFONT *lfp,
+ int size,
+ int res,
+ int avg_width);
+#endif
+
static GtkWindowClass *font_selection_parent_class = NULL;
static GtkNotebookClass *font_selection_dialog_parent_class = NULL;
GtkStyle *style;
gint text_height, new_height;
gchar *text;
+#if GDK_WINDOWING == GDK_WINDOWING_X11
XFontStruct *xfs;
-
+#endif
+
#ifdef FONTSEL_DEBUG
g_message("In update_preview\n");
#endif
gtk_entry_set_text(GTK_ENTRY(fontsel->preview_entry), PREVIEW_TEXT);
gtk_entry_set_position(GTK_ENTRY(fontsel->preview_entry), 0);
+#if GDK_WINDOWING == GDK_WINDOWING_X11
/* If this is a 2-byte font display a message to say it may not be
displayed properly. */
xfs = GDK_FONT_XFONT(fontsel->font);
if (xfs->min_byte1 != 0 || xfs->max_byte1 != 0)
gtk_label_set_text(GTK_LABEL(fontsel->message_label),
_("This is a 2-byte font and may not be displayed correctly."));
+#endif
}
static void
gtk_font_selection_show_font_info (GtkFontSelection *fontsel)
{
+#if GDK_WINDOWING == GDK_WINDOWING_X11
Atom font_atom, atom;
Bool status;
+#endif
char *name;
gchar *fontname;
gchar field_buffer[XLFD_MAX_FIELD_LEN];
gtk_clist_set_text(GTK_CLIST(fontsel->info_clist), i, 1,
field ? field : "");
}
-
+#if GDK_WINDOWING == GDK_WINDOWING_X11
if (fontsel->font)
{
font_atom = XInternAtom(GDK_DISPLAY(), "FONT", True);
}
}
}
+#elif GDK_WINDOWING == GDK_WINDOWING_WIN32
+ if (fontsel->font)
+ {
+ LOGFONT logfont;
+
+ if (GetObject (GDK_FONT_XFONT (fontsel->font),
+ sizeof (LOGFONT), &logfont) > 0)
+ {
+ name = logfont_to_xlfd (&logfont, logfont.lfHeight, -1, 0);
+ gtk_entry_set_text (GTK_ENTRY(fontsel->actual_font_name),name);
+ for (i = 0; i < GTK_XLFD_NUM_FIELDS; i++)
+ {
+ field = gtk_font_selection_get_xlfd_field (name, i,
+ field_buffer);
+ if (i == XLFD_SLANT)
+ field = gtk_font_selection_expand_slant_code(field);
+ else if (i == XLFD_SPACING)
+ field = gtk_font_selection_expand_spacing_code(field);
+ gtk_clist_set_text(GTK_CLIST(fontsel->info_clist), i, 2,
+ field ? field : "");
+ }
+ shown_actual_fields = TRUE;
+ g_free (name);
+ }
+ }
+
+#endif
if (!shown_actual_fields)
{
gtk_entry_set_text(GTK_ENTRY(fontsel->actual_font_name), "");
}
+#if GDK_WINDOWING == GDK_WINDOWING_WIN32
+
+static gint num_fonts;
+static gint font_names_size;
+static gchar **xfontnames;
+static HDC hdc;
+
+static char *
+logfont_to_xlfd (const LOGFONT *lfp,
+ int size,
+ int res,
+ int avg_width)
+{
+ const gchar *weight;
+ const gchar *registry, *encoding;
+ int point_size;
+ static int logpixelsy = 0;
+ gchar facename[LF_FACESIZE*3];
+ gchar *p, *q;
+
+ if (logpixelsy == 0)
+ {
+ HDC hdc = GetDC (NULL);
+ logpixelsy = GetDeviceCaps (hdc, LOGPIXELSY);
+ ReleaseDC (NULL, hdc);
+ }
+
+ if (lfp->lfWeight >= FW_HEAVY)
+ weight = "heavy";
+ else if (lfp->lfWeight >= FW_EXTRABOLD)
+ weight = "extrabold";
+ else if (lfp->lfWeight >= FW_BOLD)
+ weight = "bold";
+ else if (lfp->lfWeight >= FW_DEMIBOLD)
+ weight = "demibold";
+ else if (lfp->lfWeight >= FW_MEDIUM)
+ weight = "medium";
+ else if (lfp->lfWeight >= FW_NORMAL)
+ weight = "normal";
+ else if (lfp->lfWeight >= FW_LIGHT)
+ weight = "light";
+ else if (lfp->lfWeight >= FW_EXTRALIGHT)
+ weight = "extralight";
+ else if (lfp->lfWeight >= FW_THIN)
+ weight = "thin";
+ else
+ weight = "regular";
+
+ if (lfp->lfCharSet == ANSI_CHARSET)
+ {
+ registry = "iso8859";
+ encoding = "1";
+ }
+ else
+ {
+ registry = "windows";
+ if (lfp->lfCharSet == DEFAULT_CHARSET)
+ encoding = "default";
+ else if (lfp->lfCharSet == SYMBOL_CHARSET)
+ encoding = "symbol";
+ else if (lfp->lfCharSet == SHIFTJIS_CHARSET)
+ encoding = "shiftjis";
+ else if (lfp->lfCharSet == GB2312_CHARSET)
+ encoding = "gb2312";
+ else if (lfp->lfCharSet == HANGEUL_CHARSET)
+ encoding = "hangeul";
+ else if (lfp->lfCharSet == CHINESEBIG5_CHARSET)
+ encoding = "chinesebig5";
+ else if (lfp->lfCharSet == OEM_CHARSET)
+ encoding = "oem";
+ else if (lfp->lfCharSet == JOHAB_CHARSET)
+ encoding = "johab";
+ else if (lfp->lfCharSet == HEBREW_CHARSET)
+ encoding = "hebrew";
+ else if (lfp->lfCharSet == ARABIC_CHARSET)
+ encoding = "arabic";
+ else if (lfp->lfCharSet == GREEK_CHARSET)
+ encoding = "greek";
+ else if (lfp->lfCharSet == TURKISH_CHARSET)
+ encoding = "turkish";
+ else if (lfp->lfCharSet == THAI_CHARSET)
+ encoding = "thai";
+ else if (lfp->lfCharSet == EASTEUROPE_CHARSET)
+ encoding = "easteurope";
+ else if (lfp->lfCharSet == RUSSIAN_CHARSET)
+ encoding = "russian";
+ else if (lfp->lfCharSet == MAC_CHARSET)
+ encoding = "mac";
+ else if (lfp->lfCharSet == BALTIC_CHARSET)
+ encoding = "baltic";
+ else
+ encoding = "unknown";
+ }
+
+ point_size = (int) (((double) size/logpixelsy) * 720.);
+
+ if (res == -1)
+ res = logpixelsy;
+
+ /* Replace illegal characters with hex escapes. */
+ p = facename;
+ q = lfp->lfFaceName;
+ while (*q)
+ {
+ if (*q == '-' || *q == '*' || *q == '?' || *q == '%')
+ p += sprintf (p, "%%%.02x", *q);
+ else
+ *p++ = *q;
+ q++;
+ }
+ *p = '\0';
+
+ return g_strdup_printf
+ ("-%s-%s-%s-%s-%s-%s-%d-%d-%d-%d-%s-%d-%s-%s",
+ "unknown",
+ facename,
+ weight,
+ (lfp->lfItalic ?
+ ((lfp->lfPitchAndFamily & 0xF0) == FF_ROMAN
+ || (lfp->lfPitchAndFamily & 0xF0) == FF_SCRIPT ?
+ "i" : "o") : "r"),
+ "normal",
+ "",
+ size,
+ point_size,
+ res,
+ res,
+ ((lfp->lfPitchAndFamily & 0x03) == FIXED_PITCH ? "m" : "p"),
+ avg_width,
+ registry, encoding);
+}
+
+int CALLBACK
+InnerEnumFontFamExProc (const LOGFONT *lfp,
+ const TEXTMETRIC *metrics,
+ DWORD fontType,
+ LPARAM lParam)
+{
+ int size;
+
+ if (fontType == TRUETYPE_FONTTYPE)
+ {
+ size = 0;
+ }
+ else
+ {
+ size = lfp->lfHeight;
+ }
+
+ num_fonts++;
+ if (num_fonts == font_names_size)
+ {
+ font_names_size *= 2;
+ xfontnames = g_realloc (xfontnames, font_names_size * sizeof (gchar *));
+ }
+ xfontnames[num_fonts-1] =
+ logfont_to_xlfd (lfp, size, 0, 0);
+ return 1;
+}
+
+int CALLBACK
+EnumFontFamExProc (const LOGFONT *lfp,
+ const TEXTMETRIC *metrics,
+ DWORD fontType,
+ LPARAM lParam)
+{
+ if (fontType == TRUETYPE_FONTTYPE)
+ {
+ LOGFONT lf = *lfp;
+ lf.lfPitchAndFamily = 0;
+ EnumFontFamiliesEx (hdc, &lf, InnerEnumFontFamExProc, 0, 0);
+ }
+ else
+ InnerEnumFontFamExProc (lfp, metrics, fontType, lParam);
+ return 1;
+}
+
+#endif
+
/*****************************************************************************
* These functions all deal with creating the main class arrays containing
* the data about all available fonts.
static void
gtk_font_selection_get_fonts (void)
{
+#if GDK_WINDOWING == GDK_WINDOWING_X11
gchar **xfontnames;
+ gint num_fonts;
+#elif GDK_WINDOWING == GDK_WINDOWING_WIN32
+ LOGFONT logfont;
+#endif
GSList **fontnames;
gchar *fontname;
GSList * temp_list;
- gint num_fonts;
gint i, prop, style, size;
gint npixel_sizes = 0, npoint_sizes = 0;
FontInfo *font;
guint16 *pixel_sizes, *point_sizes, *tmp_sizes;
fontsel_info = g_new (GtkFontSelInfo, 1);
-
+
+#if GDK_WINDOWING == GDK_WINDOWING_X11
/* Get a maximum of MAX_FONTS fontnames from the X server.
Use "-*" as the pattern rather than "-*-*-*-*-*-*-*-*-*-*-*-*-*-*" since
the latter may result in fonts being returned which don't actually exist.
if (num_fonts == MAX_FONTS)
g_warning(_("MAX_FONTS exceeded. Some fonts may be missing."));
+#elif GDK_WINDOWING == GDK_WINDOWING_WIN32
+ num_fonts = 0;
+ hdc = GetDC (NULL);
+ font_names_size = 100;
+ xfontnames = g_new (gchar *, font_names_size);
+ logfont.lfCharSet = DEFAULT_CHARSET;
+ logfont.lfFaceName[0] = '\0';
+ logfont.lfPitchAndFamily = 0;
+ EnumFontFamiliesEx (hdc, &logfont, EnumFontFamExProc, 0, 0);
+ ReleaseDC (NULL, hdc);
+#endif
+
/* The maximum size of all these tables is the number of font names
returned. We realloc them later when we know exactly how many
unique entries there are. */
fontsel_info->point_sizes = g_realloc(fontsel_info->point_sizes,
sizeof(guint16) * npoint_sizes);
g_free(fontnames);
+
+#if GDK_WINDOWING == GDK_WINDOWING_X11
XFreeFontNames (xfontnames);
-
+#elif GDK_WINDOWING == GDK_WINDOWING_WIN32
+ for (i = 0; i < num_fonts; i++)
+ g_free (xfontnames[i]);
+ g_free (xfontnames);
+#endif
/* Debugging Output */
/* This outputs all FontInfos. */
{
gchar buffer[16];
gchar *pixel_size = "*", *point_size = "*", *fontname;
- gint length;
if (size <= 0)
return NULL;
else
point_size = buffer;
- /* Note: be careful here - don't overrun the allocated memory. */
- length = strlen(foundry) + strlen(family) + strlen(weight) + strlen(slant)
- + strlen(set_width) + strlen(pixel_size) + strlen(point_size)
- + strlen(spacing) + strlen(charset)
- + 1 + 1 + 1 + 1 + 1 + 3 + 1 + 5 + 3
- + 1 /* for the terminating '\0'. */;
-
- fontname = g_new(gchar, length);
- /* **NOTE**: If you change this string please change length above! */
- sprintf(fontname, "-%s-%s-%s-%s-%s-*-%s-%s-*-*-%s-*-%s",
- foundry, family, weight, slant, set_width, pixel_size,
- point_size, spacing, charset);
+ fontname = g_strdup_printf ("-%s-%s-%s-%s-%s-*-%s-%s-*-*-%s-*-%s",
+ foundry, family, weight, slant,
+ set_width, pixel_size, point_size,
+ spacing, charset);
return fontname;
}