Remove deprecated gdk_text_* and gdk_string_* functions
Remove gdk_string_extents(), gdk_text_extents(), gdk_text_extents_wc(), gdk_string_width(), gdk_text_width(), gdk_text_width_wc(), gdk_string_measure(), gdk_text_measure(), gdk_string_height(), gdk_text_height()
This commit is contained in:
@@ -411,18 +411,6 @@ gdk_font_unref
|
||||
gdk_font_id
|
||||
gdk_font_equal
|
||||
|
||||
<SUBSECTION>
|
||||
gdk_string_extents
|
||||
gdk_text_extents
|
||||
gdk_text_extents_wc
|
||||
gdk_string_width
|
||||
gdk_text_width
|
||||
gdk_text_width_wc
|
||||
gdk_string_measure
|
||||
gdk_text_measure
|
||||
gdk_string_height
|
||||
gdk_text_height
|
||||
|
||||
<SUBSECTION>
|
||||
GdkWChar
|
||||
gdk_wcstombs
|
||||
|
||||
@@ -196,7 +196,7 @@ of forms of string input:
|
||||
<term>Wide character string</term>
|
||||
<listitem><para>
|
||||
For a number of the text-measuring functions, GDK
|
||||
provides a variant (such as gdk_text_width_wc()) which
|
||||
provides a variant which
|
||||
takes a <type>GdkWChar *</type> instead of a
|
||||
<type>gchar *</type>. The input is then taken to
|
||||
be a wide character string in the encoding of the
|
||||
@@ -387,114 +387,6 @@ are currently:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_string_extents ##### -->
|
||||
<para>
|
||||
</para>
|
||||
|
||||
@font:
|
||||
@string:
|
||||
@lbearing:
|
||||
@rbearing:
|
||||
@width:
|
||||
@ascent:
|
||||
@descent:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_text_extents ##### -->
|
||||
<para>
|
||||
</para>
|
||||
|
||||
@font:
|
||||
@text:
|
||||
@text_length:
|
||||
@lbearing:
|
||||
@rbearing:
|
||||
@width:
|
||||
@ascent:
|
||||
@descent:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_text_extents_wc ##### -->
|
||||
<para>
|
||||
</para>
|
||||
|
||||
@font:
|
||||
@text:
|
||||
@text_length:
|
||||
@lbearing:
|
||||
@rbearing:
|
||||
@width:
|
||||
@ascent:
|
||||
@descent:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_string_width ##### -->
|
||||
<para>
|
||||
</para>
|
||||
|
||||
@font:
|
||||
@string:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_text_width ##### -->
|
||||
<para>
|
||||
</para>
|
||||
|
||||
@font:
|
||||
@text:
|
||||
@text_length:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_text_width_wc ##### -->
|
||||
<para>
|
||||
</para>
|
||||
|
||||
@font:
|
||||
@text:
|
||||
@text_length:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_string_measure ##### -->
|
||||
<para>
|
||||
</para>
|
||||
|
||||
@font:
|
||||
@string:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_text_measure ##### -->
|
||||
<para>
|
||||
</para>
|
||||
|
||||
@font:
|
||||
@text:
|
||||
@text_length:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_string_height ##### -->
|
||||
<para>
|
||||
</para>
|
||||
|
||||
@font:
|
||||
@string:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gdk_text_height ##### -->
|
||||
<para>
|
||||
</para>
|
||||
|
||||
@font:
|
||||
@text:
|
||||
@text_length:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### TYPEDEF GdkWChar ##### -->
|
||||
<para>
|
||||
Specifies a wide character type, used to represent character codes.
|
||||
|
||||
@@ -188,78 +188,6 @@ gdk_font_equal (const GdkFont *fonta,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_text_width (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length)
|
||||
{
|
||||
GdkFontDirectFB *private;
|
||||
|
||||
private = (GdkFontDirectFB*) font;
|
||||
|
||||
return (text_length * private->size) / 2;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_text_width_wc (GdkFont *font,
|
||||
const GdkWChar *text,
|
||||
gint text_length)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_text_extents (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length,
|
||||
gint *lbearing,
|
||||
gint *rbearing,
|
||||
gint *width,
|
||||
gint *ascent,
|
||||
gint *descent)
|
||||
{
|
||||
if(ascent)
|
||||
*ascent = font->ascent;
|
||||
if(descent)
|
||||
*descent = font->descent;
|
||||
if(width)
|
||||
*width = gdk_text_width(font, text, text_length);
|
||||
if(lbearing)
|
||||
*lbearing = 0;
|
||||
if(rbearing)
|
||||
*rbearing = 0;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_text_extents_wc (GdkFont *font,
|
||||
const GdkWChar *text,
|
||||
gint text_length,
|
||||
gint *lbearing,
|
||||
gint *rbearing,
|
||||
gint *width,
|
||||
gint *ascent,
|
||||
gint *descent)
|
||||
{
|
||||
char *realstr;
|
||||
int i;
|
||||
|
||||
realstr = alloca (text_length + 1);
|
||||
|
||||
for(i = 0; i < text_length; i++)
|
||||
realstr[i] = text[i];
|
||||
|
||||
realstr[i] = '\0';
|
||||
|
||||
return gdk_text_extents (font,
|
||||
realstr,
|
||||
text_length,
|
||||
lbearing,
|
||||
rbearing,
|
||||
width,
|
||||
ascent,
|
||||
descent);
|
||||
}
|
||||
|
||||
GdkFont *
|
||||
gdk_font_lookup (GdkNativeWindow xid)
|
||||
{
|
||||
|
||||
@@ -320,12 +320,6 @@ gdk_font_ref
|
||||
gdk_font_unref
|
||||
#ifndef GDK_DISABLE_DEPRECATED
|
||||
gdk_font_load
|
||||
gdk_string_width
|
||||
gdk_string_measure
|
||||
gdk_text_measure
|
||||
gdk_string_height
|
||||
gdk_text_height
|
||||
gdk_string_extents
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
@@ -333,10 +327,6 @@ gdk_string_extents
|
||||
#if IN_HEADER(__GDK_FONT_H__)
|
||||
#if IN_FILE(__GDK_FONT_X11_C__)
|
||||
#ifndef GDK_DISABLE_DEPRECATED
|
||||
gdk_text_extents
|
||||
gdk_text_extents_wc
|
||||
gdk_text_width
|
||||
gdk_text_width_wc
|
||||
gdk_font_get_display
|
||||
gdk_fontset_load
|
||||
#endif
|
||||
|
||||
151
gdk/gdkfont.c
151
gdk/gdkfont.c
@@ -85,157 +85,6 @@ gdk_font_unref (GdkFont *font)
|
||||
_gdk_font_destroy (font);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_string_width:
|
||||
* @font: a #GdkFont
|
||||
* @string: the nul-terminated string to measure
|
||||
*
|
||||
* Determines the width of a nul-terminated string.
|
||||
* (The distance from the origin of the string to the
|
||||
* point where the next string in a sequence of strings
|
||||
* should be drawn)
|
||||
*
|
||||
* Return value: the width of the string in pixels.
|
||||
**/
|
||||
gint
|
||||
gdk_string_width (GdkFont *font,
|
||||
const gchar *string)
|
||||
{
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
g_return_val_if_fail (string != NULL, -1);
|
||||
|
||||
return gdk_text_width (font, string, _gdk_font_strlen (font, string));
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_string_measure:
|
||||
* @font: a #GdkFont
|
||||
* @string: the nul-terminated string to measure.
|
||||
*
|
||||
* Determines the distance from the origin to the rightmost
|
||||
* portion of a nul-terminated string when drawn. This is not the
|
||||
* correct value for determining the origin of the next
|
||||
* portion when drawing text in multiple pieces.
|
||||
* See gdk_string_width().
|
||||
*
|
||||
* Return value: the right bearing of the string in pixels.
|
||||
**/
|
||||
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, _gdk_font_strlen (font, string));
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_string_extents:
|
||||
* @font: a #GdkFont.
|
||||
* @string: the nul-terminated string to measure.
|
||||
* @lbearing: the left bearing of the string.
|
||||
* @rbearing: the right bearing of the string.
|
||||
* @width: the width of the string.
|
||||
* @ascent: the ascent of the string.
|
||||
* @descent: the descent of the string.
|
||||
*
|
||||
* Gets the metrics of a nul-terminated string.
|
||||
**/
|
||||
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, _gdk_font_strlen (font, string),
|
||||
lbearing, rbearing, width, ascent, descent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gdk_text_measure:
|
||||
* @font: a #GdkFont
|
||||
* @text: the text to measure.
|
||||
* @text_length: the length of the text in bytes.
|
||||
*
|
||||
* Determines the distance from the origin to the rightmost
|
||||
* portion of a string when drawn. This is not the
|
||||
* correct value for determining the origin of the next
|
||||
* portion when drawing text in multiple pieces.
|
||||
* See gdk_text_width().
|
||||
*
|
||||
* Return value: the right bearing of the string in pixels.
|
||||
**/
|
||||
gint
|
||||
gdk_text_measure (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length)
|
||||
{
|
||||
gint rbearing;
|
||||
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
g_return_val_if_fail (text != NULL, -1);
|
||||
|
||||
gdk_text_extents (font, text, text_length, NULL, &rbearing, NULL, NULL, NULL);
|
||||
return rbearing;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_string_height:
|
||||
* @font: a #GdkFont
|
||||
* @string: the nul-terminated string to measure.
|
||||
*
|
||||
* Determines the total height of a given nul-terminated
|
||||
* string. This value is not generally useful, because you
|
||||
* cannot determine how this total height will be drawn in
|
||||
* relation to the baseline. See gdk_string_extents().
|
||||
*
|
||||
* Return value: the height of the string in pixels.
|
||||
**/
|
||||
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, _gdk_font_strlen (font, string));
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_text_height:
|
||||
* @font: a #GdkFont
|
||||
* @text: the text to measure.
|
||||
* @text_length: the length of the text in bytes.
|
||||
*
|
||||
* Determines the total height of a given string.
|
||||
* This value is not generally useful, because you cannot
|
||||
* determine how this total height will be drawn in
|
||||
* relation to the baseline. See gdk_text_extents().
|
||||
*
|
||||
* Return value: the height of the string in pixels.
|
||||
**/
|
||||
gint
|
||||
gdk_text_height (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length)
|
||||
{
|
||||
gint ascent, descent;
|
||||
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
g_return_val_if_fail (text != NULL, -1);
|
||||
|
||||
gdk_text_extents (font, text, text_length, NULL, NULL, NULL, &ascent, &descent);
|
||||
return ascent + descent;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_font_from_description:
|
||||
* @font_desc: a #PangoFontDescription.
|
||||
|
||||
@@ -76,49 +76,6 @@ GdkFont* gdk_fontset_load (const gchar *fontset_name);
|
||||
GdkFont* gdk_font_from_description (PangoFontDescription *font_desc);
|
||||
#endif
|
||||
|
||||
gint gdk_string_width (GdkFont *font,
|
||||
const gchar *string);
|
||||
gint gdk_text_width (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length);
|
||||
gint gdk_text_width_wc (GdkFont *font,
|
||||
const GdkWChar *text,
|
||||
gint text_length);
|
||||
gint gdk_string_measure (GdkFont *font,
|
||||
const gchar *string);
|
||||
gint gdk_text_measure (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length);
|
||||
gint gdk_string_height (GdkFont *font,
|
||||
const gchar *string);
|
||||
gint gdk_text_height (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length);
|
||||
|
||||
void gdk_text_extents (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length,
|
||||
gint *lbearing,
|
||||
gint *rbearing,
|
||||
gint *width,
|
||||
gint *ascent,
|
||||
gint *descent);
|
||||
void gdk_text_extents_wc (GdkFont *font,
|
||||
const GdkWChar *text,
|
||||
gint text_length,
|
||||
gint *lbearing,
|
||||
gint *rbearing,
|
||||
gint *width,
|
||||
gint *ascent,
|
||||
gint *descent);
|
||||
void gdk_string_extents (GdkFont *font,
|
||||
const gchar *string,
|
||||
gint *lbearing,
|
||||
gint *rbearing,
|
||||
gint *width,
|
||||
gint *ascent,
|
||||
gint *descent);
|
||||
|
||||
GdkDisplay * gdk_font_get_display (GdkFont *font);
|
||||
|
||||
#endif /* GDK_DISABLE_DEPRECATED */
|
||||
|
||||
@@ -52,51 +52,6 @@ gdk_fontset_load (const gchar *fontset_name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_text_width (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length)
|
||||
{
|
||||
/* FIXME: Implement */
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_text_extents (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length,
|
||||
gint *lbearing,
|
||||
gint *rbearing,
|
||||
gint *width,
|
||||
gint *ascent,
|
||||
gint *descent)
|
||||
{
|
||||
/* FIXME: Implement */
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_text_width_wc (GdkFont *font,
|
||||
const GdkWChar *text,
|
||||
gint text_length)
|
||||
{
|
||||
/* FIXME: Implement */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gdk_text_extents_wc (GdkFont *font,
|
||||
const GdkWChar *text,
|
||||
gint text_length,
|
||||
gint *lbearing,
|
||||
gint *rbearing,
|
||||
gint *width,
|
||||
gint *ascent,
|
||||
gint *descent)
|
||||
{
|
||||
/* FIXME: Implement */
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_font_destroy (GdkFont *font)
|
||||
{
|
||||
|
||||
@@ -1531,186 +1531,6 @@ _gdk_wchar_text_handle (GdkFont *font,
|
||||
GDK_NOTE (MISC, g_print ("\n"));
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SIZE total;
|
||||
} gdk_text_size_arg;
|
||||
|
||||
static void
|
||||
gdk_text_size_handler (GdkWin32SingleFont *singlefont,
|
||||
const wchar_t *wcstr,
|
||||
int wclen,
|
||||
void *argp)
|
||||
{
|
||||
SIZE this_size;
|
||||
HGDIOBJ oldfont;
|
||||
gdk_text_size_arg *arg = (gdk_text_size_arg *) argp;
|
||||
|
||||
if (!singlefont)
|
||||
return;
|
||||
|
||||
if ((oldfont = SelectObject (_gdk_display_hdc, singlefont->hfont)) == NULL)
|
||||
{
|
||||
WIN32_GDI_FAILED ("SelectObject");
|
||||
return;
|
||||
}
|
||||
GetTextExtentPoint32W (_gdk_display_hdc, wcstr, wclen, &this_size);
|
||||
SelectObject (_gdk_display_hdc, oldfont);
|
||||
|
||||
arg->total.cx += this_size.cx;
|
||||
arg->total.cy = MAX (arg->total.cy, this_size.cy);
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_text_width (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length)
|
||||
{
|
||||
gint width = -1;
|
||||
|
||||
gdk_text_extents (font, text, text_length, NULL, NULL, &width, NULL, NULL);
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
gint
|
||||
gdk_text_width_wc (GdkFont *font,
|
||||
const GdkWChar *text,
|
||||
gint text_length)
|
||||
{
|
||||
gint width = -1;
|
||||
|
||||
gdk_text_extents_wc (font, text, text_length, NULL, NULL, &width, NULL, NULL);
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_text_extents (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length,
|
||||
gint *lbearing,
|
||||
gint *rbearing,
|
||||
gint *width,
|
||||
gint *ascent,
|
||||
gint *descent)
|
||||
{
|
||||
gdk_text_size_arg arg;
|
||||
glong wlen;
|
||||
wchar_t *wcstr, wc;
|
||||
|
||||
g_return_if_fail (font != NULL);
|
||||
g_return_if_fail (text != NULL);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
g_assert (font->type == GDK_FONT_FONT || font->type == GDK_FONT_FONTSET);
|
||||
|
||||
arg.total.cx = arg.total.cy = 0;
|
||||
|
||||
if (text_length == 1)
|
||||
{
|
||||
wc = (guchar) text[0];
|
||||
_gdk_wchar_text_handle (font, &wc, 1, gdk_text_size_handler, &arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
wcstr = g_utf8_to_utf16 (text, text_length, NULL, &wlen, NULL);
|
||||
_gdk_wchar_text_handle (font, wcstr, wlen, gdk_text_size_handler, &arg);
|
||||
g_free (wcstr);
|
||||
}
|
||||
|
||||
/* XXX This is quite bogus */
|
||||
if (lbearing)
|
||||
*lbearing = 0;
|
||||
if (rbearing)
|
||||
*rbearing = arg.total.cx;
|
||||
/* What should be the difference between width and rbearing? */
|
||||
if (width)
|
||||
*width = arg.total.cx;
|
||||
if (ascent)
|
||||
*ascent = arg.total.cy + 1;
|
||||
if (descent)
|
||||
*descent = font->descent + 1;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_text_extents_wc (GdkFont *font,
|
||||
const GdkWChar *text,
|
||||
gint text_length,
|
||||
gint *lbearing,
|
||||
gint *rbearing,
|
||||
gint *width,
|
||||
gint *ascent,
|
||||
gint *descent)
|
||||
{
|
||||
gdk_text_size_arg arg;
|
||||
wchar_t *wcstr;
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (font != NULL);
|
||||
g_return_if_fail (text != NULL);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
/* XXX This is quite bogus */
|
||||
if (lbearing)
|
||||
*lbearing = 0;
|
||||
if (rbearing)
|
||||
*rbearing = arg.total.cx;
|
||||
if (width)
|
||||
*width = arg.total.cx;
|
||||
if (ascent)
|
||||
*ascent = arg.total.cy + 1;
|
||||
if (descent)
|
||||
*descent = font->descent + 1;
|
||||
}
|
||||
|
||||
GdkDisplay*
|
||||
gdk_font_get_display (GdkFont* font)
|
||||
{
|
||||
|
||||
@@ -491,303 +491,6 @@ gdk_font_equal (const GdkFont *fonta,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_text_width:
|
||||
* @font: a #GdkFont
|
||||
* @text: the text to measure.
|
||||
* @text_length: the length of the text in bytes.
|
||||
*
|
||||
* Determines the width of a given string.
|
||||
*
|
||||
* Return value: the width of the string in pixels.
|
||||
**/
|
||||
gint
|
||||
gdk_text_width (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length)
|
||||
{
|
||||
GdkFontPrivateX *private;
|
||||
gint width;
|
||||
XFontStruct *xfont;
|
||||
XFontSet fontset;
|
||||
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
g_return_val_if_fail (text != NULL, -1);
|
||||
|
||||
private = (GdkFontPrivateX*) font;
|
||||
|
||||
switch (font->type)
|
||||
{
|
||||
case GDK_FONT_FONT:
|
||||
xfont = (XFontStruct *) private->xfont;
|
||||
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
|
||||
{
|
||||
width = XTextWidth (xfont, text, text_length);
|
||||
}
|
||||
else
|
||||
{
|
||||
width = XTextWidth16 (xfont, (XChar2b *) text, text_length / 2);
|
||||
}
|
||||
break;
|
||||
case GDK_FONT_FONTSET:
|
||||
fontset = (XFontSet) private->xfont;
|
||||
width = XmbTextEscapement (fontset, text, text_length);
|
||||
break;
|
||||
default:
|
||||
width = 0;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_text_width_wc:
|
||||
* @font: a #GdkFont
|
||||
* @text: the text to measure.
|
||||
* @text_length: the length of the text in characters.
|
||||
*
|
||||
* Determines the width of a given wide-character string.
|
||||
*
|
||||
* Return value: the width of the string in pixels.
|
||||
**/
|
||||
gint
|
||||
gdk_text_width_wc (GdkFont *font,
|
||||
const GdkWChar *text,
|
||||
gint text_length)
|
||||
{
|
||||
GdkFontPrivateX *private;
|
||||
gint width;
|
||||
XFontStruct *xfont;
|
||||
XFontSet fontset;
|
||||
|
||||
g_return_val_if_fail (font != NULL, -1);
|
||||
g_return_val_if_fail (text != NULL, -1);
|
||||
|
||||
private = (GdkFontPrivateX*) font;
|
||||
|
||||
switch (font->type)
|
||||
{
|
||||
case GDK_FONT_FONT:
|
||||
xfont = (XFontStruct *) private->xfont;
|
||||
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
|
||||
{
|
||||
gchar *text_8bit;
|
||||
gint i;
|
||||
text_8bit = g_new (gchar, text_length);
|
||||
for (i=0; i<text_length; i++) text_8bit[i] = text[i];
|
||||
width = XTextWidth (xfont, text_8bit, text_length);
|
||||
g_free (text_8bit);
|
||||
}
|
||||
else
|
||||
{
|
||||
width = 0;
|
||||
}
|
||||
break;
|
||||
case GDK_FONT_FONTSET:
|
||||
if (sizeof(GdkWChar) == sizeof(wchar_t))
|
||||
{
|
||||
fontset = (XFontSet) private->xfont;
|
||||
width = XwcTextEscapement (fontset, (wchar_t *)text, text_length);
|
||||
}
|
||||
else
|
||||
{
|
||||
wchar_t *text_wchar;
|
||||
gint i;
|
||||
fontset = (XFontSet) private->xfont;
|
||||
text_wchar = g_new(wchar_t, text_length);
|
||||
for (i=0; i<text_length; i++) text_wchar[i] = text[i];
|
||||
width = XwcTextEscapement (fontset, text_wchar, text_length);
|
||||
g_free (text_wchar);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
width = 0;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_text_extents:
|
||||
* @font: a #GdkFont
|
||||
* @text: the text to measure
|
||||
* @text_length: the length of the text in bytes. (If the
|
||||
* font is a 16-bit font, this is twice the length
|
||||
* of the text in characters.)
|
||||
* @lbearing: the left bearing of the string.
|
||||
* @rbearing: the right bearing of the string.
|
||||
* @width: the width of the string.
|
||||
* @ascent: the ascent of the string.
|
||||
* @descent: the descent of the string.
|
||||
*
|
||||
* Gets the metrics of a string.
|
||||
**/
|
||||
void
|
||||
gdk_text_extents (GdkFont *font,
|
||||
const gchar *text,
|
||||
gint text_length,
|
||||
gint *lbearing,
|
||||
gint *rbearing,
|
||||
gint *width,
|
||||
gint *ascent,
|
||||
gint *descent)
|
||||
{
|
||||
GdkFontPrivateX *private;
|
||||
XCharStruct overall;
|
||||
XFontStruct *xfont;
|
||||
XFontSet fontset;
|
||||
XRectangle ink, logical;
|
||||
int direction;
|
||||
int font_ascent;
|
||||
int font_descent;
|
||||
|
||||
g_return_if_fail (font != NULL);
|
||||
g_return_if_fail (text != NULL);
|
||||
|
||||
private = (GdkFontPrivateX*) font;
|
||||
|
||||
switch (font->type)
|
||||
{
|
||||
case GDK_FONT_FONT:
|
||||
xfont = (XFontStruct *) private->xfont;
|
||||
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
|
||||
{
|
||||
XTextExtents (xfont, text, text_length,
|
||||
&direction, &font_ascent, &font_descent,
|
||||
&overall);
|
||||
}
|
||||
else
|
||||
{
|
||||
XTextExtents16 (xfont, (XChar2b *) text, text_length / 2,
|
||||
&direction, &font_ascent, &font_descent,
|
||||
&overall);
|
||||
}
|
||||
if (lbearing)
|
||||
*lbearing = overall.lbearing;
|
||||
if (rbearing)
|
||||
*rbearing = overall.rbearing;
|
||||
if (width)
|
||||
*width = overall.width;
|
||||
if (ascent)
|
||||
*ascent = overall.ascent;
|
||||
if (descent)
|
||||
*descent = overall.descent;
|
||||
break;
|
||||
case GDK_FONT_FONTSET:
|
||||
fontset = (XFontSet) private->xfont;
|
||||
XmbTextExtents (fontset, text, text_length, &ink, &logical);
|
||||
if (lbearing)
|
||||
*lbearing = ink.x;
|
||||
if (rbearing)
|
||||
*rbearing = ink.x + ink.width;
|
||||
if (width)
|
||||
*width = logical.width;
|
||||
if (ascent)
|
||||
*ascent = -ink.y;
|
||||
if (descent)
|
||||
*descent = ink.y + ink.height;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_text_extents_wc:
|
||||
* @font: a #GdkFont
|
||||
* @text: the text to measure.
|
||||
* @text_length: the length of the text in character.
|
||||
* @lbearing: the left bearing of the string.
|
||||
* @rbearing: the right bearing of the string.
|
||||
* @width: the width of the string.
|
||||
* @ascent: the ascent of the string.
|
||||
* @descent: the descent of the string.
|
||||
*
|
||||
* Gets the metrics of a string of wide characters.
|
||||
**/
|
||||
void
|
||||
gdk_text_extents_wc (GdkFont *font,
|
||||
const GdkWChar *text,
|
||||
gint text_length,
|
||||
gint *lbearing,
|
||||
gint *rbearing,
|
||||
gint *width,
|
||||
gint *ascent,
|
||||
gint *descent)
|
||||
{
|
||||
GdkFontPrivateX *private;
|
||||
XCharStruct overall;
|
||||
XFontStruct *xfont;
|
||||
XFontSet fontset;
|
||||
XRectangle ink, logical;
|
||||
int direction;
|
||||
int font_ascent;
|
||||
int font_descent;
|
||||
|
||||
g_return_if_fail (font != NULL);
|
||||
g_return_if_fail (text != NULL);
|
||||
|
||||
private = (GdkFontPrivateX*) font;
|
||||
|
||||
switch (font->type)
|
||||
{
|
||||
case GDK_FONT_FONT:
|
||||
{
|
||||
gchar *text_8bit;
|
||||
gint i;
|
||||
|
||||
xfont = (XFontStruct *) private->xfont;
|
||||
g_return_if_fail ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0));
|
||||
|
||||
text_8bit = g_new (gchar, text_length);
|
||||
for (i=0; i<text_length; i++)
|
||||
text_8bit[i] = text[i];
|
||||
|
||||
XTextExtents (xfont, text_8bit, text_length,
|
||||
&direction, &font_ascent, &font_descent,
|
||||
&overall);
|
||||
g_free (text_8bit);
|
||||
|
||||
if (lbearing)
|
||||
*lbearing = overall.lbearing;
|
||||
if (rbearing)
|
||||
*rbearing = overall.rbearing;
|
||||
if (width)
|
||||
*width = overall.width;
|
||||
if (ascent)
|
||||
*ascent = overall.ascent;
|
||||
if (descent)
|
||||
*descent = overall.descent;
|
||||
break;
|
||||
}
|
||||
case GDK_FONT_FONTSET:
|
||||
fontset = (XFontSet) private->xfont;
|
||||
|
||||
if (sizeof(GdkWChar) == sizeof(wchar_t))
|
||||
XwcTextExtents (fontset, (wchar_t *)text, text_length, &ink, &logical);
|
||||
else
|
||||
{
|
||||
wchar_t *text_wchar;
|
||||
gint i;
|
||||
|
||||
text_wchar = g_new (wchar_t, text_length);
|
||||
for (i = 0; i < text_length; i++)
|
||||
text_wchar[i] = text[i];
|
||||
XwcTextExtents (fontset, text_wchar, text_length, &ink, &logical);
|
||||
g_free (text_wchar);
|
||||
}
|
||||
if (lbearing)
|
||||
*lbearing = ink.x;
|
||||
if (rbearing)
|
||||
*rbearing = ink.x + ink.width;
|
||||
if (width)
|
||||
*width = logical.width;
|
||||
if (ascent)
|
||||
*ascent = -ink.y;
|
||||
if (descent)
|
||||
*descent = ink.y + ink.height;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_x11_font_get_xdisplay:
|
||||
* @font: a #GdkFont.
|
||||
|
||||
@@ -693,8 +693,7 @@ gtk_ruler_real_draw_ticks (GtkRuler *ruler)
|
||||
increment = (gdouble) width / (upper - lower);
|
||||
|
||||
/* determine the scale H
|
||||
* We calculate the text size as for the vruler instead of using
|
||||
* text_width = gdk_string_width(font, unit_str), so that the result
|
||||
* We calculate the text size as for the vruler, so that the result
|
||||
* for the scale looks consistent with an accompanying vruler
|
||||
*/
|
||||
/* determine the scale V
|
||||
|
||||
Reference in New Issue
Block a user