2000-05-31 21:50:38 +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
|
2000-07-26 11:33:08 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
2000-05-31 21:50:38 +00:00
|
|
|
* 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
|
2000-07-26 11:33:08 +00:00
|
|
|
* Lesser General Public License for more details.
|
2000-05-31 21:50:38 +00:00
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2000-05-31 21:50:38 +00:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
2000-05-31 21:50:38 +00:00
|
|
|
* 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/.
|
|
|
|
*/
|
|
|
|
|
2004-03-06 03:38:59 +00:00
|
|
|
#include <config.h>
|
2000-05-31 21:50:38 +00:00
|
|
|
#include <math.h>
|
|
|
|
#include <stdlib.h>
|
2000-08-07 03:26:05 +00:00
|
|
|
#include <string.h>
|
2000-05-31 21:50:38 +00:00
|
|
|
#include "gdkfont.h"
|
|
|
|
#include "gdkprivate-fb.h"
|
2000-06-20 20:20:38 +00:00
|
|
|
#include "gdkpango.h"
|
2000-05-31 21:50:38 +00:00
|
|
|
|
2000-06-20 20:20:38 +00:00
|
|
|
#include <pango/pango.h>
|
|
|
|
|
|
|
|
#include <freetype/freetype.h>
|
|
|
|
#if !defined(FREETYPE_MAJOR) || FREETYPE_MAJOR != 2
|
2001-01-19 10:38:12 +00:00
|
|
|
#error "We need Freetype 2.0"
|
2000-06-20 20:20:38 +00:00
|
|
|
#endif
|
|
|
|
|
2001-01-19 10:38:12 +00:00
|
|
|
#ifdef EMULATE_GDKFONT
|
2000-05-31 21:50:38 +00:00
|
|
|
static GHashTable *font_name_hash = NULL;
|
|
|
|
static GHashTable *fontset_name_hash = NULL;
|
|
|
|
|
|
|
|
static void
|
2001-01-19 10:38:12 +00:00
|
|
|
gdk_font_hash_insert (GdkFontType type, GdkFont *font)
|
2000-05-31 21:50:38 +00:00
|
|
|
{
|
|
|
|
GdkFontPrivateFB *private = (GdkFontPrivateFB *)font;
|
2001-01-19 10:38:12 +00:00
|
|
|
|
2000-05-31 21:50:38 +00:00
|
|
|
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);
|
|
|
|
|
2001-01-19 10:38:12 +00:00
|
|
|
g_hash_table_insert (*hashp, private->name, font);
|
2000-05-31 21:50:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_font_hash_remove (GdkFontType type, GdkFont *font)
|
|
|
|
{
|
|
|
|
GdkFontPrivateFB *private = (GdkFontPrivateFB *)font;
|
2001-01-19 10:38:12 +00:00
|
|
|
|
2000-05-31 21:50:38 +00:00
|
|
|
GHashTable *hash = (type == GDK_FONT_FONT) ?
|
|
|
|
font_name_hash : fontset_name_hash;
|
|
|
|
|
2001-01-19 10:38:12 +00:00
|
|
|
g_hash_table_remove (hash, private->name);
|
2000-05-31 21:50:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-19 10:38:12 +00:00
|
|
|
GdkFont*
|
2002-09-10 15:19:13 +00:00
|
|
|
gdk_font_from_description_for_display (GdkDisplay *display,
|
|
|
|
PangoFontDescription *desc)
|
2001-01-19 10:38:12 +00:00
|
|
|
{
|
|
|
|
GdkFont *font;
|
|
|
|
GdkFontPrivateFB *private;
|
|
|
|
PangoFont *pango_font;
|
|
|
|
PangoContext *context;
|
2001-10-19 16:26:09 +00:00
|
|
|
PangoFontMetrics *metrics;
|
2001-06-15 15:58:26 +00:00
|
|
|
PangoLanguage *lang;
|
2001-01-19 10:38:12 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (desc, NULL);
|
|
|
|
|
|
|
|
private = g_new0 (GdkFontPrivateFB, 1);
|
|
|
|
private->base.ref_count = 1;
|
|
|
|
private->name = NULL;
|
|
|
|
|
|
|
|
font = (GdkFont*) private;
|
|
|
|
font->type = GDK_FONT_FONT;
|
|
|
|
|
|
|
|
context = gdk_pango_context_get ();
|
2001-06-15 15:58:26 +00:00
|
|
|
pango_context_set_base_dir (context, PANGO_DIRECTION_LTR);
|
|
|
|
pango_context_set_language (context, pango_language_from_string ("UNKNOWN"));
|
|
|
|
|
2001-01-19 10:38:12 +00:00
|
|
|
pango_font = pango_context_load_font (context, desc);
|
|
|
|
if (!pango_font)
|
|
|
|
{
|
2001-01-23 14:37:54 +00:00
|
|
|
desc = pango_font_description_copy (desc);
|
2001-10-19 16:26:09 +00:00
|
|
|
pango_font_description_set_family (desc, "sans");
|
2001-01-19 10:38:12 +00:00
|
|
|
pango_font = pango_context_load_font (context, desc);
|
|
|
|
if (!pango_font)
|
|
|
|
{
|
2001-10-19 16:26:09 +00:00
|
|
|
pango_font_description_set_style (desc, PANGO_STYLE_NORMAL);
|
|
|
|
pango_font_description_set_weight (desc, PANGO_WEIGHT_NORMAL);
|
|
|
|
pango_font_description_set_variant (desc, PANGO_VARIANT_NORMAL);
|
|
|
|
pango_font_description_set_stretch (desc, PANGO_STRETCH_NORMAL);
|
2001-01-19 10:38:12 +00:00
|
|
|
pango_font = pango_context_load_font (context, desc);
|
|
|
|
}
|
2001-01-23 14:37:54 +00:00
|
|
|
pango_font_description_free (desc);
|
2001-01-19 10:38:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_assert (pango_font != NULL);
|
|
|
|
|
|
|
|
if (pango_font == NULL)
|
2001-01-23 14:37:54 +00:00
|
|
|
{
|
|
|
|
g_free (private);
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-01-19 10:38:12 +00:00
|
|
|
|
2001-06-15 15:58:26 +00:00
|
|
|
lang = pango_context_get_language (context);
|
2001-10-19 16:26:09 +00:00
|
|
|
metrics = pango_font_get_metrics (pango_font, lang);
|
2001-01-19 10:38:12 +00:00
|
|
|
|
|
|
|
private->pango_font = pango_font;
|
|
|
|
|
|
|
|
g_free (lang);
|
2002-09-25 07:23:55 +00:00
|
|
|
g_object_unref (context);
|
2001-01-19 10:38:12 +00:00
|
|
|
|
2001-10-24 23:41:12 +00:00
|
|
|
font->ascent = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics));
|
|
|
|
font->descent = PANGO_PIXELS (pango_font_metrics_get_descent (metrics));
|
2001-01-19 10:38:12 +00:00
|
|
|
|
|
|
|
g_assert ((font->ascent > 0) || (font->descent > 0));
|
2001-10-19 16:26:09 +00:00
|
|
|
|
2001-10-24 23:41:12 +00:00
|
|
|
pango_font_metrics_unref (metrics);
|
2001-01-19 10:38:12 +00:00
|
|
|
|
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-31 21:50:38 +00:00
|
|
|
GdkFont*
|
2002-09-10 15:19:13 +00:00
|
|
|
gdk_font_load_for_display (GdkDisplay *display,
|
|
|
|
const gchar *font_name)
|
2000-05-31 21:50:38 +00:00
|
|
|
{
|
|
|
|
GdkFont *font;
|
|
|
|
GdkFontPrivateFB *private;
|
2001-10-24 23:41:12 +00:00
|
|
|
PangoFontDescription *desc;
|
2001-01-19 10:38:12 +00:00
|
|
|
gchar **pieces;
|
2000-05-31 21:50:38 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (font_name != NULL, NULL);
|
|
|
|
|
2001-01-19 10:38:12 +00:00
|
|
|
font = gdk_font_hash_lookup (GDK_FONT_FONT, font_name);
|
2000-05-31 21:50:38 +00:00
|
|
|
if (font)
|
|
|
|
return font;
|
|
|
|
|
2001-10-24 23:41:12 +00:00
|
|
|
desc = pango_font_description_new ();
|
2001-01-19 10:38:12 +00:00
|
|
|
|
2001-01-31 09:18:20 +00:00
|
|
|
pieces = g_strsplit (font_name, "-", 8);
|
2000-05-31 21:50:38 +00:00
|
|
|
|
2001-01-19 10:38:12 +00:00
|
|
|
do {
|
|
|
|
if (!pieces[0])
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (!pieces[1])
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (!pieces[2])
|
|
|
|
break;
|
2000-05-31 21:50:38 +00:00
|
|
|
|
2001-01-19 10:38:12 +00:00
|
|
|
if (strcmp (pieces[2], "*")!=0)
|
2001-11-24 21:52:50 +00:00
|
|
|
pango_font_description_set_family (desc, pieces[2]);
|
2001-01-19 10:38:12 +00:00
|
|
|
|
|
|
|
if (!pieces[3])
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (strcmp (pieces[3], "light")==0)
|
2001-10-24 23:41:12 +00:00
|
|
|
pango_font_description_set_weight (desc, PANGO_WEIGHT_LIGHT);
|
2001-01-19 10:38:12 +00:00
|
|
|
if (strcmp (pieces[3], "medium")==0)
|
2001-10-24 23:41:12 +00:00
|
|
|
pango_font_description_set_weight (desc, PANGO_WEIGHT_NORMAL);
|
2001-01-19 10:38:12 +00:00
|
|
|
if (strcmp (pieces[3], "bold")==0)
|
2001-10-24 23:41:12 +00:00
|
|
|
pango_font_description_set_weight (desc, PANGO_WEIGHT_BOLD);
|
2001-01-19 10:38:12 +00:00
|
|
|
|
|
|
|
if (!pieces[4])
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (strcmp (pieces[4], "r")==0)
|
2001-10-24 23:41:12 +00:00
|
|
|
pango_font_description_set_style (desc, PANGO_STYLE_NORMAL);
|
2001-01-19 10:38:12 +00:00
|
|
|
if (strcmp (pieces[4], "i")==0)
|
2001-10-24 23:41:12 +00:00
|
|
|
pango_font_description_set_style (desc, PANGO_STYLE_ITALIC);
|
2001-01-19 10:38:12 +00:00
|
|
|
if (strcmp (pieces[4], "o")==0)
|
2001-10-24 23:41:12 +00:00
|
|
|
pango_font_description_set_style (desc, PANGO_STYLE_OBLIQUE);
|
2001-01-19 10:38:12 +00:00
|
|
|
|
|
|
|
if (!pieces[5])
|
|
|
|
break;
|
|
|
|
if (!pieces[6])
|
|
|
|
break;
|
|
|
|
if (!pieces[7])
|
|
|
|
break;
|
2000-05-31 21:50:38 +00:00
|
|
|
|
2001-01-19 10:38:12 +00:00
|
|
|
if (strcmp (pieces[7], "*")!=0)
|
2001-11-24 21:52:50 +00:00
|
|
|
pango_font_description_set_size (desc, atoi (pieces[7]) * PANGO_SCALE);
|
2001-10-24 23:41:12 +00:00
|
|
|
if (pango_font_description_get_size (desc) == 0)
|
|
|
|
pango_font_description_set_size (desc, 12 * PANGO_SCALE);
|
2001-01-19 10:38:12 +00:00
|
|
|
|
|
|
|
} while (0);
|
|
|
|
|
2001-10-24 23:41:12 +00:00
|
|
|
font = gdk_font_from_description (desc);
|
2001-01-19 10:38:12 +00:00
|
|
|
private = (GdkFontPrivateFB*) font;
|
|
|
|
private->name = g_strdup (font_name);
|
2000-05-31 21:50:38 +00:00
|
|
|
|
2001-01-19 10:38:12 +00:00
|
|
|
gdk_font_hash_insert (GDK_FONT_FONT, font);
|
2000-05-31 21:50:38 +00:00
|
|
|
|
2001-11-24 21:52:50 +00:00
|
|
|
g_strfreev (pieces);
|
2000-05-31 21:50:38 +00:00
|
|
|
|
2001-10-24 23:41:12 +00:00
|
|
|
pango_font_description_free (desc);
|
2001-01-19 10:38:12 +00:00
|
|
|
|
2000-05-31 21:50:38 +00:00
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkFont*
|
|
|
|
gdk_fontset_load (const gchar *fontset_name)
|
|
|
|
{
|
|
|
|
return gdk_font_load(fontset_name);
|
|
|
|
}
|
2001-01-19 10:38:12 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
_gdk_font_destroy (GdkFont *font)
|
|
|
|
{
|
|
|
|
GdkFontPrivateFB *private = (GdkFontPrivateFB *)font;
|
|
|
|
gdk_font_hash_remove (font->type, font);
|
|
|
|
|
2002-09-25 07:23:55 +00:00
|
|
|
g_object_unref (private->pango_font);
|
2001-01-19 10:38:12 +00:00
|
|
|
g_free (private->name);
|
|
|
|
g_free (font);
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
_gdk_font_strlen (GdkFont *font,
|
|
|
|
const gchar *str)
|
|
|
|
{
|
|
|
|
GdkFontPrivateFB *font_private;
|
|
|
|
|
|
|
|
g_return_val_if_fail (font != NULL, -1);
|
|
|
|
g_return_val_if_fail (str != NULL, -1);
|
|
|
|
|
|
|
|
font_private = (GdkFontPrivateFB*) font;
|
|
|
|
|
|
|
|
return strlen (str);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Assumes text is in Latin-1 for performance reasons.
|
|
|
|
If you need another encoding, use pangofont */
|
|
|
|
void
|
|
|
|
gdk_text_extents (GdkFont *font,
|
|
|
|
const gchar *text,
|
|
|
|
gint text_length,
|
|
|
|
gint *lbearing,
|
|
|
|
gint *rbearing,
|
|
|
|
gint *width,
|
|
|
|
gint *ascent,
|
|
|
|
gint *descent)
|
|
|
|
{
|
|
|
|
GdkFontPrivateFB *private;
|
|
|
|
guchar *utf8, *utf8_end;
|
|
|
|
PangoGlyphString *glyphs = pango_glyph_string_new ();
|
|
|
|
PangoEngineShape *shaper, *last_shaper;
|
|
|
|
PangoAnalysis analysis;
|
|
|
|
guchar *p, *start;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
g_return_if_fail (font != NULL);
|
|
|
|
g_return_if_fail (text != NULL);
|
|
|
|
|
|
|
|
private = (GdkFontPrivateFB*) font;
|
|
|
|
|
|
|
|
if(ascent)
|
|
|
|
*ascent = 0;
|
|
|
|
if(descent)
|
|
|
|
*descent = 0;
|
|
|
|
if(width)
|
|
|
|
*width = 0;
|
|
|
|
if(lbearing)
|
|
|
|
*lbearing = 0;
|
|
|
|
if(rbearing)
|
|
|
|
*rbearing = 0;
|
|
|
|
|
|
|
|
utf8 = alloca (text_length*2);
|
|
|
|
|
|
|
|
/* Convert latin-1 to utf8 */
|
|
|
|
p = utf8;
|
2001-01-31 09:18:20 +00:00
|
|
|
for (i = 0; i < text_length; i++)
|
2001-01-19 10:38:12 +00:00
|
|
|
{
|
|
|
|
if (text[i]==0)
|
|
|
|
*p++ = 1; /* Hack to handle embedded nulls */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(((guchar)text[i])<128)
|
|
|
|
*p++ = text[i];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*p++ = ((((guchar)text[i])>>6) & 0x3f) | 0xC0;
|
|
|
|
*p++ = (((guchar)text[i]) & 0x3f) | 0x80;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
utf8_end = p;
|
|
|
|
|
|
|
|
last_shaper = NULL;
|
|
|
|
shaper = NULL;
|
|
|
|
|
|
|
|
p = start = utf8;
|
|
|
|
while (p < utf8_end)
|
|
|
|
{
|
|
|
|
gunichar wc = g_utf8_get_char (p);
|
|
|
|
p = g_utf8_next_char (p);
|
2001-09-08 00:30:13 +00:00
|
|
|
shaper = pango_font_find_shaper (private->pango_font, pango_language_from_string ("fr"), wc);
|
2001-01-19 10:38:12 +00:00
|
|
|
if (shaper != last_shaper)
|
|
|
|
{
|
|
|
|
analysis.shape_engine = shaper;
|
|
|
|
analysis.lang_engine = NULL;
|
|
|
|
analysis.font = private->pango_font;
|
|
|
|
analysis.level = 0;
|
|
|
|
|
|
|
|
pango_shape (start, p - start, &analysis, glyphs);
|
|
|
|
|
|
|
|
for (i = 0; i < glyphs->num_glyphs; i++)
|
|
|
|
{
|
|
|
|
PangoRectangle ink_rect;
|
|
|
|
PangoGlyphGeometry *geometry = &glyphs->glyphs[i].geometry;
|
|
|
|
|
|
|
|
pango_font_get_glyph_extents (private->pango_font, glyphs->glyphs[i].glyph,
|
|
|
|
&ink_rect, NULL);
|
|
|
|
|
|
|
|
if(ascent)
|
|
|
|
*ascent = MAX (*ascent, ink_rect.y);
|
|
|
|
if(descent)
|
|
|
|
*descent = MAX (*descent, ink_rect.height - ink_rect.y);
|
|
|
|
if(width)
|
|
|
|
*width += geometry->width;
|
|
|
|
if(lbearing)
|
|
|
|
*lbearing = 0;
|
|
|
|
if(rbearing)
|
|
|
|
*rbearing = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
start = p;
|
|
|
|
}
|
|
|
|
|
|
|
|
last_shaper = shaper;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p > start)
|
|
|
|
{
|
|
|
|
analysis.shape_engine = shaper;
|
|
|
|
analysis.lang_engine = NULL;
|
|
|
|
analysis.font = private->pango_font;
|
|
|
|
analysis.level = 0;
|
|
|
|
|
|
|
|
pango_shape (start, p - start, &analysis, glyphs);
|
|
|
|
|
|
|
|
for (i = 0; i < glyphs->num_glyphs; i++)
|
|
|
|
{
|
|
|
|
PangoRectangle ink_rect;
|
|
|
|
PangoGlyphGeometry *geometry = &glyphs->glyphs[i].geometry;
|
|
|
|
|
|
|
|
pango_font_get_glyph_extents (private->pango_font, glyphs->glyphs[i].glyph,
|
|
|
|
&ink_rect, NULL);
|
|
|
|
|
|
|
|
if(ascent)
|
|
|
|
*ascent = MAX (*ascent, ink_rect.y);
|
|
|
|
if(descent)
|
|
|
|
*descent = MAX (*descent, ink_rect.height - ink_rect.y);
|
|
|
|
if(width)
|
|
|
|
*width += geometry->width;
|
|
|
|
if(lbearing)
|
|
|
|
*lbearing = 0;
|
|
|
|
if(rbearing)
|
|
|
|
*rbearing = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pango_glyph_string_free (glyphs);
|
|
|
|
|
|
|
|
if(ascent)
|
|
|
|
*ascent = PANGO_PIXELS (*ascent);
|
|
|
|
if(descent)
|
|
|
|
*descent = PANGO_PIXELS(*descent);
|
|
|
|
if(width)
|
|
|
|
*width = PANGO_PIXELS (*width);
|
|
|
|
if(lbearing)
|
|
|
|
*lbearing = PANGO_PIXELS (*lbearing);
|
|
|
|
if(rbearing)
|
|
|
|
*rbearing = PANGO_PIXELS (*rbearing);
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
/* Don't emulate GdkFont */
|
|
|
|
static GdkFont *
|
|
|
|
gdk_fb_bogus_font (gint height)
|
|
|
|
{
|
|
|
|
GdkFont *font;
|
|
|
|
GdkFontPrivateFB *private;
|
|
|
|
|
|
|
|
private = g_new0 (GdkFontPrivateFB, 1);
|
|
|
|
font = (GdkFont *)private;
|
|
|
|
|
|
|
|
font->type = GDK_FONT_FONT;
|
|
|
|
font->ascent = height*3/4;
|
|
|
|
font->descent = height/4;
|
|
|
|
private->size = height;
|
|
|
|
private->base.ref_count = 1;
|
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkFont*
|
|
|
|
gdk_font_from_description (PangoFontDescription *font_desc)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (font_desc, NULL);
|
|
|
|
|
2001-10-19 16:26:09 +00:00
|
|
|
return gdk_fb_bogus_font (PANGO_PIXELS (pango_font_description_get_size (font_desc)));
|
2001-01-19 10:38:12 +00:00
|
|
|
}
|
2000-05-31 21:50:38 +00:00
|
|
|
|
2000-12-08 16:01:46 +00:00
|
|
|
GdkFont*
|
|
|
|
gdk_fontset_load (const gchar *fontset_name)
|
|
|
|
{
|
2001-01-05 14:01:36 +00:00
|
|
|
return gdk_fb_bogus_font (10);
|
2000-12-08 16:01:46 +00:00
|
|
|
}
|
|
|
|
|
2000-11-13 17:40:23 +00:00
|
|
|
GdkFont *
|
|
|
|
gdk_font_load (const gchar *font_name)
|
|
|
|
{
|
2001-01-05 14:01:36 +00:00
|
|
|
return gdk_fb_bogus_font (10);
|
2000-11-13 17:40:23 +00:00
|
|
|
}
|
|
|
|
|
2000-05-31 21:50:38 +00:00
|
|
|
void
|
|
|
|
_gdk_font_destroy (GdkFont *font)
|
|
|
|
{
|
|
|
|
g_free (font);
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
_gdk_font_strlen (GdkFont *font,
|
|
|
|
const gchar *str)
|
|
|
|
{
|
|
|
|
GdkFontPrivateFB *font_private;
|
|
|
|
gint length = 0;
|
|
|
|
|
|
|
|
g_return_val_if_fail (font != NULL, -1);
|
|
|
|
g_return_val_if_fail (str != NULL, -1);
|
|
|
|
|
|
|
|
font_private = (GdkFontPrivateFB*) font;
|
2001-01-19 10:38:12 +00:00
|
|
|
|
|
|
|
return strlen (str);
|
|
|
|
}
|
2000-05-31 21:50:38 +00:00
|
|
|
|
2001-01-19 10:38:12 +00:00
|
|
|
gint
|
|
|
|
gdk_text_width (GdkFont *font,
|
|
|
|
const gchar *text,
|
|
|
|
gint text_length)
|
|
|
|
{
|
|
|
|
GdkFontPrivateFB *private;
|
|
|
|
|
|
|
|
private = (GdkFontPrivateFB*) font;
|
2000-05-31 21:50:38 +00:00
|
|
|
|
2001-01-19 10:38:12 +00:00
|
|
|
return (text_length * private->size) / 2;
|
2000-05-31 21:50:38 +00:00
|
|
|
}
|
|
|
|
|
2001-01-19 10:38:12 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2000-05-31 21:50:38 +00:00
|
|
|
gint
|
|
|
|
gdk_font_id (const GdkFont *font)
|
|
|
|
{
|
|
|
|
const GdkFontPrivateFB *font_private;
|
|
|
|
|
|
|
|
g_return_val_if_fail (font != NULL, 0);
|
|
|
|
|
|
|
|
font_private = (const GdkFontPrivateFB*) font;
|
|
|
|
|
|
|
|
if (font->type == GDK_FONT_FONT)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gdk_font_equal (const GdkFont *fonta,
|
|
|
|
const GdkFont *fontb)
|
|
|
|
{
|
|
|
|
const GdkFontPrivateFB *privatea;
|
|
|
|
const GdkFontPrivateFB *privateb;
|
|
|
|
|
|
|
|
g_return_val_if_fail (fonta != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (fontb != NULL, FALSE);
|
|
|
|
|
|
|
|
privatea = (const GdkFontPrivateFB*) fonta;
|
|
|
|
privateb = (const GdkFontPrivateFB*) fontb;
|
|
|
|
|
|
|
|
if(fonta == fontb)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gint
|
|
|
|
gdk_text_width_wc (GdkFont *font,
|
|
|
|
const GdkWChar *text,
|
|
|
|
gint text_length)
|
|
|
|
{
|
2000-06-20 20:20:38 +00:00
|
|
|
return 0;
|
2000-05-31 21:50:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_text_extents_wc (GdkFont *font,
|
|
|
|
const GdkWChar *text,
|
|
|
|
gint text_length,
|
|
|
|
gint *lbearing,
|
|
|
|
gint *rbearing,
|
|
|
|
gint *width,
|
|
|
|
gint *ascent,
|
|
|
|
gint *descent)
|
|
|
|
{
|
2001-01-19 10:38:12 +00:00
|
|
|
g_warning ("gdk_text_extents_wc() is not implemented\n");
|
|
|
|
return;
|
2000-05-31 21:50:38 +00:00
|
|
|
}
|