diff options
author | Tor Lillqvist <tml@iki.fi> | 2002-09-19 23:27:10 +0000 |
---|---|---|
committer | Tor Lillqvist <tml@src.gnome.org> | 2002-09-19 23:27:10 +0000 |
commit | d8a49627083b777ad66c5923ed3d634260b5dfcf (patch) | |
tree | d97eaa57ce65508a8ed799f7de0d5451ade643e2 /gdk/win32/gdkfont-win32.c | |
parent | 944334da7f0d71f4879362d80be91b4a58c1f416 (diff) | |
download | gdk-pixbuf-d8a49627083b777ad66c5923ed3d634260b5dfcf.tar.gz |
Delete leftover declarations of the obsolete Win32-only functions
2002-09-20 Tor Lillqvist <tml@iki.fi>
* gdk/gdkfont.h: Delete leftover declarations of the obsolete
Win32-only functions gdk_font_full_name_get() and
gdk_font_full_name_free().
* gdk/gdk.def: Delete from here, too.
* gdk/win32/gdkfont-win32.c (logfont_to_xlfd,
gdk_font_full_name_get, gdk_font_full_name_free): Delete
implementation, and helper functions.
(pattern_match, InnerEnumFontFamExProc, EnumFontFamExProc,
gdk_font_list_new, gdk_font_list_free): Delete unused functions.
(gdk_text_width, gdk_text_width_wc) Instead of code duplication,
let gdk_text_extents() and gdk_text_extents_wc() do the job.
* gdk/win32/gdkgc-win32.c (gdk_win32_gc_values_to_win32values):
Don't use the above removed functions in debugging output.
* gdk/win32/gdkdisplay-win32.c
* gdk/win32/gdkmain-win32.c
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkselection-win32.c
* gdk/win32/gdkinput-win32.h
* gdk/win32/gdkinput.c: Make it compile again, pass a GdkDisplay in
a couple of places.
Diffstat (limited to 'gdk/win32/gdkfont-win32.c')
-rw-r--r-- | gdk/win32/gdkfont-win32.c | 367 |
1 files changed, 6 insertions, 361 deletions
diff --git a/gdk/win32/gdkfont-win32.c b/gdk/win32/gdkfont-win32.c index a831635eb..eba638b12 100644 --- a/gdk/win32/gdkfont-win32.c +++ b/gdk/win32/gdkfont-win32.c @@ -124,332 +124,6 @@ charset_name (DWORD charset) return "unknown"; } -static gint num_fonts; -static gint font_names_size; -static gchar **xfontnames; - -static gchar * -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*5]; - gchar *utf8_facename; - gchar *p; - const gchar *q; - - if (logpixelsy == 0) - { - logpixelsy = GetDeviceCaps (gdk_display_hdc, LOGPIXELSY); - } - - if (lfp->lfWeight >= FW_HEAVY) - weight = "heavy"; - else if (lfp->lfWeight >= FW_EXTRABOLD) - weight = "extrabold"; - else if (lfp->lfWeight >= FW_BOLD) - weight = "bold"; -#ifdef FW_DEMIBOLD - else if (lfp->lfWeight >= FW_DEMIBOLD) - weight = "demibold"; -#endif - 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"; - - switch (lfp->lfCharSet) - { - case ANSI_CHARSET: - registry = "iso8859"; - encoding = "1"; - break; - case SHIFTJIS_CHARSET: - registry = "jisx0208.1983"; - encoding = "0"; - break; - case HANGEUL_CHARSET: - registry = "ksc5601.1987"; - encoding = "0"; - break; - case GB2312_CHARSET: - registry = "gb2312.1980"; - encoding = "0"; - break; - case CHINESEBIG5_CHARSET: - registry = "big5"; - encoding = "0"; - break; - case GREEK_CHARSET: - registry = "iso8859"; - encoding = "7"; - break; - case TURKISH_CHARSET: - registry = "iso8859"; - encoding = "9"; - break; -#if 0 /* Not a good idea, I think, to use ISO8859-8 and -6 for the Windows - * hebrew and arabic codepages, they differ too much. - */ - case HEBREW_CHARSET: - registry = "iso8859"; - encoding = "8"; - break; - case ARABIC_CHARSET: - registry = "iso8859"; - encoding = "6"; - break; -#endif - default: - registry = "microsoft"; - encoding = charset_name (lfp->lfCharSet); - } - - point_size = (int) (((double) size/logpixelsy) * 720.); - - if (res == -1) - res = logpixelsy; - - /* Convert the facename Windows fives us from the locale-dependent - * codepage to UTF-8. - */ - utf8_facename = g_filename_to_utf8 (lfp->lfFaceName, -1, NULL, NULL, NULL); - - /* Replace characters illegal in an XLFD with hex escapes. */ - p = facename; - q = utf8_facename; - while (*q) - { - if (*q == '-' || *q == '*' || *q == '?' || *q == '%') - p += sprintf (p, "%%%.02x", *q); - else - *p++ = *q; - q++; - } - *p = '\0'; - g_free (utf8_facename); - - 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); -} - -gchar * -gdk_font_full_name_get (GdkFont *font) -{ - GdkFontPrivateWin32 *private; - GdkWin32SingleFont *singlefont; - GSList *list; - GString *string; - gchar *result; - gchar *xlfd; - LOGFONT logfont; - - g_return_val_if_fail (font != NULL, NULL); - - private = (GdkFontPrivateWin32 *) font; - - list = private->fonts; - string = g_string_new (""); - - while (list) - { - singlefont = (GdkWin32SingleFont *) list->data; - - if (GetObject (singlefont->hfont, sizeof (LOGFONT), &logfont) == 0) - { - WIN32_GDI_FAILED ("GetObject"); - return NULL; - } - - xlfd = logfont_to_xlfd (&logfont, logfont.lfHeight, -1, 0); - string = g_string_append (string, xlfd); - g_free (xlfd); - list = list->next; - if (list) - string = g_string_append_c (string, ','); - } - result = string->str; - g_string_free (string, FALSE); - return result; -} - -void -gdk_font_full_name_free (gchar *name) -{ - g_free (name); -} - -static gboolean -pattern_match (const gchar *pattern, - const gchar *string) -{ - const gchar *p = pattern, *n = string; - gchar c, c1; - - /* Common case first */ - if ((pattern[0] == '*' - && pattern[1] == '\0') - || (pattern[0] == '-' - && pattern[1] == '*' - && pattern[2] == '\0')) - return TRUE; - - while ((c = *p++) != '\0') - { - c = tolower (c); - - switch (c) - { - case '?': - if (*n == '\0') - return FALSE; - break; - - case '*': - for (c = *p++; c == '?' || c == '*'; c = *p++, ++n) - if (c == '?' && *n == '\0') - return FALSE; - - if (c == '\0') - return TRUE; - - c1 = tolower (c); - for (--p; *n != '\0'; ++n) - if (tolower (*n) == c1 - && pattern_match (p, n)) - return TRUE; - return FALSE; - - default: - if (c != tolower (*n)) - return FALSE; - } - - ++n; - } - - if (*n == '\0') - return TRUE; - - return FALSE; -} - -static int CALLBACK -InnerEnumFontFamExProc (const LOGFONT *lfp, - const TEXTMETRIC *metrics, - DWORD fontType, - LPARAM lParam) -{ - int size; - gchar *xlfd; - - if (fontType == TRUETYPE_FONTTYPE) - { - size = 0; - } - else - { - size = lfp->lfHeight; - } - - xlfd = logfont_to_xlfd (lfp, size, 0, 0); - - if (!pattern_match ((gchar *) lParam, xlfd)) - { - g_free (xlfd); - return 1; - } - - 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] = xlfd; - - return 1; -} - -static int CALLBACK -EnumFontFamExProc (const LOGFONT *lfp, - const TEXTMETRIC *metrics, - DWORD fontType, - LPARAM lParam) -{ - if (fontType == TRUETYPE_FONTTYPE) - { - LOGFONT lf; - - lf = *lfp; - - EnumFontFamiliesEx (gdk_display_hdc, &lf, InnerEnumFontFamExProc, lParam, 0); - } - else - InnerEnumFontFamExProc (lfp, metrics, fontType, lParam); - - return 1; -} - -gchar ** -gdk_font_list_new (const gchar *font_pattern, - gint *n_returned) -{ - LOGFONT logfont; - gchar **result; - - num_fonts = 0; - font_names_size = 100; - xfontnames = g_new (gchar *, font_names_size); - memset (&logfont, 0, sizeof (logfont)); - logfont.lfCharSet = DEFAULT_CHARSET; - EnumFontFamiliesEx (gdk_display_hdc, &logfont, EnumFontFamExProc, - (LPARAM) font_pattern, 0); - - result = g_new (gchar *, num_fonts + 1); - memmove (result, xfontnames, num_fonts * sizeof (gchar *)); - result[num_fonts] = NULL; - g_free (xfontnames); - - *n_returned = num_fonts; - return result; -} - -void -gdk_font_list_free (gchar **font_list) -{ - g_strfreev (font_list); -} - /* This table classifies Unicode characters according to the Microsoft * Unicode subset numbering. This is based on the table in "Developing * International Software for Windows 95 and Windows NT". This is almost, @@ -1929,14 +1603,11 @@ gdk_text_width (GdkFont *font, const gchar *text, gint text_length) { - gdk_text_size_arg arg; - - arg.total.cx = arg.total.cy = 0; + gint width = -1; - if (!gdk_text_size (font, text, text_length, &arg)) - return -1; + gdk_text_extents (font, text, text_length, NULL, NULL, &width, NULL, NULL); - return arg.total.cx; + return width; } gint @@ -1944,36 +1615,10 @@ gdk_text_width_wc (GdkFont *font, const GdkWChar *text, gint text_length) { - gdk_text_size_arg arg; - wchar_t *wcstr; - gint i; - - g_return_val_if_fail (font != NULL, -1); - g_return_val_if_fail (text != NULL, -1); - - if (text_length == 0) - return 0; - - g_assert (font->type == GDK_FONT_FONT || font->type == GDK_FONT_FONTSET); - - if (sizeof (wchar_t) != sizeof (GdkWChar)) - { - wcstr = g_new (wchar_t, text_length); - for (i = 0; i < text_length; i++) - wcstr[i] = text[i]; - } - else - wcstr = (wchar_t *) text; - - arg.total.cx = arg.total.cy = 0; - - _gdk_wchar_text_handle (font, wcstr, text_length, - gdk_text_size_handler, &arg); - - if (sizeof (wchar_t) != sizeof (GdkWChar)) - g_free (wcstr); + gint width = -1; - return arg.total.cx; + gdk_text_extents_wc (font, text, text_length, NULL, NULL, &width, NULL, NULL); + return width; } void |