1999-03-05 19:53:56 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
|
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
1999-10-02 22:42:58 +00:00
|
|
|
#include "gdkfont.h"
|
1999-03-05 19:53:56 +00:00
|
|
|
#include "gdkprivate.h"
|
|
|
|
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
static GHashTable *font_name_hash = NULL;
|
|
|
|
static GHashTable *fontset_name_hash = NULL;
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_font_hash_insert (GdkFontType type, GdkFont *font, const gchar *font_name)
|
|
|
|
{
|
|
|
|
GdkFontPrivate *private = (GdkFontPrivate *)font;
|
|
|
|
GHashTable **hashp = (type == GDK_FONT_FONT) ?
|
|
|
|
&font_name_hash : &fontset_name_hash;
|
|
|
|
|
|
|
|
if (!*hashp)
|
|
|
|
*hashp = g_hash_table_new (g_str_hash, g_str_equal);
|
|
|
|
|
|
|
|
private->names = g_slist_prepend (private->names, g_strdup (font_name));
|
|
|
|
g_hash_table_insert (*hashp, private->names->data, font);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_font_hash_remove (GdkFontType type, GdkFont *font)
|
|
|
|
{
|
|
|
|
GdkFontPrivate *private = (GdkFontPrivate *)font;
|
|
|
|
GSList *tmp_list;
|
|
|
|
GHashTable *hash = (type == GDK_FONT_FONT) ?
|
|
|
|
font_name_hash : fontset_name_hash;
|
|
|
|
|
|
|
|
tmp_list = private->names;
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
g_hash_table_remove (hash, tmp_list->data);
|
|
|
|
g_free (tmp_list->data);
|
|
|
|
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_slist_free (private->names);
|
|
|
|
private->names = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkFont *
|
|
|
|
gdk_font_hash_lookup (GdkFontType type, const gchar *font_name)
|
|
|
|
{
|
|
|
|
GdkFont *result;
|
|
|
|
GHashTable *hash = (type == GDK_FONT_FONT) ?
|
|
|
|
font_name_hash : fontset_name_hash;
|
|
|
|
|
|
|
|
if (!hash)
|
|
|
|
return NULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = g_hash_table_lookup (hash, font_name);
|
|
|
|
if (result)
|
|
|
|
gdk_font_ref (result);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-20 22:58:37 +00:00
|
|
|
static const char *
|
|
|
|
charset_name (DWORD charset)
|
|
|
|
{
|
|
|
|
switch (charset)
|
|
|
|
{
|
|
|
|
case ANSI_CHARSET: return "ANSI";
|
|
|
|
case DEFAULT_CHARSET: return "DEFAULT";
|
|
|
|
case SYMBOL_CHARSET: return "SYMBOL";
|
|
|
|
case SHIFTJIS_CHARSET: return "SHIFTJIS";
|
|
|
|
case HANGEUL_CHARSET: return "HANGEUL";
|
|
|
|
case GB2312_CHARSET: return "GB2312";
|
|
|
|
case CHINESEBIG5_CHARSET: return "CHINESEBIG5";
|
|
|
|
case JOHAB_CHARSET: return "JOHAB";
|
|
|
|
case HEBREW_CHARSET: return "HEBREW";
|
|
|
|
case ARABIC_CHARSET: return "ARABIC";
|
|
|
|
case GREEK_CHARSET: return "GREEK";
|
|
|
|
case TURKISH_CHARSET: return "TURKISH";
|
|
|
|
case VIETNAMESE_CHARSET: return "VIETNAMESE";
|
|
|
|
case THAI_CHARSET: return "THAI";
|
|
|
|
case EASTEUROPE_CHARSET: return "EASTEUROPE";
|
|
|
|
case RUSSIAN_CHARSET: return "RUSSIAN";
|
|
|
|
case MAC_CHARSET: return "MAC";
|
|
|
|
case BALTIC_CHARSET: return "BALTIC";
|
|
|
|
}
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
|
1999-03-05 19:53:56 +00:00
|
|
|
GdkFont*
|
|
|
|
gdk_font_load (const gchar *font_name)
|
|
|
|
{
|
|
|
|
GdkFont *font;
|
|
|
|
GdkFontPrivate *private;
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
HFONT hfont;
|
1999-03-05 19:53:56 +00:00
|
|
|
LOGFONT logfont;
|
|
|
|
HGDIOBJ oldfont;
|
|
|
|
TEXTMETRIC textmetric;
|
1999-10-20 22:58:37 +00:00
|
|
|
CHARSETINFO csi;
|
1999-03-05 19:53:56 +00:00
|
|
|
HANDLE *f;
|
|
|
|
DWORD fdwItalic, fdwUnderline, fdwStrikeOut, fdwCharSet,
|
|
|
|
fdwOutputPrecision, fdwClipPrecision, fdwQuality, fdwPitchAndFamily;
|
|
|
|
const char *lpszFace;
|
|
|
|
|
|
|
|
int numfields, n1, n2, tries;
|
|
|
|
char foundry[32], family[100], weight[32], slant[32], set_width[32],
|
|
|
|
spacing[32], registry[32], encoding[32];
|
|
|
|
char pixel_size[10], point_size[10], res_x[10], res_y[10], avg_width[10];
|
|
|
|
int c;
|
|
|
|
char *p;
|
|
|
|
int nHeight, nWidth, nEscapement, nOrientation, fnWeight;
|
|
|
|
int logpixelsy;
|
|
|
|
|
1999-03-12 20:12:58 +00:00
|
|
|
g_return_val_if_fail (font_name != NULL, NULL);
|
|
|
|
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("gdk_font_load: %s\n", font_name));
|
|
|
|
|
|
|
|
font = gdk_font_hash_lookup (GDK_FONT_FONT, font_name);
|
|
|
|
if (font)
|
|
|
|
return font;
|
1999-03-05 19:53:56 +00:00
|
|
|
|
|
|
|
numfields = sscanf (font_name,
|
|
|
|
"-%30[^-]-%100[^-]-%30[^-]-%30[^-]-%30[^-]-%n",
|
|
|
|
foundry,
|
|
|
|
family,
|
|
|
|
weight,
|
|
|
|
slant,
|
|
|
|
set_width,
|
|
|
|
&n1);
|
|
|
|
if (numfields == 0)
|
|
|
|
{
|
|
|
|
/* Probably a plain Windows font name */
|
|
|
|
nHeight = 0;
|
|
|
|
nWidth = 0;
|
|
|
|
nEscapement = 0;
|
|
|
|
nOrientation = 0;
|
|
|
|
fnWeight = FW_DONTCARE;
|
|
|
|
fdwItalic = FALSE;
|
|
|
|
fdwUnderline = FALSE;
|
|
|
|
fdwStrikeOut = FALSE;
|
|
|
|
fdwCharSet = ANSI_CHARSET;
|
|
|
|
fdwOutputPrecision = OUT_TT_PRECIS;
|
|
|
|
fdwClipPrecision = CLIP_DEFAULT_PRECIS;
|
|
|
|
fdwQuality = PROOF_QUALITY;
|
|
|
|
fdwPitchAndFamily = DEFAULT_PITCH;
|
|
|
|
lpszFace = font_name;
|
|
|
|
}
|
|
|
|
else if (numfields != 5)
|
|
|
|
{
|
|
|
|
g_warning ("gdk_font_load: font name %s illegal", font_name);
|
|
|
|
g_free (font);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* It must be a XLFD name */
|
|
|
|
|
|
|
|
/* Check for hex escapes in the font family,
|
|
|
|
* put in there by gtkfontsel.
|
|
|
|
*/
|
|
|
|
p = family;
|
|
|
|
while (*p)
|
|
|
|
{
|
|
|
|
if (*p == '%' && isxdigit (p[1]) && isxdigit (p[2]))
|
|
|
|
{
|
|
|
|
sscanf (p+1, "%2x", &c);
|
|
|
|
*p = c;
|
|
|
|
strcpy (p+1, p+3);
|
|
|
|
}
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Skip add_style which often is empty in the requested font name */
|
|
|
|
while (font_name[n1] && font_name[n1] != '-')
|
|
|
|
n1++;
|
|
|
|
numfields++;
|
|
|
|
|
|
|
|
numfields += sscanf (font_name + n1,
|
|
|
|
"-%8[^-]-%8[^-]-%8[^-]-%8[^-]-%30[^-]-%8[^-]-%30[^-]-%30[^-]%n",
|
|
|
|
pixel_size,
|
|
|
|
point_size,
|
|
|
|
res_x,
|
|
|
|
res_y,
|
|
|
|
spacing,
|
|
|
|
avg_width,
|
|
|
|
registry,
|
|
|
|
encoding,
|
|
|
|
&n2);
|
|
|
|
|
|
|
|
if (numfields != 14 || font_name[n1 + n2] != '\0')
|
|
|
|
{
|
|
|
|
g_warning ("gdk_font_load: font name %s illegal", font_name);
|
|
|
|
g_free (font);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
logpixelsy = GetDeviceCaps (gdk_DC, LOGPIXELSY);
|
|
|
|
|
|
|
|
if (strcmp (pixel_size, "*") == 0)
|
|
|
|
if (strcmp (point_size, "*") == 0)
|
|
|
|
nHeight = 0;
|
|
|
|
else
|
|
|
|
nHeight = (int) (((double) atoi (point_size))/720.*logpixelsy);
|
|
|
|
else
|
|
|
|
nHeight = atoi (pixel_size);
|
|
|
|
|
|
|
|
nWidth = 0;
|
|
|
|
nEscapement = 0;
|
|
|
|
nOrientation = 0;
|
|
|
|
|
|
|
|
if (g_strcasecmp (weight, "thin") == 0)
|
|
|
|
fnWeight = FW_THIN;
|
|
|
|
else if (g_strcasecmp (weight, "extralight") == 0)
|
|
|
|
fnWeight = FW_EXTRALIGHT;
|
|
|
|
else if (g_strcasecmp (weight, "ultralight") == 0)
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
#ifdef FW_ULTRALIGHT
|
1999-03-05 19:53:56 +00:00
|
|
|
fnWeight = FW_ULTRALIGHT;
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
#else
|
|
|
|
fnWeight = FW_EXTRALIGHT; /* In fact, FW_ULTRALIGHT really is
|
|
|
|
* defined as FW_EXTRALIGHT anyway.
|
|
|
|
*/
|
1999-07-21 19:27:25 +00:00
|
|
|
#endif
|
1999-03-05 19:53:56 +00:00
|
|
|
else if (g_strcasecmp (weight, "light") == 0)
|
|
|
|
fnWeight = FW_LIGHT;
|
|
|
|
else if (g_strcasecmp (weight, "normal") == 0)
|
|
|
|
fnWeight = FW_NORMAL;
|
|
|
|
else if (g_strcasecmp (weight, "regular") == 0)
|
|
|
|
fnWeight = FW_REGULAR;
|
|
|
|
else if (g_strcasecmp (weight, "medium") == 0)
|
|
|
|
fnWeight = FW_MEDIUM;
|
|
|
|
else if (g_strcasecmp (weight, "semibold") == 0)
|
|
|
|
fnWeight = FW_SEMIBOLD;
|
|
|
|
else if (g_strcasecmp (weight, "demibold") == 0)
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
#ifdef FW_DEMIBOLD
|
1999-03-05 19:53:56 +00:00
|
|
|
fnWeight = FW_DEMIBOLD;
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
#else
|
|
|
|
fnWeight = FW_SEMIBOLD; /* As above */
|
1999-07-21 19:27:25 +00:00
|
|
|
#endif
|
1999-03-05 19:53:56 +00:00
|
|
|
else if (g_strcasecmp (weight, "bold") == 0)
|
|
|
|
fnWeight = FW_BOLD;
|
|
|
|
else if (g_strcasecmp (weight, "extrabold") == 0)
|
|
|
|
fnWeight = FW_EXTRABOLD;
|
|
|
|
else if (g_strcasecmp (weight, "ultrabold") == 0)
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
#ifdef FW_ULTRABOLD
|
1999-03-05 19:53:56 +00:00
|
|
|
fnWeight = FW_ULTRABOLD;
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
#else
|
|
|
|
fnWeight = FW_EXTRABOLD; /* As above */
|
1999-07-21 19:27:25 +00:00
|
|
|
#endif
|
1999-03-05 19:53:56 +00:00
|
|
|
else if (g_strcasecmp (weight, "heavy") == 0)
|
|
|
|
fnWeight = FW_HEAVY;
|
|
|
|
else if (g_strcasecmp (weight, "black") == 0)
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
#ifdef FW_BLACK
|
1999-03-05 19:53:56 +00:00
|
|
|
fnWeight = FW_BLACK;
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
#else
|
|
|
|
fnWeight = FW_HEAVY; /* As above */
|
1999-07-21 19:27:25 +00:00
|
|
|
#endif
|
1999-03-05 19:53:56 +00:00
|
|
|
else
|
|
|
|
fnWeight = FW_DONTCARE;
|
|
|
|
|
|
|
|
if (g_strcasecmp (slant, "italic") == 0
|
|
|
|
|| g_strcasecmp (slant, "oblique") == 0
|
|
|
|
|| g_strcasecmp (slant, "i") == 0
|
|
|
|
|| g_strcasecmp (slant, "o") == 0)
|
|
|
|
fdwItalic = TRUE;
|
|
|
|
else
|
|
|
|
fdwItalic = FALSE;
|
|
|
|
fdwUnderline = FALSE;
|
|
|
|
fdwStrikeOut = FALSE;
|
|
|
|
if (g_strcasecmp (registry, "iso8859") == 0)
|
|
|
|
if (strcmp (encoding, "1") == 0)
|
|
|
|
fdwCharSet = ANSI_CHARSET;
|
|
|
|
else
|
|
|
|
fdwCharSet = ANSI_CHARSET; /* XXX ??? */
|
|
|
|
else if (g_strcasecmp (registry, "windows") == 0)
|
|
|
|
if (g_strcasecmp (encoding, "symbol") == 0)
|
|
|
|
fdwCharSet = SYMBOL_CHARSET;
|
|
|
|
else if (g_strcasecmp (encoding, "shiftjis") == 0)
|
|
|
|
fdwCharSet = SHIFTJIS_CHARSET;
|
|
|
|
else if (g_strcasecmp (encoding, "gb2312") == 0)
|
|
|
|
fdwCharSet = GB2312_CHARSET;
|
|
|
|
else if (g_strcasecmp (encoding, "hangeul") == 0)
|
|
|
|
fdwCharSet = HANGEUL_CHARSET;
|
|
|
|
else if (g_strcasecmp (encoding, "chinesebig5") == 0)
|
|
|
|
fdwCharSet = CHINESEBIG5_CHARSET;
|
|
|
|
else if (g_strcasecmp (encoding, "johab") == 0)
|
|
|
|
fdwCharSet = JOHAB_CHARSET;
|
|
|
|
else if (g_strcasecmp (encoding, "hebrew") == 0)
|
|
|
|
fdwCharSet = HEBREW_CHARSET;
|
|
|
|
else if (g_strcasecmp (encoding, "arabic") == 0)
|
|
|
|
fdwCharSet = ARABIC_CHARSET;
|
|
|
|
else if (g_strcasecmp (encoding, "greek") == 0)
|
|
|
|
fdwCharSet = GREEK_CHARSET;
|
|
|
|
else if (g_strcasecmp (encoding, "turkish") == 0)
|
|
|
|
fdwCharSet = TURKISH_CHARSET;
|
|
|
|
else if (g_strcasecmp (encoding, "easteurope") == 0)
|
|
|
|
fdwCharSet = EASTEUROPE_CHARSET;
|
|
|
|
else if (g_strcasecmp (encoding, "russian") == 0)
|
|
|
|
fdwCharSet = RUSSIAN_CHARSET;
|
|
|
|
else if (g_strcasecmp (encoding, "mac") == 0)
|
|
|
|
fdwCharSet = MAC_CHARSET;
|
|
|
|
else if (g_strcasecmp (encoding, "baltic") == 0)
|
|
|
|
fdwCharSet = BALTIC_CHARSET;
|
|
|
|
else
|
|
|
|
fdwCharSet = ANSI_CHARSET; /* XXX ??? */
|
|
|
|
else
|
|
|
|
fdwCharSet = ANSI_CHARSET; /* XXX ??? */
|
|
|
|
fdwOutputPrecision = OUT_TT_PRECIS;
|
|
|
|
fdwClipPrecision = CLIP_DEFAULT_PRECIS;
|
|
|
|
fdwQuality = PROOF_QUALITY;
|
|
|
|
if (g_strcasecmp (spacing, "m") == 0)
|
|
|
|
fdwPitchAndFamily = FIXED_PITCH;
|
|
|
|
else if (g_strcasecmp (spacing, "p") == 0)
|
|
|
|
fdwPitchAndFamily = VARIABLE_PITCH;
|
|
|
|
else
|
|
|
|
fdwPitchAndFamily = DEFAULT_PITCH;
|
|
|
|
lpszFace = family;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (tries = 0; ; tries++)
|
|
|
|
{
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("...trying CreateFont(%d,%d,%d,%d,"
|
|
|
|
"%d,%d,%d,%d,"
|
|
|
|
"%d,%d,%d,"
|
|
|
|
"%d,%#.02x,\"%s\")\n",
|
1999-03-05 19:53:56 +00:00
|
|
|
nHeight, nWidth, nEscapement, nOrientation,
|
|
|
|
fnWeight, fdwItalic, fdwUnderline, fdwStrikeOut,
|
|
|
|
fdwCharSet, fdwOutputPrecision, fdwClipPrecision,
|
|
|
|
fdwQuality, fdwPitchAndFamily, lpszFace));
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
if ((hfont =
|
1999-03-05 19:53:56 +00:00
|
|
|
CreateFont (nHeight, nWidth, nEscapement, nOrientation,
|
|
|
|
fnWeight, fdwItalic, fdwUnderline, fdwStrikeOut,
|
|
|
|
fdwCharSet, fdwOutputPrecision, fdwClipPrecision,
|
|
|
|
fdwQuality, fdwPitchAndFamily, lpszFace)) != NULL)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* If we fail, try some similar fonts often found on Windows. */
|
|
|
|
|
|
|
|
if (tries == 0)
|
|
|
|
{
|
|
|
|
if (g_strcasecmp (family, "helvetica") == 0)
|
|
|
|
lpszFace = "arial";
|
|
|
|
else if (g_strcasecmp (family, "new century schoolbook") == 0)
|
|
|
|
lpszFace = "century schoolbook";
|
|
|
|
else if (g_strcasecmp (family, "courier") == 0)
|
|
|
|
lpszFace = "courier new";
|
|
|
|
else if (g_strcasecmp (family, "lucida") == 0)
|
|
|
|
lpszFace = "lucida sans unicode";
|
|
|
|
else if (g_strcasecmp (family, "lucidatypewriter") == 0)
|
|
|
|
lpszFace = "lucida console";
|
|
|
|
else if (g_strcasecmp (family, "times") == 0)
|
|
|
|
lpszFace = "times new roman";
|
|
|
|
}
|
|
|
|
else if (tries == 1)
|
|
|
|
{
|
|
|
|
if (g_strcasecmp (family, "courier") == 0)
|
|
|
|
{
|
|
|
|
lpszFace = "";
|
|
|
|
fdwPitchAndFamily |= FF_MODERN;
|
|
|
|
}
|
|
|
|
else if (g_strcasecmp (family, "times new roman") == 0)
|
|
|
|
{
|
|
|
|
lpszFace = "";
|
|
|
|
fdwPitchAndFamily |= FF_ROMAN;
|
|
|
|
}
|
|
|
|
else if (g_strcasecmp (family, "helvetica") == 0
|
|
|
|
|| g_strcasecmp (family, "lucida") == 0)
|
|
|
|
{
|
|
|
|
lpszFace = "";
|
|
|
|
fdwPitchAndFamily |= FF_SWISS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lpszFace = "";
|
|
|
|
fdwPitchAndFamily = (fdwPitchAndFamily & 0x0F) | FF_DONTCARE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
tries++;
|
|
|
|
}
|
|
|
|
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
if (!hfont)
|
|
|
|
return NULL;
|
1999-03-05 19:53:56 +00:00
|
|
|
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
private = g_new (GdkFontPrivate, 1);
|
|
|
|
font = (GdkFont*) private;
|
|
|
|
|
|
|
|
private->xfont = hfont;
|
1999-03-05 19:53:56 +00:00
|
|
|
private->ref_count = 1;
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
private->names = NULL;
|
1999-03-05 19:53:56 +00:00
|
|
|
font->type = GDK_FONT_FONT;
|
|
|
|
GetObject (private->xfont, sizeof (logfont), &logfont);
|
|
|
|
oldfont = SelectObject (gdk_DC, private->xfont);
|
|
|
|
GetTextMetrics (gdk_DC, &textmetric);
|
1999-10-20 22:58:37 +00:00
|
|
|
private->charset = GetTextCharsetInfo (gdk_DC, &private->fs, 0);
|
1999-03-05 19:53:56 +00:00
|
|
|
SelectObject (gdk_DC, oldfont);
|
1999-10-20 22:58:37 +00:00
|
|
|
TranslateCharsetInfo ((DWORD *) private->charset, &csi, TCI_SRCCHARSET);
|
|
|
|
private->codepage = csi.ciACP;
|
|
|
|
GetCPInfo (private->codepage, &private->cpinfo);
|
1999-03-05 19:53:56 +00:00
|
|
|
font->ascent = textmetric.tmAscent;
|
|
|
|
font->descent = textmetric.tmDescent;
|
|
|
|
|
1999-10-20 22:58:37 +00:00
|
|
|
GDK_NOTE (MISC, g_print ("... = %#x charset %s codepage %d (max %d bytes) "
|
|
|
|
"asc %d desc %d\n",
|
|
|
|
private->xfont,
|
|
|
|
charset_name (private->charset),
|
|
|
|
private->codepage,
|
|
|
|
private->cpinfo.MaxCharSize,
|
|
|
|
font->ascent, font->descent));
|
1999-03-05 19:53:56 +00:00
|
|
|
|
|
|
|
/* This memory is leaked, so shoot me. */
|
|
|
|
f = g_new (HANDLE, 1);
|
|
|
|
*f = (HANDLE) ((guint) private->xfont + HFONT_DITHER);
|
|
|
|
gdk_xid_table_insert (f, font);
|
|
|
|
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
gdk_font_hash_insert (GDK_FONT_FONT, font, font_name);
|
|
|
|
|
1999-03-05 19:53:56 +00:00
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkFont*
|
|
|
|
gdk_fontset_load (gchar *fontset_name)
|
|
|
|
{
|
|
|
|
g_warning ("gdk_fontset_load: Not implemented");
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
|
1999-03-05 19:53:56 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkFont*
|
|
|
|
gdk_font_ref (GdkFont *font)
|
|
|
|
{
|
|
|
|
GdkFontPrivate *private;
|
|
|
|
|
|
|
|
g_return_val_if_fail (font != NULL, NULL);
|
|
|
|
|
|
|
|
private = (GdkFontPrivate*) font;
|
|
|
|
private->ref_count += 1;
|
1999-10-20 22:58:37 +00:00
|
|
|
|
|
|
|
GDK_NOTE (MISC, g_print ("gdk_font_ref %#x %d\n",
|
|
|
|
private->xfont, private->ref_count));
|
1999-03-05 19:53:56 +00:00
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_font_unref (GdkFont *font)
|
|
|
|
{
|
|
|
|
GdkFontPrivate *private;
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
private = (GdkFontPrivate*) font;
|
1999-03-05 19:53:56 +00:00
|
|
|
|
|
|
|
g_return_if_fail (font != NULL);
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
g_return_if_fail (private->ref_count > 0);
|
1999-03-05 19:53:56 +00:00
|
|
|
|
|
|
|
private->ref_count -= 1;
|
1999-10-20 22:58:37 +00:00
|
|
|
|
|
|
|
GDK_NOTE (MISC, g_print ("gdk_font_unref %#x %d%s\n",
|
|
|
|
private->xfont,
|
|
|
|
private->ref_count,
|
|
|
|
(private->ref_count == 0 ? " freeing" : "")));
|
|
|
|
|
1999-03-05 19:53:56 +00:00
|
|
|
if (private->ref_count == 0)
|
|
|
|
{
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
gdk_font_hash_remove (font->type, font);
|
|
|
|
|
1999-03-05 19:53:56 +00:00
|
|
|
switch (font->type)
|
|
|
|
{
|
|
|
|
case GDK_FONT_FONT:
|
|
|
|
gdk_xid_table_remove ((HANDLE) ((guint) private->xfont + HFONT_DITHER));
|
|
|
|
DeleteObject (private->xfont);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
g_free (font);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gdk_font_id (const GdkFont *font)
|
|
|
|
{
|
|
|
|
const GdkFontPrivate *font_private;
|
|
|
|
|
|
|
|
g_return_val_if_fail (font != NULL, 0);
|
|
|
|
|
|
|
|
font_private = (const GdkFontPrivate*) font;
|
|
|
|
|
|
|
|
if (font->type == GDK_FONT_FONT)
|
|
|
|
return (gint) font_private->xfont;
|
|
|
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gdk_font_equal (const GdkFont *fonta,
|
|
|
|
const GdkFont *fontb)
|
|
|
|
{
|
|
|
|
const GdkFontPrivate *privatea;
|
|
|
|
const GdkFontPrivate *privateb;
|
|
|
|
|
|
|
|
g_return_val_if_fail (fonta != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (fontb != NULL, FALSE);
|
|
|
|
|
|
|
|
privatea = (const GdkFontPrivate*) fonta;
|
|
|
|
privateb = (const GdkFontPrivate*) fontb;
|
|
|
|
|
|
|
|
if (fonta->type == GDK_FONT_FONT && fontb->type == GDK_FONT_FONT)
|
|
|
|
return (privatea->xfont == privateb->xfont);
|
|
|
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gdk_string_width (GdkFont *font,
|
|
|
|
const gchar *string)
|
|
|
|
{
|
|
|
|
return gdk_text_width (font, string, strlen (string));
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gdk_text_width (GdkFont *font,
|
|
|
|
const gchar *text,
|
|
|
|
gint text_length)
|
|
|
|
{
|
|
|
|
GdkFontPrivate *private;
|
|
|
|
HGDIOBJ oldfont;
|
|
|
|
SIZE size;
|
1999-10-20 22:58:37 +00:00
|
|
|
gint width, wlen;
|
|
|
|
wchar_t *wcstr;
|
1999-03-05 19:53:56 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (font != NULL, -1);
|
|
|
|
g_return_val_if_fail (text != NULL, -1);
|
|
|
|
|
1999-10-20 22:58:37 +00:00
|
|
|
if (text_length == 0)
|
|
|
|
return 0;
|
|
|
|
|
1999-03-05 19:53:56 +00:00
|
|
|
private = (GdkFontPrivate*) font;
|
|
|
|
|
|
|
|
switch (font->type)
|
|
|
|
{
|
|
|
|
case GDK_FONT_FONT:
|
|
|
|
oldfont = SelectObject (gdk_DC, private->xfont);
|
1999-10-20 22:58:37 +00:00
|
|
|
if (private->cpinfo.MaxCharSize > 1)
|
|
|
|
{
|
|
|
|
wcstr = g_new (wchar_t, text_length);
|
|
|
|
if ((wlen = MultiByteToWideChar (private->codepage, 0,
|
|
|
|
text, text_length,
|
|
|
|
wcstr, text_length)) == 0)
|
|
|
|
{
|
|
|
|
g_warning ("gdk_text_width: MultiByteToWideChar failed");
|
|
|
|
size.cx = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
GetTextExtentPoint32W (gdk_DC, wcstr, wlen, &size);
|
|
|
|
g_free (wcstr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GetTextExtentPoint32A (gdk_DC, text, text_length, &size);
|
|
|
|
}
|
1999-03-05 19:53:56 +00:00
|
|
|
SelectObject (gdk_DC, oldfont);
|
|
|
|
width = size.cx;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gdk_text_width_wc (GdkFont *font,
|
|
|
|
const GdkWChar *text,
|
|
|
|
gint text_length)
|
|
|
|
{
|
|
|
|
GdkFontPrivate *private;
|
|
|
|
HGDIOBJ oldfont;
|
|
|
|
SIZE size;
|
|
|
|
wchar_t *wcstr;
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
guchar *str;
|
1999-10-20 22:58:37 +00:00
|
|
|
gint i, width, wlen;
|
1999-03-05 19:53:56 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (font != NULL, -1);
|
|
|
|
g_return_val_if_fail (text != NULL, -1);
|
|
|
|
|
1999-10-20 22:58:37 +00:00
|
|
|
if (text_length == 0)
|
|
|
|
return 0;
|
|
|
|
|
1999-03-05 19:53:56 +00:00
|
|
|
private = (GdkFontPrivate*) font;
|
|
|
|
|
|
|
|
switch (font->type)
|
|
|
|
{
|
|
|
|
case GDK_FONT_FONT:
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
oldfont = SelectObject (gdk_DC, private->xfont);
|
|
|
|
#if 0 /* No. Don't assume Unicode here either.
|
|
|
|
* (Read the comments in gdk_draw_text_wc.)
|
|
|
|
*/
|
1999-03-05 19:53:56 +00:00
|
|
|
wcstr = g_new (wchar_t, text_length);
|
|
|
|
for (i = 0; i < text_length; i++)
|
|
|
|
wcstr[i] = text[i];
|
|
|
|
GetTextExtentPoint32W (gdk_DC, wcstr, text_length, &size);
|
|
|
|
g_free (wcstr);
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
#else
|
|
|
|
str = g_new (guchar, text_length);
|
1999-10-20 22:58:37 +00:00
|
|
|
for (i = 0; i < text_length; i++)
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
str[i] = text[i];
|
1999-10-20 22:58:37 +00:00
|
|
|
if (private->cpinfo.MaxCharSize > 1)
|
|
|
|
{
|
|
|
|
wcstr = g_new (wchar_t, text_length);
|
|
|
|
if ((wlen = MultiByteToWideChar (private->codepage, 0,
|
|
|
|
str, text_length,
|
|
|
|
wcstr, text_length)) == 0)
|
|
|
|
{
|
|
|
|
g_warning ("gdk_text_width_wc: MultiByteToWideChar failed");
|
|
|
|
size.cx = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
GetTextExtentPoint32W (gdk_DC, wcstr, wlen, &size);
|
|
|
|
g_free (wcstr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GetTextExtentPoint32A (gdk_DC, str, text_length, &size);
|
|
|
|
}
|
Don't use TextOutW for GDK_FONT_FONT fonts (which is all we have for now,
1999-10-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_text_wc): Don't use TextOutW for
GDK_FONT_FONT fonts (which is all we have for now, we don't
emulate fontsets). The X11 version uses plain XDrawString in that
case, too. The string passed to gdk_draw_text_wc seems to be in
fact (at least, when used by gtkentry and gtktext) either in a
single-byte charset, or a DBCS. Not Unicode.
This fixes the problem in gtkfontsel, where even if you had
selected a font with a non-Latin1 charset (windows-greek, for
instance), the preview still used Latin-1 glyphs.
* gdk/win32/gdkfont.c (gdk_text_width_wc): Similar change. Don't
use GetTextExtentPoint32W, use GetTextExtentPoint32A.
(gdk_font_load): Recognize the demibold etc weights, even if we
don't have the corresponding constants in the headers.
(gdk_font_hash_insert): Use same hash mechanism as in the X11
version. Should save font resources a bit, when we don't have
multiple HFONTs for the same font.
* gdk/win32/gdkprivate.h: Add the names field as in the X11
version.
1999-10-13 21:46:33 +00:00
|
|
|
g_free (str);
|
|
|
|
#endif
|
1999-03-05 19:53:56 +00:00
|
|
|
SelectObject (gdk_DC, oldfont);
|
|
|
|
width = size.cx;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
width = 0;
|
|
|
|
}
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gdk_char_width (GdkFont *font,
|
|
|
|
gchar character)
|
|
|
|
{
|
|
|
|
return gdk_text_width (font, &character, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gdk_char_width_wc (GdkFont *font,
|
|
|
|
GdkWChar character)
|
|
|
|
{
|
|
|
|
return gdk_text_width_wc (font, &character, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gdk_string_measure (GdkFont *font,
|
|
|
|
const gchar *string)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (font != NULL, -1);
|
|
|
|
g_return_val_if_fail (string != NULL, -1);
|
|
|
|
|
|
|
|
return gdk_text_measure (font, string, strlen (string));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_text_extents (GdkFont *font,
|
|
|
|
const gchar *text,
|
|
|
|
gint text_length,
|
|
|
|
gint *lbearing,
|
|
|
|
gint *rbearing,
|
|
|
|
gint *width,
|
|
|
|
gint *ascent,
|
|
|
|
gint *descent)
|
|
|
|
{
|
|
|
|
GdkFontPrivate *private;
|
|
|
|
HGDIOBJ oldfont;
|
|
|
|
SIZE size;
|
1999-10-20 22:58:37 +00:00
|
|
|
gint wlen;
|
|
|
|
wchar_t *wcstr;
|
1999-03-05 19:53:56 +00:00
|
|
|
|
|
|
|
g_return_if_fail (font != NULL);
|
|
|
|
g_return_if_fail (text != NULL);
|
|
|
|
|
1999-10-20 22:58:37 +00:00
|
|
|
if (text_length == 0)
|
|
|
|
{
|
|
|
|
if (lbearing)
|
|
|
|
*lbearing = 0;
|
|
|
|
if (rbearing)
|
|
|
|
*rbearing = 0;
|
|
|
|
if (width)
|
|
|
|
*width = 0;
|
|
|
|
if (ascent)
|
|
|
|
*ascent = 0;
|
|
|
|
if (descent)
|
|
|
|
*descent = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-03-05 19:53:56 +00:00
|
|
|
private = (GdkFontPrivate*) font;
|
|
|
|
|
|
|
|
switch (font->type)
|
|
|
|
{
|
|
|
|
case GDK_FONT_FONT:
|
|
|
|
oldfont = SelectObject (gdk_DC, private->xfont);
|
1999-10-20 22:58:37 +00:00
|
|
|
if (private->cpinfo.MaxCharSize > 1)
|
|
|
|
{
|
|
|
|
wcstr = g_new (wchar_t, text_length);
|
|
|
|
if ((wlen = MultiByteToWideChar (private->codepage, 0,
|
|
|
|
text, text_length,
|
|
|
|
wcstr, text_length)) == 0)
|
|
|
|
{
|
|
|
|
g_warning ("gdk_text_extents: MultiByteToWideChar failed");
|
|
|
|
size.cx = 0;
|
|
|
|
size.cy = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
GetTextExtentPoint32W (gdk_DC, wcstr, wlen, &size);
|
|
|
|
g_free (wcstr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GetTextExtentPoint32A (gdk_DC, text, text_length, &size);
|
|
|
|
}
|
1999-03-05 19:53:56 +00:00
|
|
|
SelectObject (gdk_DC, oldfont);
|
|
|
|
/* XXX This is all quite bogus */
|
|
|
|
if (lbearing)
|
|
|
|
*lbearing = 0;
|
|
|
|
if (rbearing)
|
|
|
|
*rbearing = 0;
|
|
|
|
if (width)
|
|
|
|
*width = size.cx;
|
|
|
|
if (ascent)
|
|
|
|
*ascent = size.cy + 1;
|
|
|
|
if (descent)
|
|
|
|
*descent = font->descent + 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_text_extents_wc (GdkFont *font,
|
|
|
|
const GdkWChar *text,
|
|
|
|
gint text_length,
|
|
|
|
gint *lbearing,
|
|
|
|
gint *rbearing,
|
|
|
|
gint *width,
|
|
|
|
gint *ascent,
|
|
|
|
gint *descent)
|
|
|
|
{
|
|
|
|
GdkFontPrivate *private;
|
|
|
|
HGDIOBJ oldfont;
|
|
|
|
SIZE size;
|
|
|
|
wchar_t *wcstr;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_return_if_fail (font != NULL);
|
|
|
|
g_return_if_fail (text != NULL);
|
|
|
|
|
1999-10-20 22:58:37 +00:00
|
|
|
if (text_length == 0)
|
|
|
|
{
|
|
|
|
if (lbearing)
|
|
|
|
*lbearing = 0;
|
|
|
|
if (rbearing)
|
|
|
|
*rbearing = 0;
|
|
|
|
if (width)
|
|
|
|
*width = 0;
|
|
|
|
if (ascent)
|
|
|
|
*ascent = 0;
|
|
|
|
if (descent)
|
|
|
|
*descent = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-03-05 19:53:56 +00:00
|
|
|
private = (GdkFontPrivate*) font;
|
|
|
|
|
|
|
|
switch (font->type)
|
|
|
|
{
|
|
|
|
case GDK_FONT_FONT:
|
|
|
|
wcstr = g_new (wchar_t, text_length);
|
|
|
|
for (i = 0; i < text_length; i++)
|
|
|
|
wcstr[i] = text[i];
|
|
|
|
oldfont = SelectObject (gdk_DC, private->xfont);
|
|
|
|
GetTextExtentPoint32W (gdk_DC, wcstr, text_length, &size);
|
|
|
|
g_free (wcstr);
|
|
|
|
SelectObject (gdk_DC, oldfont);
|
|
|
|
|
|
|
|
/* XXX This is all quite bogus */
|
|
|
|
if (lbearing)
|
|
|
|
*lbearing = 0;
|
|
|
|
if (rbearing)
|
|
|
|
*rbearing = 0;
|
|
|
|
if (width)
|
|
|
|
*width = size.cx;
|
|
|
|
if (ascent)
|
|
|
|
*ascent = size.cy + 1;
|
|
|
|
if (descent)
|
|
|
|
*descent = font->descent + 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_string_extents (GdkFont *font,
|
|
|
|
const gchar *string,
|
|
|
|
gint *lbearing,
|
|
|
|
gint *rbearing,
|
|
|
|
gint *width,
|
|
|
|
gint *ascent,
|
|
|
|
gint *descent)
|
|
|
|
{
|
|
|
|
g_return_if_fail (font != NULL);
|
|
|
|
g_return_if_fail (string != NULL);
|
|
|
|
|
|
|
|
gdk_text_extents (font, string, strlen (string),
|
|
|
|
lbearing, rbearing, width, ascent, descent);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gint
|
|
|
|
gdk_text_measure (GdkFont *font,
|
|
|
|
const gchar *text,
|
|
|
|
gint text_length)
|
|
|
|
{
|
|
|
|
GdkFontPrivate *private;
|
|
|
|
gint width;
|
|
|
|
|
|
|
|
g_return_val_if_fail (font != NULL, -1);
|
|
|
|
g_return_val_if_fail (text != NULL, -1);
|
|
|
|
|
|
|
|
private = (GdkFontPrivate*) font;
|
|
|
|
|
|
|
|
switch (font->type)
|
|
|
|
{
|
|
|
|
case GDK_FONT_FONT:
|
|
|
|
return gdk_text_width (font, text, text_length); /* ??? */
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gdk_char_measure (GdkFont *font,
|
|
|
|
gchar character)
|
|
|
|
{
|
|
|
|
return gdk_text_measure (font, &character, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gdk_string_height (GdkFont *font,
|
|
|
|
const gchar *string)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (font != NULL, -1);
|
|
|
|
g_return_val_if_fail (string != NULL, -1);
|
|
|
|
|
|
|
|
return gdk_text_height (font, string, strlen (string));
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gdk_text_height (GdkFont *font,
|
|
|
|
const gchar *text,
|
|
|
|
gint text_length)
|
|
|
|
{
|
|
|
|
GdkFontPrivate *private;
|
|
|
|
HGDIOBJ oldfont;
|
|
|
|
SIZE size;
|
1999-10-20 22:58:37 +00:00
|
|
|
gint height, wlen;
|
|
|
|
wchar_t *wcstr;
|
1999-03-05 19:53:56 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (font != NULL, -1);
|
|
|
|
g_return_val_if_fail (text != NULL, -1);
|
|
|
|
|
1999-10-20 22:58:37 +00:00
|
|
|
if (text_length == 0)
|
|
|
|
return 0;
|
|
|
|
|
1999-03-05 19:53:56 +00:00
|
|
|
private = (GdkFontPrivate*) font;
|
|
|
|
|
|
|
|
switch (font->type)
|
|
|
|
{
|
|
|
|
case GDK_FONT_FONT:
|
|
|
|
oldfont = SelectObject (gdk_DC, private->xfont);
|
1999-10-20 22:58:37 +00:00
|
|
|
if (private->cpinfo.MaxCharSize > 1)
|
|
|
|
{
|
|
|
|
wcstr = g_new (wchar_t, text_length);
|
|
|
|
if ((wlen = MultiByteToWideChar (private->codepage, 0,
|
|
|
|
text, text_length,
|
|
|
|
wcstr, text_length)) == 0)
|
|
|
|
{
|
|
|
|
g_warning ("gdk_text_height: MultiByteToWideChar failed "
|
|
|
|
"text = %.*s (%d)",
|
|
|
|
text_length, text, text_length);
|
|
|
|
size.cy = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
GetTextExtentPoint32W (gdk_DC, wcstr, wlen, &size);
|
|
|
|
g_free (wcstr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GetTextExtentPoint32A (gdk_DC, text, text_length, &size);
|
|
|
|
}
|
1999-03-05 19:53:56 +00:00
|
|
|
SelectObject (gdk_DC, oldfont);
|
|
|
|
height = size.cy;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_error ("font->type = %d", font->type);
|
|
|
|
}
|
|
|
|
return height;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gdk_char_height (GdkFont *font,
|
|
|
|
gchar character)
|
|
|
|
{
|
|
|
|
return gdk_text_height (font, &character, 1);
|
|
|
|
}
|